Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107090370
D41735.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D41735.diff
View Options
diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist
--- a/etc/mtree/BSD.tests.dist
+++ b/etc/mtree/BSD.tests.dist
@@ -278,6 +278,8 @@
..
..
..
+ include
+ ..
lib
atf
libatf-c
diff --git a/tests/Makefile b/tests/Makefile
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -9,6 +9,7 @@
SUBDIR+= etc
SUBDIR+= examples
+SUBDIR+= include
SUBDIR+= sys
SUBDIR+= atf_python
diff --git a/tests/include/Makefile b/tests/include/Makefile
new file mode 100644
--- /dev/null
+++ b/tests/include/Makefile
@@ -0,0 +1,7 @@
+.include <bsd.own.mk>
+
+TESTSDIR= ${TESTSBASE}/include
+
+ATF_TESTS_C+= stdckdint_test
+
+.include <bsd.test.mk>
diff --git a/tests/include/stdckdint_test.c b/tests/include/stdckdint_test.c
new file mode 100644
--- /dev/null
+++ b/tests/include/stdckdint_test.c
@@ -0,0 +1,52 @@
+/*-
+ * Copyright (c) 2023 Dag-Erling Smørgrav
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <limits.h>
+#include <stdckdint.h>
+
+#include <atf-c.h>
+
+ATF_TC_WITHOUT_HEAD(ckd_add);
+ATF_TC_BODY(ckd_add, tc)
+{
+ int result;
+
+ ATF_CHECK(!ckd_add(&result, INT_MAX, 0));
+ ATF_CHECK_EQ(INT_MAX, result);
+ ATF_CHECK(ckd_add(&result, INT_MAX, 1));
+ ATF_CHECK_EQ(INT_MIN, result);
+}
+
+ATF_TC_WITHOUT_HEAD(ckd_sub);
+ATF_TC_BODY(ckd_sub, tc)
+{
+ int result;
+
+ ATF_CHECK(!ckd_sub(&result, INT_MIN, 0));
+ ATF_CHECK_EQ(INT_MIN, result);
+ ATF_CHECK(ckd_sub(&result, INT_MIN, 1));
+ ATF_CHECK_EQ(INT_MAX, result);
+}
+
+ATF_TC_WITHOUT_HEAD(ckd_mul);
+ATF_TC_BODY(ckd_mul, tc)
+{
+ int result;
+
+ ATF_CHECK(!ckd_mul(&result, INT_MAX / 2, 2));
+ ATF_CHECK_EQ(INT_MAX - 1, result);
+ ATF_CHECK(ckd_mul(&result, INT_MAX / 2 + 1, 2));
+ ATF_CHECK_EQ(INT_MIN, result);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, ckd_add);
+ ATF_TP_ADD_TC(tp, ckd_sub);
+ ATF_TP_ADD_TC(tp, ckd_mul);
+ return (atf_no_error());
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 10, 11:14 PM (16 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15747697
Default Alt Text
D41735.diff (1 KB)
Attached To
Mode
D41735: include: Add tests for N2867.
Attached
Detach File
Event Timeline
Log In to Comment