[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [RFC/PATCH v3 4/8] libbb: add unit tests for is_prefixed_with()
From:       Denys Vlasenko <vda.linux () googlemail ! com>
Date:       2015-08-25 13:00:41
Message-ID: CAK1hOcOpu2vE9YBWjZGmam47PCNLA-ptX+yy_BGuTrtS=rWQZw () mail ! gmail ! com
[Download RAW message or body]

Applied, thanks!

On Tue, Aug 25, 2015 at 1:09 PM, Bartosz Golaszewski
<bartekgola@gmail.com> wrote:
> Test corner cases too like looking for an empty prefix etc.
>
> Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
> ---
>  libbb/compare_string_array.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
>
> diff --git a/libbb/compare_string_array.c b/libbb/compare_string_array.c
> index fe6d4a5..eb754af 100644
> --- a/libbb/compare_string_array.c
> +++ b/libbb/compare_string_array.c
> @@ -103,3 +103,22 @@ smallint FAST_FUNC yesno(const char *str)
>         return ret / 3;
>  }
>  #endif
> +
> +#if ENABLE_UNIT_TEST
> +
> +BBUNIT_DEFINE_TEST(is_prefixed_with)
> +{
> +       BBUNIT_ASSERT_STREQ(" bar", is_prefixed_with("foo bar", "foo"));
> +       BBUNIT_ASSERT_STREQ("bar", is_prefixed_with("foo bar", "foo "));
> +       BBUNIT_ASSERT_STREQ("", is_prefixed_with("foo", "foo"));
> +       BBUNIT_ASSERT_STREQ("foo", is_prefixed_with("foo", ""));
> +       BBUNIT_ASSERT_STREQ("", is_prefixed_with("", ""));
> +
> +       BBUNIT_ASSERT_NULL(is_prefixed_with("foo", "bar foo"));
> +       BBUNIT_ASSERT_NULL(is_prefixed_with("foo foo", "bar"));
> +       BBUNIT_ASSERT_NULL(is_prefixed_with("", "foo"));
> +
> +       BBUNIT_ENDTEST;
> +}
> +
> +#endif /* ENABLE_UNIT_TEST */
> --
> 2.1.4
>
> _______________________________________________
> busybox mailing list
> busybox@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic