Skip to content

Commit

Permalink
Fix example and test compiled warnings and error in MSVC.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwankyun committed Apr 22, 2024
1 parent c39022e commit 48d8e30
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@
add_executable(example example.cpp)
target_link_libraries(example cxxopts)

set_property(TARGET example PROPERTY CXX_STANDARD 17)
target_compile_features(example PRIVATE cxx_std_17)
target_compile_options(example PRIVATE
"$<$<CXX_COMPILER_ID:MSVC>:/utf-8;>")
2 changes: 2 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

add_executable(options_test main.cpp options.cpp)
target_link_libraries(options_test cxxopts)
target_compile_features(options_test PRIVATE cxx_std_17)
add_test(options options_test)

# test if the targets are findable from the build directory
Expand Down Expand Up @@ -51,6 +52,7 @@ add_test(add-subdirectory-test ${CMAKE_CTEST_COMMAND}

add_executable(link_test link_a.cpp link_b.cpp)
target_link_libraries(link_test cxxopts)
target_compile_features(link_test PRIVATE cxx_std_17)

if(("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") AND ("${CMAKE_SYSTEM}" MATCHES "Linux"))
add_executable(fuzzer fuzz.cpp)
Expand Down
6 changes: 3 additions & 3 deletions test/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -848,11 +848,11 @@ TEST_CASE("Optional value", "[optional]")

CHECK(result.as_optional<int>("int"));
CHECK(result.as_optional<float>("float"));
CHECK(result.as_optional<string>("string"));
CHECK(result.as_optional<std::string>("string"));

CHECK(*result.as_optional<int>("int") == 42);
CHECK(*result.as_optional<float>("float") == 3.141);
CHECK(*result.as_optional<string>("string") == "Hello");
CHECK(*result.as_optional<std::string>("string") == "Hello");
}

SECTION("Unavailable") {
Expand All @@ -866,7 +866,7 @@ TEST_CASE("Optional value", "[optional]")

CHECK(!result.as_optional<int>("int"));
CHECK(!result.as_optional<float>("float"));
CHECK(!result.as_optional<string>("string"));
CHECK(!result.as_optional<std::string>("string"));
}

}
Expand Down

0 comments on commit 48d8e30

Please sign in to comment.