forked from mpaland/printf
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a test program, which produces random format strings and applie…
…s them to random values (of the appropriate type) - checking the results of this library against the standard C library's `sprintf()`. This is not intended to replace the existing tests nor even be run by default, but rather to allow developers/maintainers to more easily find corner-case discrepancies while working on the library.
- Loading branch information
Showing
3 changed files
with
697 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
cmake_minimum_required(VERSION 3.9) | ||
|
||
enable_language(CXX) | ||
|
||
add_executable(autotest "autotest.cpp") | ||
|
||
set_target_properties( | ||
autotest | ||
PROPERTIES | ||
CXX_STANDARD 11 | ||
CXX_STANDARD_REQUIRED YES | ||
CXX_EXTENSIONS NO | ||
) | ||
|
||
add_definitions(-DNO_OVERRIDE_STDIO) | ||
|
||
option(TEST_BROKEN_FORMATS "Include tests using non-standard-compliant format strings?" ON) | ||
# ... don't worry, we'll suppress the compiler warnings for those. | ||
if (TEST_BROKEN_FORMATS) | ||
target_compile_definitions(autotest PRIVATE TEST_WITH_NON_STANDARD_FORMAT_STRINGS) | ||
endif() | ||
|
||
target_link_libraries(autotest PRIVATE mpaland-printf) | ||
|
||
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") | ||
target_compile_options(autoteste PRIVATE /W4) | ||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR | ||
CMAKE_CXX_COMPILER_ID STREQUAL "Clang") | ||
# lots of warnings and all warnings as errors | ||
target_compile_options(autotest PRIVATE | ||
-g | ||
-Wall | ||
-Wextra | ||
-pedantic | ||
-Wundef | ||
-Wsign-conversion | ||
-Wuninitialized | ||
-Wshadow | ||
-Wunreachable-code | ||
-Wswitch-default | ||
-Wswitch | ||
-Wcast-align | ||
-Wmissing-include-dirs | ||
-Winit-self | ||
-Wdouble-promotion | ||
-gdwarf-2 | ||
-fno-exceptions | ||
-ffunction-sections | ||
-fdata-sections | ||
-fverbose-asm | ||
-Wunused-parameter | ||
) | ||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | ||
target_compile_options(autotest PRIVATE -ffat-lto-objects) | ||
endif() | ||
endif() | ||
|
||
add_test( | ||
NAME ${PROJECT_NAME}.autotest | ||
COMMAND autotest # ${TEST_RUNNER_PARAMS} | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.