summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2021-05-21 03:59:02 +0000
committerDamien Miller <djm@cvs.openbsd.org>2021-05-21 03:59:02 +0000
commit8cc8bbf41a95289748f45394101c84eb75f316c9 (patch)
tree818d1603e0f88fb8fa28b9cdaa5b6ff447b3ba1d /regress
parentca9ba2d43e0c41a2acb318e9175cb278a3a2cd6a (diff)
also check contents of remaining string
Diffstat (limited to 'regress')
-rw-r--r--regress/usr.bin/ssh/unittests/misc/test_strdelim.c28
1 files changed, 26 insertions, 2 deletions
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();