Skip to content

Commit

Permalink
Move overflow tests to another executable
Browse files Browse the repository at this point in the history
This avoids ODR issues where different tests cause integer methods
to be instantiated differently.
  • Loading branch information
danakj committed Nov 29, 2023
1 parent 389f5ee commit 6b1d775
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
20 changes: 16 additions & 4 deletions sus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -299,14 +299,12 @@ if(${SUBSPACE_BUILD_TESTS})
"num/f64_unittest.cc"
"num/i8_unittest.cc"
"num/i16_unittest.cc"
"num/i32_overflow_unittest.cc"
"num/i32_unittest.cc"
"num/i64_unittest.cc"
"num/isize_unittest.cc"
"num/overflow_integer_unittest.cc"
"num/u8_unittest.cc"
"num/u16_unittest.cc"
"num/u32_overflow_unittest.cc"
"num/u32_unittest.cc"
"num/u64_unittest.cc"
"num/uptr_unittest.cc"
Expand All @@ -328,18 +326,32 @@ if(${SUBSPACE_BUILD_TESTS})
"tuple/tuple_unittest.cc"
)

add_executable(subspace_overflow_unittests
"num/i32_overflow_unittest.cc"
"num/u32_overflow_unittest.cc"
)

# Subspace test support
subspace_test_default_compile_options(subspace_test_support)
target_link_libraries(subspace_test_support subspace::lib)

# Subspace unittests
subspace_test_default_compile_options(subspace_unittests)
target_link_libraries(subspace_unittests
target_link_libraries(subspace_unittests
subspace::lib
subspace::test_support
gtest_main
)

gtest_discover_tests(subspace_unittests)

# Subspace overflow unittests
subspace_test_default_compile_options(subspace_overflow_unittests)
target_compile_options(subspace_overflow_unittests PUBLIC -DSUS_CHECK_INTEGER_OVERFLOW=false)
target_link_libraries(subspace_overflow_unittests
subspace::lib
subspace::test_support
gtest_main
)
gtest_discover_tests(subspace_overflow_unittests)
endif()

2 changes: 0 additions & 2 deletions sus/num/i32_overflow_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#define SUS_CHECK_INTEGER_OVERFLOW false

#include "googletest/include/gtest/gtest.h"
#include "sus/prelude.h"
#include "sus/test/ensure_use.h"
Expand Down
2 changes: 0 additions & 2 deletions sus/num/u32_overflow_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#define SUS_CHECK_INTEGER_OVERFLOW false

#include "googletest/include/gtest/gtest.h"
#include "sus/prelude.h"
#include "sus/test/ensure_use.h"
Expand Down

0 comments on commit 6b1d775

Please sign in to comment.