diff options
author | Bartosz Golaszewski <bartekgola@gmail.com> | 2015-08-25 13:09:59 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-08-25 15:00:24 +0200 |
commit | b432923e29dcd8c6f3a528bb9d61952de68e790c (patch) | |
tree | 9c7127016e93c26ccb1587fbdbbc184ed2174715 | |
parent | d86271732828117d32270e9f7b3d128d77e9fa57 (diff) | |
download | busybox-w32-b432923e29dcd8c6f3a528bb9d61952de68e790c.tar.gz busybox-w32-b432923e29dcd8c6f3a528bb9d61952de68e790c.tar.bz2 busybox-w32-b432923e29dcd8c6f3a528bb9d61952de68e790c.zip |
libbb: add unit tests for is_prefixed_with()
Test corner cases too like looking for an empty prefix etc.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | libbb/compare_string_array.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libbb/compare_string_array.c b/libbb/compare_string_array.c index e24815a03..450916c3a 100644 --- a/libbb/compare_string_array.c +++ b/libbb/compare_string_array.c | |||
@@ -110,3 +110,22 @@ smallint FAST_FUNC yesno(const char *str) | |||
110 | return ret / 3; | 110 | return ret / 3; |
111 | } | 111 | } |
112 | #endif | 112 | #endif |
113 | |||
114 | #if ENABLE_UNIT_TEST | ||
115 | |||
116 | BBUNIT_DEFINE_TEST(is_prefixed_with) | ||
117 | { | ||
118 | BBUNIT_ASSERT_STREQ(" bar", is_prefixed_with("foo bar", "foo")); | ||
119 | BBUNIT_ASSERT_STREQ("bar", is_prefixed_with("foo bar", "foo ")); | ||
120 | BBUNIT_ASSERT_STREQ("", is_prefixed_with("foo", "foo")); | ||
121 | BBUNIT_ASSERT_STREQ("foo", is_prefixed_with("foo", "")); | ||
122 | BBUNIT_ASSERT_STREQ("", is_prefixed_with("", "")); | ||
123 | |||
124 | BBUNIT_ASSERT_NULL(is_prefixed_with("foo", "bar foo")); | ||
125 | BBUNIT_ASSERT_NULL(is_prefixed_with("foo foo", "bar")); | ||
126 | BBUNIT_ASSERT_NULL(is_prefixed_with("", "foo")); | ||
127 | |||
128 | BBUNIT_ENDTEST; | ||
129 | } | ||
130 | |||
131 | #endif /* ENABLE_UNIT_TEST */ | ||