Refactor for better multi-read support. Each read is now held separately, with

F_DESYNC being deprecated, and FluxSource returns an iterator which can be used
to retry reads.
This commit is contained in:
David Given
2022-03-07 00:07:42 +01:00
parent 78186d8a45
commit 96214bf3fd
25 changed files with 347 additions and 146 deletions

View File

@@ -1,5 +1,8 @@
#include "globals.h"
#include "bytes.h"
#include "snowhouse/snowhouse.h"
using namespace snowhouse;
static void check_oob(Bytes& b, unsigned pos)
{
@@ -115,6 +118,49 @@ static void test_slice()
assert((bs == Bytes{ 0, 0 }));
}
static void test_split()
{
AssertThat(
(Bytes{ }).split(0),
Equals(std::vector<Bytes> {
Bytes{}
}));
AssertThat(
(Bytes{ 0 }).split(0),
Equals(std::vector<Bytes> {
Bytes{},
Bytes{}
}));
AssertThat(
(Bytes{ 1 }).split(0),
Equals(std::vector<Bytes> {
Bytes{ 1 }
}));
AssertThat(
(Bytes{ 1, 0 }).split(0),
Equals(std::vector<Bytes> {
Bytes{ 1 },
Bytes{ }
}));
AssertThat(
(Bytes{ 0, 1 }).split(0),
Equals(std::vector<Bytes> {
Bytes{ },
Bytes{ 1 }
}));
AssertThat(
(Bytes{ 1, 0, 1 }).split(0),
Equals(std::vector<Bytes> {
Bytes{ 1 },
Bytes{ 1 }
}));
}
static void test_tobits()
{
Bytes b = {1, 2};
@@ -139,6 +185,7 @@ int main(int argc, const char* argv[])
test_reads();
test_writes();
test_slice();
test_split();
test_tobits();
test_tostring();
return 0;