forked from TartanLlama/optional
Start committing tests
This commit is contained in:
14
CMakeLists.txt
Normal file
14
CMakeLists.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
project(cmake_test)
|
||||
|
||||
# Prepare "Catch" library for other executables
|
||||
set(CATCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
add_library(Catch INTERFACE)
|
||||
target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR})
|
||||
|
||||
# Make test executable
|
||||
set(TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/tests/main.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tests/noexcept.cpp)
|
||||
add_executable(tests ${TEST_SOURCES})
|
||||
target_link_libraries(tests Catch)
|
2
tests/main.cpp
Normal file
2
tests/main.cpp
Normal file
@@ -0,0 +1,2 @@
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include "catch.hpp"
|
29
tests/noexcept.cpp
Normal file
29
tests/noexcept.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "optional.hpp"
|
||||
#include "catch.hpp"
|
||||
|
||||
TEST_CASE("Noexcept", "[noexcept]") {
|
||||
tl::optional<int> o1 {4};
|
||||
tl::optional<int> o2 {42};
|
||||
|
||||
SECTION ("comparison with nullopt") {
|
||||
REQUIRE(noexcept(o1 == tl::nullopt));
|
||||
REQUIRE(noexcept(tl::nullopt == o1));
|
||||
REQUIRE(noexcept(o1 != tl::nullopt));
|
||||
REQUIRE(noexcept(tl::nullopt != o1));
|
||||
REQUIRE(noexcept(o1 < tl::nullopt));
|
||||
REQUIRE(noexcept(tl::nullopt < o1));
|
||||
REQUIRE(noexcept(o1 <= tl::nullopt));
|
||||
REQUIRE(noexcept(tl::nullopt <= o1));
|
||||
REQUIRE(noexcept(o1 > tl::nullopt));
|
||||
REQUIRE(noexcept(tl::nullopt > o1));
|
||||
REQUIRE(noexcept(o1 >= tl::nullopt));
|
||||
REQUIRE(noexcept(tl::nullopt >= o1));
|
||||
}
|
||||
|
||||
SECTION ("swap") {
|
||||
REQUIRE(tl::detail::is_swappable<int>::value);
|
||||
//REQUIRE(noexcept(swap(o1,o2)) == noexcept(o1.swap(o2)));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user