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