From 973297dc45268efcd767a8833f44392133f736da Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Sun, 26 May 2019 16:02:23 +0100 Subject: [PATCH] test: improve test_mutt_str_skip_whitespace() --- test/string/mutt_str_skip_whitespace.c | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/string/mutt_str_skip_whitespace.c b/test/string/mutt_str_skip_whitespace.c index abe944fe9..4625922e1 100644 --- a/test/string/mutt_str_skip_whitespace.c +++ b/test/string/mutt_str_skip_whitespace.c @@ -25,6 +25,12 @@ #include "config.h" #include "mutt/mutt.h" +struct SkipTest +{ + const char *str; + size_t offset; +}; + void test_mutt_str_skip_whitespace(void) { // char *mutt_str_skip_whitespace(char *p); @@ -32,4 +38,30 @@ void test_mutt_str_skip_whitespace(void) { TEST_CHECK(mutt_str_skip_whitespace(NULL) == NULL); } + + // clang-format off + struct SkipTest skip_tests[] = + { + { "", 0 }, + { "apple", 0 }, + { " apple", 1 }, + { "\tapple", 1 }, + { "\rapple", 1 }, + { "\napple", 1 }, + + { "\t \t \napple", 5 }, + { "\t \t \n", 5 }, + }; + // clang-format on + + { + for (size_t i = 0; i < mutt_array_size(skip_tests); i++) + { + struct SkipTest *t = &skip_tests[i]; + TEST_CASE_("'%s'", t->str); + + const char *result = mutt_str_skip_whitespace(t->str); + TEST_CHECK(result == (t->str + t->offset)); + } + } } -- 2.40.0