From 59d04d737ac4445ba96c9c117dcf8d95654719a3 Mon Sep 17 00:00:00 2001 From: Jessica Date: Wed, 3 Nov 2021 18:45:00 -0500 Subject: [PATCH] Update fmt and googletest submodules, fix various compilation issues --- src/common/config.cpp | 4 ++-- src/external/fmt | 2 +- src/include/io/color.hpp | 2 +- src/include/io/message.hpp | 4 ++-- src/test/CMakeLists.txt | 3 ++- src/test/googletest | 2 +- src/test/io/color.cpp | 2 +- src/test/parser.cpp | 4 ++-- src/test/parsers/json.cpp | 10 ++++++++-- src/test/timer.cpp | 2 +- 10 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/common/config.cpp b/src/common/config.cpp index 85accfa..4168667 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -32,7 +32,7 @@ config::file_error::file_error() } config::file_error::file_error(const std::filesystem::path& in_filename) - : std::runtime_error{ "Error openening file \"" + std::string{ in_filename } + "\". Error: " + std::strerror(errno) } { + : std::runtime_error{ "Error opening file \"" + in_filename.string() + "\". Error: " + std::strerror(errno) } { // Empty ctor body }; @@ -136,7 +136,7 @@ std::string config::get_format(const std::filesystem::path& in_filename, const s } // Try to determine format from filename - std::string extension = in_filename.extension(); + std::string extension = in_filename.extension().string(); if jessilib_assert(!extension.empty()) { return extension.substr(1); } diff --git a/src/external/fmt b/src/external/fmt index 0476a51..812733c 160000 --- a/src/external/fmt +++ b/src/external/fmt @@ -1 +1 @@ -Subproject commit 0476a51cba8dca9591f022856e2ff51c4d3f36b0 +Subproject commit 812733cc963b2e1d96f6ad2cb2d441c6fe8e4a5b diff --git a/src/include/io/color.hpp b/src/include/io/color.hpp index fb0bc2b..0a24097 100644 --- a/src/include/io/color.hpp +++ b/src/include/io/color.hpp @@ -70,7 +70,7 @@ public: return m_value; } - constexpr double distance(const color& in_color) const { + double distance(const color& in_color) const { return std::sqrt(distance_sq(in_color)); } diff --git a/src/include/io/message.hpp b/src/include/io/message.hpp index b9662de..0e6cb2a 100644 --- a/src/include/io/message.hpp +++ b/src/include/io/message.hpp @@ -214,11 +214,11 @@ std::string process_message(const jessilib::io::formatted_message& msg) { // Populate args for (auto& text : msg.get_message()) { - args.emplace_back(fmt::internal::make_arg(wrap_text(text))); + args.emplace_back(fmt::detail::make_arg(wrap_text(text))); } // Pass args into vformat - fmt::format_args text_args{ args.data(), args.size() }; + fmt::format_args text_args{ args.data(), static_cast(args.size()) }; return fmt::vformat(msg.format(), text_args); } diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index e19ee1e..90a8ff2 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -3,7 +3,8 @@ set(SOURCE_FILES timer.cpp thread_pool.cpp util.cpp object.cpp parser.cpp config.cpp parsers/json.cpp unicode.cpp app_parameters.cpp io/color.cpp duration.cpp) # Setup gtest -add_subdirectory(googletest/googletest) +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +add_subdirectory(googletest) #include_directories(googletest/googletest) #include_directories(googletest/googlemock) diff --git a/src/test/googletest b/src/test/googletest index d175c8b..bf0701d 160000 --- a/src/test/googletest +++ b/src/test/googletest @@ -1 +1 @@ -Subproject commit d175c8bf823e709d570772b038757fadf63bc632 +Subproject commit bf0701daa9f5b30e5882e2f8f9a5280bcba87e77 diff --git a/src/test/io/color.cpp b/src/test/io/color.cpp index fe5ec80..348dbf6 100644 --- a/src/test/io/color.cpp +++ b/src/test/io/color.cpp @@ -74,7 +74,7 @@ TEST(ColorTest, copy) { color color_rgb{ 0x12, 0x34, 0x56 }; EXPECT_EQ(color_value, color_rgb); - EXPECT_EQ(color_value.value(), g_constexpr_color); + EXPECT_EQ(color_value.value(), g_constexpr_color.value()); EXPECT_EQ(color_value.red(), 0x12); EXPECT_EQ(color_value.green(), 0x34); EXPECT_EQ(color_value.blue(), 0x56); diff --git a/src/test/parser.cpp b/src/test/parser.cpp index c1a22a6..3a3c48a 100644 --- a/src/test/parser.cpp +++ b/src/test/parser.cpp @@ -50,7 +50,7 @@ public: return in_object.get(); } - return DEFAULT_SERIALIZE_RESULT; + return static_cast(DEFAULT_SERIALIZE_RESULT); } static object deserialize_default(std::string_view in_data) { @@ -58,7 +58,7 @@ public: } /** static members */ - static constexpr const char DEFAULT_SERIALIZE_RESULT[]{ "serialize_result" }; + static constexpr std::string_view DEFAULT_SERIALIZE_RESULT = "serialize_result"sv; static std::function serialize_impl; static std::function deserialize_impl; }; diff --git a/src/test/parsers/json.cpp b/src/test/parsers/json.cpp index 9cd4cfd..e954551 100644 --- a/src/test/parsers/json.cpp +++ b/src/test/parsers/json.cpp @@ -47,12 +47,18 @@ TEST(JsonParser, serialize_decimal) { EXPECT_DOUBLE_EQ(std::atof(parser.serialize(1234.0).c_str()), 1234.0); } +// necessary due to some sort of bug with EXPECT_EQ on MSVC +template +void expect_eq(LeftT in_left, RightT in_right) { + EXPECT_EQ(in_left, in_right); +} + TEST(JsonParser, serialize_string) { json_parser parser; EXPECT_EQ(parser.serialize("text"), R"json("text")json"); - EXPECT_EQ(parser.serialize("\"text\""), R"json("\"text\"")json"); - EXPECT_EQ(parser.serialize("\"te\x10xt\""), R"json("\"te\u0010xt\"")json"); + expect_eq(parser.serialize("\"text\""), R"json("\"text\"")json"); + expect_eq(parser.serialize("\"te\x10xt\""), R"json("\"te\u0010xt\"")json"); } TEST(JsonParser, serialize_array) { diff --git a/src/test/timer.cpp b/src/test/timer.cpp index 9069c11..1e47837 100644 --- a/src/test/timer.cpp +++ b/src/test/timer.cpp @@ -169,7 +169,7 @@ TEST(TimerTest, simultaneousTimers) { }}; // Wait for some timers to fire - std::this_thread::sleep_for(period * 3); + std::this_thread::sleep_for(period + 100ms); EXPECT_GE(timers_running, 2); // Notify timers to close