-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
81 lines (71 loc) · 2.97 KB
/
CMakeLists.txt
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
##
## Copyright (C) 2018-2019 Alex Thiessen <[email protected]>
##
## This file is part of Numbers.
##
## Numbers is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 2 of the License, or
## (at your option) any later version.
##
## Numbers is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Numbers. If not, see <http://www.gnu.org/licenses/>.
##
## SPDX-License-Identifier: GPL-2.0-or-later
## <https://spdx.org/licenses/GPL-2.0-or-later.html>
##
cmake_minimum_required(VERSION 3.1)
project(numbers)
find_package(FLEX)
flex_target(Numbers_impl numbers.l ${CMAKE_CURRENT_BINARY_DIR}/numbers.c)
# numbers.h is here
include_directories(${CMAKE_SOURCE_DIR})
add_executable(numbers
COPYING
${FLEX_Numbers_impl_OUTPUTS}
main.c
numbers.h
)
enable_testing()
macro(numbers_test name input expected_regex)
add_test(NAME "${name}-${input}" COMMAND ./numbers "${input}")
set_tests_properties("${name}-${input}" PROPERTIES PASS_REGULAR_EXPRESSION "^${expected_regex}\n$")
endmacro(numbers_test)
# simple positive tests
numbers_test(bin-positive b1001 "9 pos")
numbers_test(bin-positive b_1001 "9 pos")
numbers_test(bin-positive +b_1001 "9 pos")
numbers_test(bin-positive -b_1001 "9 neg")
numbers_test(oct-positive 011 "9 pos")
numbers_test(oct-positive 0_11 "9 pos")
numbers_test(dec-positive 0 "0 zero")
numbers_test(dec-positive -0 "0 zero")
numbers_test(dec-positive +0 "0 zero")
numbers_test(dec-positive 0000 "0 zero")
numbers_test(dec-positive 0___ "0 zero")
numbers_test(dec-positive 9 "9 pos")
numbers_test(dec-positive 9_9 "99 pos")
numbers_test(hex-positive 0xa "10 pos")
numbers_test(hex-positive 0x_a_ "10 pos")
numbers_test(bin-positive b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 "18446744073709551615 pos")
numbers_test(oct-positive 01_777_777_777_777_777_777_777 "18446744073709551615 pos")
numbers_test(dec-positive 18446744073709551615 "18446744073709551615 pos")
numbers_test(hex-positive 0xFFFF_FFFF_FFFF_FFFF "18446744073709551615 pos")
numbers_test(bin-negative b2 bad)
numbers_test(oct-negative 09 bad)
numbers_test(dec-negative A bad)
numbers_test(hex-negative 0xG bad)
numbers_test(bin-negative b bad)
numbers_test(dec-negative +-1 bad)
numbers_test(hex-negative 0x bad)
numbers_test(hex-negative 0x__ bad)
numbers_test(hex-negative _0xA bad)
numbers_test(bin-negative b1_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 bad)
numbers_test(oct-negative 02_777_777_777_777_777_777_777 bad)
numbers_test(dec-negative 18446744073709551616 bad)
numbers_test(hex-negative 0x1_FFFF_FFFF_FFFF_FFFF bad)