Page MenuHomeFreeBSD

D41821.diff
No OneTemporary

D41821.diff

diff --git a/lib/libc/tests/string/strcspn_test.c b/lib/libc/tests/string/strcspn_test.c
--- a/lib/libc/tests/string/strcspn_test.c
+++ b/lib/libc/tests/string/strcspn_test.c
@@ -148,10 +148,74 @@
test_set_alignments(buf, 30, NOMATCH);
}
+#ifndef STRSPN
+/* test all positions in which set could match buf */
+static void
+test_match_positions(char *buf, char *set, size_t buflen, size_t setlen)
+{
+ size_t i, j, outcome;
+
+ memset(buf, '-', buflen);
+
+ for (i = 0; i < setlen; i++)
+ set[i] = 'A' + i;
+
+ buf[buflen] = '\0';
+ set[setlen] = '\0';
+
+ /*
+ * Check for (mis)match at buffer position i
+ * against set position j.
+ */
+ for (i = 0; i < buflen; i++) {
+ for (j = 0; j < setlen; j++) {
+ buf[i] = set[j];
+
+ outcome = strcspn(buf, set);
+ ATF_CHECK_EQ_MSG(i, outcome,
+ "strcspn(\"%s\", \"%s\") = %zu != %zu",
+ buf, set, outcome, i);
+ }
+
+ buf[i] = '-';
+ }
+}
+
+ATF_TC_WITHOUT_HEAD(match_positions);
+ATF_TC_BODY(match_positions, tc)
+{
+ char buf[129], set[65];
+
+ test_match_positions(buf, set, 128, 64);
+ test_match_positions(buf, set, 64, 64);
+ test_match_positions(buf, set, 32, 64);
+ test_match_positions(buf, set, 16, 64);
+ test_match_positions(buf, set, 8, 64);
+ test_match_positions(buf, set, 128, 32);
+ test_match_positions(buf, set, 64, 32);
+ test_match_positions(buf, set, 32, 32);
+ test_match_positions(buf, set, 16, 32);
+ test_match_positions(buf, set, 8, 32);
+ test_match_positions(buf, set, 128, 16);
+ test_match_positions(buf, set, 64, 16);
+ test_match_positions(buf, set, 32, 16);
+ test_match_positions(buf, set, 16, 16);
+ test_match_positions(buf, set, 8, 16);
+ test_match_positions(buf, set, 128, 8);
+ test_match_positions(buf, set, 64, 8);
+ test_match_positions(buf, set, 32, 8);
+ test_match_positions(buf, set, 16, 8);
+ test_match_positions(buf, set, 8, 8);
+}
+#endif /* !defined(STRSPN) */
+
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, buf_alignments);
ATF_TP_ADD_TC(tp, set_alignments);
+#ifndef STRSPN
+ ATF_TP_ADD_TC(tp, match_positions);
+#endif
return (atf_no_error());
}

File Metadata

Mime Type
text/plain
Expires
Thu, Feb 13, 1:30 AM (18 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16620431
Default Alt Text
D41821.diff (2 KB)

Event Timeline