From 59656709c0c58fcd0ed18b38e02938dbe05284c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AC=8A=E5=B0=91?= Date: Sat, 27 Apr 2024 10:11:52 +0800 Subject: [PATCH] Fix example and test compiled warnings and error in MSVC. (#428) * Fix example and test compiled warnings and error in MSVC. --- src/CMakeLists.txt | 4 +++- test/options.cpp | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3b222e4..2894e13 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 + "$<$:/utf-8;>") diff --git a/test/options.cpp b/test/options.cpp index bb90f82..647934c 100644 --- a/test/options.cpp +++ b/test/options.cpp @@ -848,11 +848,11 @@ TEST_CASE("Optional value", "[optional]") CHECK(result.as_optional("int")); CHECK(result.as_optional("float")); - CHECK(result.as_optional("string")); + CHECK(result.as_optional("string")); CHECK(*result.as_optional("int") == 42); CHECK(*result.as_optional("float") == 3.141); - CHECK(*result.as_optional("string") == "Hello"); + CHECK(*result.as_optional("string") == "Hello"); } SECTION("Unavailable") { @@ -866,7 +866,7 @@ TEST_CASE("Optional value", "[optional]") CHECK(!result.as_optional("int")); CHECK(!result.as_optional("float")); - CHECK(!result.as_optional("string")); + CHECK(!result.as_optional("string")); } }