1 /* 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright 2026 The FreeBSD Foundation 5 * 6 * Portions of this software were developed by Konstantin Belousov 7 * under sponsorship from the FreeBSD Foundation. 8 * 9 */ 10 11 #include <limits.h> 12 #include <atf-c.h> 13 14 static int 15 #include "parse_integer_func.c" 16 17 ATF_TC_WITHOUT_HEAD(integers); 18 ATF_TC_BODY(integers, tc) 19 { 20 ATF_REQUIRE_EQ(parse_integer("0"), 0); 21 ATF_REQUIRE_EQ(parse_integer("10"), 10); 22 ATF_REQUIRE_EQ(parse_integer("10001"), 10001); 23 ATF_REQUIRE_EQ(parse_integer("0b101"), 0b101); 24 ATF_REQUIRE_EQ(parse_integer("0x10"), 0x10); 25 ATF_REQUIRE_EQ(parse_integer("020"), 020); 26 ATF_REQUIRE_EQ(parse_integer("090"), -1); 27 /* This test assumes some value for INT_MAX */ 28 ATF_REQUIRE_EQ(parse_integer("1111111111111111111111111111"), -1); 29 } 30 31 ATF_TP_ADD_TCS(tp) 32 { 33 ATF_TP_ADD_TC(tp, integers); 34 return (atf_no_error()); 35 } 36