File tree Expand file tree Collapse file tree 4 files changed +32
-2
lines changed Expand file tree Collapse file tree 4 files changed +32
-2
lines changed Original file line number Diff line number Diff line change 11# Function for defining a test with proper args
22function (utl_add_test file_name)
3+ cmake_parse_arguments (PARSE_ARGV 0 ARG "" "" "ADDITIONAL_CPP" ) # optional named argument
4+
35 string (REPLACE "/" "-" target_name "${file_name} " ) # CMake doesn't like target names with slashes
46 string (PREPEND target_name "test-" ) # so we don't intersect names with benchmarks & examples
57
6- add_executable (${target_name} ${file_name} .cpp)
8+ add_executable (${target_name} ${file_name} .cpp ${ARG_ADDITIONAL_CPP} )
79
810 target_compile_features (${target_name} PRIVATE ${UTL_COMPILE_FEATURES} )
911 target_compile_options (${target_name} PRIVATE ${UTL_TEST_FLAGS} )
@@ -24,7 +26,7 @@ endfunction()
2426# Note 2: '--force-colors' makes doctest show colored output in the terminal, but makes up CTest logs save ANSI
2527# color codes. Without this flag doctest suppresses color because it detects CTest writing output to the file.
2628
27- # Tests
29+ # Module tests
2830utl_add_test("module_assertion/assertions" )
2931utl_add_test("module_bit/enum_bitflags" )
3032utl_add_test("module_bit/group_bit_operations" )
@@ -70,3 +72,5 @@ utl_add_test("module_struct_reflect/perfect_forwarding")
7072utl_add_test("module_struct_reflect/reflection" )
7173utl_add_test("module_table/formats" )
7274utl_add_test("module_time/unit_split" )
75+ # General tests
76+ utl_add_test("general_odr/main" ADDITIONAL_CPP "general_odr/second.cpp" )
Original file line number Diff line number Diff line change 1+ // __________________________________ CONTENTS ___________________________________
2+ //
3+ // Compile-time test that checks the library for ODR violations,
4+ // should any of the headers miss an 'inline' this will not build
5+ // due to including the same thing in multiple translation units.
6+ // _______________________________________________________________________________
7+
8+ #include " second.hpp"
9+
10+ int main () {
11+ print_hello ();
12+ }
Original file line number Diff line number Diff line change 1+ #include " second.hpp"
2+
3+ void print_hello () { utl::log::println (" Hello (second)" ); }
Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ #include " single_include/UTL.hpp"
4+ // this will be included in both translation units, should
5+ // there be any ODR violations the compiler will complain
6+ //
7+ // we include the automatically amalgamated header so we don't have
8+ // to update this test every time there is a new module, this also
9+ // has a benefit of testing the amalgamated include in general
10+
11+ void print_hello ();
You can’t perform that action at this time.
0 commit comments