summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2010-10-25 09:41:30 +0100
committerLars Wirzenius <liw@liw.fi>2010-10-25 09:41:30 +0100
commitb9b308aa5ab1507c290f350c841dc872a0b7c936 (patch)
tree2c155f1291606761aca0d2719ac86ea0f41c8605
parent0be32d20fecb5e34dfa4579110434ffe5530ffbc (diff)
downloaddynstr-b9b308aa5ab1507c290f350c841dc872a0b7c936.tar.gz
Add tests to get full coverage for dynstr_first_byte and dynstr_last_byte.
-rw-r--r--unittests.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/unittests.c b/unittests.c
index d9b14d3..4c3abf4 100644
--- a/unittests.c
+++ b/unittests.c
@@ -616,6 +616,19 @@ static int test_first_byte_only_finds_byte_inside_range(void)
}
+static int test_first_byte_does_not_find_in_range_outside_string(void)
+{
+ Dynstr *dynstr;
+ size_t offset;
+
+ dynstr = dynstr_new_from_cstring("123123");
+ offset = dynstr_first_byte(dynstr, 128, '3');
+ FAIL_UNLESS_EQUAL(offset, DYNSTR_NOT_FOUND);
+ dynstr_free(dynstr);
+ return true;
+}
+
+
static int test_last_byte_finds_byte(void)
{
Dynstr *dynstr;
@@ -681,6 +694,19 @@ static int test_last_byte_only_finds_byte_inside_range(void)
}
+static int test_last_byte_does_not_find_in_range_outside_string(void)
+{
+ Dynstr *dynstr;
+ size_t offset;
+
+ dynstr = dynstr_new_from_cstring("123123");
+ offset = dynstr_last_byte(dynstr, 128, '3');
+ FAIL_UNLESS_EQUAL(offset, DYNSTR_NOT_FOUND);
+ dynstr_free(dynstr);
+ return true;
+}
+
+
static int test_first_string_finds_pattern(void)
{
Dynstr *dynstr;
@@ -933,11 +959,13 @@ static const struct test tests[] = {
TEST(test_first_byte_does_not_find_nonexistent_byte),
TEST(test_first_byte_does_not_find_byte_outside_range),
TEST(test_first_byte_only_finds_byte_inside_range),
+ TEST(test_first_byte_does_not_find_in_range_outside_string),
TEST(test_last_byte_finds_byte),
TEST(test_last_byte_only_finds_last_byte),
TEST(test_last_byte_does_not_find_nonexistent_byte),
TEST(test_last_byte_does_not_find_byte_outside_range),
TEST(test_last_byte_only_finds_byte_inside_range),
+ TEST(test_last_byte_does_not_find_in_range_outside_string),
TEST(test_first_string_finds_pattern),
TEST(test_first_string_only_finds_first_pattern),
TEST(test_first_string_does_not_find_nonexistent_pattern),