mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-10 20:31:27 +01:00
include: Add tests for N2867.
Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D41735
This commit is contained in:
parent
e6615b1034
commit
4fbb9c43aa
@ -278,6 +278,8 @@
|
||||
..
|
||||
..
|
||||
..
|
||||
include
|
||||
..
|
||||
lib
|
||||
atf
|
||||
libatf-c
|
||||
|
@ -9,6 +9,7 @@ KYUAFILE= yes
|
||||
|
||||
SUBDIR+= etc
|
||||
SUBDIR+= examples
|
||||
SUBDIR+= include
|
||||
SUBDIR+= sys
|
||||
SUBDIR+= atf_python
|
||||
|
||||
|
7
tests/include/Makefile
Normal file
7
tests/include/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
.include <bsd.own.mk>
|
||||
|
||||
TESTSDIR= ${TESTSBASE}/include
|
||||
|
||||
ATF_TESTS_C+= stdckdint_test
|
||||
|
||||
.include <bsd.test.mk>
|
52
tests/include/stdckdint_test.c
Normal file
52
tests/include/stdckdint_test.c
Normal file
@ -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());
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user