From: djm Date: Fri, 21 May 2021 03:59:01 +0000 (+0000) Subject: also check contents of remaining string X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=9d6f8b7e25c5db34983ad4464311eea9cd550244;p=openbsd also check contents of remaining string --- diff --git a/regress/usr.bin/ssh/unittests/misc/test_strdelim.c b/regress/usr.bin/ssh/unittests/misc/test_strdelim.c index e5026d8637d..0a791e753d2 100644 --- a/regress/usr.bin/ssh/unittests/misc/test_strdelim.c +++ b/regress/usr.bin/ssh/unittests/misc/test_strdelim.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test_strdelim.c,v 1.1 2021/05/21 03:48:07 djm Exp $ */ +/* $OpenBSD: test_strdelim.c,v 1.2 2021/05/21 03:59:01 djm Exp $ */ /* * Regress test for misc strdelim() and co * @@ -31,7 +31,9 @@ test_strdelim(void) TEST_START("empty"); START_STRING(""); cp = strdelim(&str); - ASSERT_STRING_EQ(cp, ""); /* XXX better as NULL */ + ASSERT_STRING_EQ(cp, ""); /* XXX arguable */ + cp = strdelim(&str); + ASSERT_PTR_EQ(cp, NULL); DONE_STRING(); TEST_DONE(); @@ -39,6 +41,7 @@ test_strdelim(void) START_STRING(" "); cp = strdelim(&str); ASSERT_STRING_EQ(cp, ""); /* XXX better as NULL */ + ASSERT_STRING_EQ(str, ""); DONE_STRING(); TEST_DONE(); @@ -48,6 +51,7 @@ test_strdelim(void) ASSERT_STRING_EQ(cp, "blob"); cp = strdelim(&str); ASSERT_PTR_EQ(cp, NULL); + ASSERT_PTR_EQ(str, NULL); DONE_STRING(); TEST_DONE(); @@ -55,8 +59,10 @@ test_strdelim(void) START_STRING("blob "); cp = strdelim(&str); ASSERT_STRING_EQ(cp, "blob"); + ASSERT_STRING_EQ(str, ""); cp = strdelim(&str); ASSERT_STRING_EQ(cp, ""); /* XXX better as NULL */ + ASSERT_PTR_EQ(str, NULL); DONE_STRING(); TEST_DONE(); @@ -64,8 +70,10 @@ test_strdelim(void) START_STRING("blob1 blob2"); cp = strdelim(&str); ASSERT_STRING_EQ(cp, "blob1"); + ASSERT_STRING_EQ(str, "blob2"); cp = strdelim(&str); ASSERT_STRING_EQ(cp, "blob2"); + ASSERT_PTR_EQ(str, NULL); cp = strdelim(&str); ASSERT_PTR_EQ(cp, NULL); DONE_STRING(); @@ -75,10 +83,12 @@ test_strdelim(void) START_STRING("blob1 blob2 "); cp = strdelim(&str); ASSERT_STRING_EQ(cp, "blob1"); + ASSERT_STRING_EQ(str, "blob2 "); cp = strdelim(&str); ASSERT_STRING_EQ(cp, "blob2"); cp = strdelim(&str); ASSERT_STRING_EQ(cp, ""); /* XXX better as NULL */ + ASSERT_PTR_EQ(str, NULL); DONE_STRING(); TEST_DONE(); @@ -86,8 +96,10 @@ test_strdelim(void) START_STRING("blob1=blob2"); cp = strdelim(&str); ASSERT_STRING_EQ(cp, "blob1"); + ASSERT_STRING_EQ(str, "blob2"); cp = strdelim(&str); ASSERT_STRING_EQ(cp, "blob2"); + ASSERT_PTR_EQ(str, NULL); cp = strdelim(&str); ASSERT_PTR_EQ(cp, NULL); DONE_STRING(); @@ -97,8 +109,13 @@ test_strdelim(void) START_STRING("blob1==blob2"); cp = strdelim(&str); ASSERT_STRING_EQ(cp, "blob1"); /* XXX better returning NULL early */ + ASSERT_STRING_EQ(str, "=blob2"); cp = strdelim(&str); ASSERT_STRING_EQ(cp, ""); + ASSERT_STRING_EQ(str, "blob2"); + cp = strdelim(&str); + ASSERT_STRING_EQ(cp, "blob2"); /* XXX should (but can't) reject */ + ASSERT_PTR_EQ(str, NULL); DONE_STRING(); TEST_DONE(); @@ -106,6 +123,7 @@ test_strdelim(void) START_STRING("blob1=blob2"); cp = strdelimw(&str); ASSERT_STRING_EQ(cp, "blob1=blob2"); + ASSERT_PTR_EQ(str, NULL); cp = strdelimw(&str); ASSERT_PTR_EQ(cp, NULL); DONE_STRING(); @@ -117,6 +135,7 @@ test_strdelim(void) ASSERT_STRING_EQ(cp, "blob"); cp = strdelim(&str); ASSERT_STRING_EQ(cp, ""); /* XXX better as NULL */ + ASSERT_PTR_EQ(str, NULL); DONE_STRING(); TEST_DONE(); @@ -124,8 +143,10 @@ test_strdelim(void) START_STRING("\"blob1\" blob2"); cp = strdelim(&str); ASSERT_STRING_EQ(cp, "blob1"); + ASSERT_STRING_EQ(str, "blob2"); cp = strdelim(&str); ASSERT_STRING_EQ(cp, "blob2"); + ASSERT_PTR_EQ(str, NULL); cp = strdelim(&str); ASSERT_PTR_EQ(cp, NULL); DONE_STRING(); @@ -135,10 +156,13 @@ test_strdelim(void) START_STRING("blob1 \"blob2\""); cp = strdelim(&str); ASSERT_STRING_EQ(cp, "blob1"); + ASSERT_STRING_EQ(str, "\"blob2\""); cp = strdelim(&str); ASSERT_STRING_EQ(cp, "blob2"); + ASSERT_STRING_EQ(str, ""); cp = strdelim(&str); ASSERT_STRING_EQ(cp, ""); /* XXX better as NULL */ + ASSERT_PTR_EQ(str, NULL); DONE_STRING(); TEST_DONE();