Skip to content

Commit bf9bd30

Browse files
committed
Add the supplemental tests
1 parent 757f3ae commit bf9bd30

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

Makefile

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: test example
1+
.PHONY: test example fetch-supplemental-data
22

33
# Detect linux and define _DEFAULT_SOURCE if so
44
UNAME_S := $(shell uname -s)
@@ -7,18 +7,39 @@ ifeq ($(UNAME_S),Linux)
77
endif
88

99
CLANG_FLAGS := -xc -Wall -Wextra -Wpedantic -O3 -g -std=c99 $(EXTRA_CFLAGS)
10+
SUPPLEMENTAL_TEST_FILES_DIR := out/supplemental_test_files
11+
SUPPLEMENTAL_TEST_DATA_DIR := $(SUPPLEMENTAL_TEST_FILES_DIR)/data
12+
SUPPLEMENTAL_TEST_FILES_REPO := https://github.com/fastfloat/supplemental_test_files.git
1013

1114
out/test_runner: ffc.h test_src/test.c | out
1215
gcc -xc -Wall -Wextra -Wpedantic ffc.h -fsyntax-only
1316
clang $(CLANG_FLAGS) -I. -Itest_src test_src/test.c -o out/test_runner -lm
1417

15-
test: out/test_runner out/test_int_runner
18+
test: out/test_runner out/test_int_runner out/supplemental_tests out/supplemental_tests_src
1619
./out/test_runner
1720
./out/test_int_runner
21+
./out/supplemental_tests
22+
./out/supplemental_tests_src
1823

1924
out/test_int_runner: ffc.h test_src/test_int.c | out
2025
clang $(CLANG_FLAGS) -I. -Itest_src test_src/test_int.c -o out/test_int_runner -lm
2126

27+
$(SUPPLEMENTAL_TEST_DATA_DIR):
28+
@test -d "$(SUPPLEMENTAL_TEST_DATA_DIR)" || { \
29+
echo "Missing supplemental test data at $(SUPPLEMENTAL_TEST_DATA_DIR)." >&2; \
30+
echo "Run 'make fetch-supplemental-data' first." >&2; \
31+
exit 1; \
32+
}
33+
34+
out/supplemental_tests: ffc.h test_src/supplemental_tests.c $(SUPPLEMENTAL_TEST_DATA_DIR) | out
35+
clang $(CLANG_FLAGS) -I. -Itest_src -DSUPPLEMENTAL_TEST_DATA_DIR=\"$(SUPPLEMENTAL_TEST_DATA_DIR)\" test_src/supplemental_tests.c -o out/supplemental_tests -lm
36+
37+
out/supplemental_tests_src: src/ffc.h test_src/supplemental_tests.c $(SUPPLEMENTAL_TEST_DATA_DIR) | out
38+
clang $(CLANG_FLAGS) -Isrc -Itest_src -DSUPPLEMENTAL_TEST_DATA_DIR=\"$(SUPPLEMENTAL_TEST_DATA_DIR)\" test_src/supplemental_tests.c -o out/supplemental_tests_src -lm
39+
40+
fetch-supplemental-data: | out
41+
git clone --depth 1 $(SUPPLEMENTAL_TEST_FILES_REPO) $(SUPPLEMENTAL_TEST_FILES_DIR)
42+
2243
ffc.h: src/ffc.h src/common.h src/parse.h src/digit_comparison.h src/api.h src/bigint.h amalgamate.py
2344
python3 amalgamate.py > ffc.h
2445

readme.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ make test
7070
make example
7171
```
7272

73+
`make test` builds and runs the base tests plus supplemental tests.
74+
Run `make fetch-supplemental-data` once first to clone `supplemental_test_files`
75+
into `out/`.
76+
7377
### With CMake
7478

7579
ffc.h supports building with CMake as an installable single-header library.
@@ -169,4 +173,4 @@ ffc : 1019.67 MB/s (+/- 7.3 %) 138.91 Mfl
169173
51 (8), 2021.
170174
* Noble Mushtak, Daniel Lemire, [Fast Number Parsing Without
171175
Fallback](https://arxiv.org/abs/2212.06644), Software: Practice and Experience
172-
53 (7), 2023.
176+
53 (7), 2023.

test_src/supplemental_tests.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#define FFC_IMPL
12
#include "ffc.h"
23
#include <stdio.h>
34
#include <stdlib.h>
@@ -161,4 +162,4 @@ int main(void) {
161162
closedir(dir);
162163
#endif
163164
return all_passed ? EXIT_SUCCESS : EXIT_FAILURE;
164-
}
165+
}

0 commit comments

Comments
 (0)