diff options
Diffstat (limited to 'libtests/input_source.cc')
-rw-r--r-- | libtests/input_source.cc | 41 |
1 files changed, 11 insertions, 30 deletions
diff --git a/libtests/input_source.cc b/libtests/input_source.cc index 9ab41b5d..4111fd65 100644 --- a/libtests/input_source.cc +++ b/libtests/input_source.cc @@ -47,8 +47,7 @@ Finder::check() void check(char const* description, bool expected, bool actual) { - std::cout << description << ": " << ((actual == expected) ? "PASS" : "FAIL") - << std::endl; + std::cout << description << ": " << ((actual == expected) ? "PASS" : "FAIL") << std::endl; } int @@ -61,28 +60,15 @@ main() // Overlap so that the first check() would advance past the start // of the next match memcpy(b + 2037, "potato potato salad ", 20); - auto is = std::shared_ptr<InputSource>( - new BufferInputSource("test buffer input source", b1.get())); + auto is = + std::shared_ptr<InputSource>(new BufferInputSource("test buffer input source", b1.get())); Finder f1(is, "salad"); check("find potato salad", true, is->findFirst("potato", 0, 0, f1)); - check( - "barely find potato salad", - true, - is->findFirst("potato", 1100, 945, f1)); - check( - "barely find potato salad", - true, - is->findFirst("potato", 2000, 45, f1)); - check( - "potato salad is too late", - false, - is->findFirst("potato", 1100, 944, f1)); - check( - "potato salad is too late", - false, - is->findFirst("potato", 2000, 44, f1)); - check( - "potato salad not found", false, is->findFirst("potato", 2045, 0, f1)); + check("barely find potato salad", true, is->findFirst("potato", 1100, 945, f1)); + check("barely find potato salad", true, is->findFirst("potato", 2000, 45, f1)); + check("potato salad is too late", false, is->findFirst("potato", 1100, 944, f1)); + check("potato salad is too late", false, is->findFirst("potato", 2000, 44, f1)); + check("potato salad not found", false, is->findFirst("potato", 2045, 0, f1)); check("potato salad not found", false, is->findFirst("potato", 0, 1, f1)); // Put one more right at EOF @@ -91,18 +77,13 @@ main() is->findFirst("potato", 0, 0, f1); check("findFirst found first", true, is->tell() == 2056); - check( - "findLast found potato salad", true, is->findLast("potato", 0, 0, f1)); + check("findLast found potato salad", true, is->findLast("potato", 0, 0, f1)); check("findLast found at EOF", true, is->tell() == 3172); // Make check() bump into EOF memcpy(b + b1->getSize() - 6, "potato", 6); - check( - "potato but not salad salad at EOF", - false, - is->findFirst("potato", 3000, 0, f1)); - check( - "findLast found potato salad", true, is->findLast("potato", 0, 0, f1)); + check("potato but not salad salad at EOF", false, is->findFirst("potato", 3000, 0, f1)); + check("findLast found potato salad", true, is->findLast("potato", 0, 0, f1)); check("findLast found first one", true, is->tell() == 2056); return 0; |