Browse Source

Update fmt and googletest submodules, fix various compilation issues

master
Jessica James 3 years ago
parent
commit
59d04d737a
  1. 4
      src/common/config.cpp
  2. 2
      src/external/fmt
  3. 2
      src/include/io/color.hpp
  4. 4
      src/include/io/message.hpp
  5. 3
      src/test/CMakeLists.txt
  6. 2
      src/test/googletest
  7. 2
      src/test/io/color.cpp
  8. 4
      src/test/parser.cpp
  9. 10
      src/test/parsers/json.cpp
  10. 2
      src/test/timer.cpp

4
src/common/config.cpp

@ -32,7 +32,7 @@ config::file_error::file_error()
} }
config::file_error::file_error(const std::filesystem::path& in_filename) 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 // 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 // Try to determine format from filename
std::string extension = in_filename.extension(); std::string extension = in_filename.extension().string();
if jessilib_assert(!extension.empty()) { if jessilib_assert(!extension.empty()) {
return extension.substr(1); return extension.substr(1);
} }

2
src/external/fmt

@ -1 +1 @@
Subproject commit 0476a51cba8dca9591f022856e2ff51c4d3f36b0 Subproject commit 812733cc963b2e1d96f6ad2cb2d441c6fe8e4a5b

2
src/include/io/color.hpp

@ -70,7 +70,7 @@ public:
return m_value; 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)); return std::sqrt(distance_sq(in_color));
} }

4
src/include/io/message.hpp

@ -214,11 +214,11 @@ std::string process_message(const jessilib::io::formatted_message& msg) {
// Populate args // Populate args
for (auto& text : msg.get_message()) { for (auto& text : msg.get_message()) {
args.emplace_back(fmt::internal::make_arg<fmt::format_context>(wrap_text<WrapperT>(text))); args.emplace_back(fmt::detail::make_arg<fmt::format_context>(wrap_text<WrapperT>(text)));
} }
// Pass args into vformat // Pass args into vformat
fmt::format_args text_args{ args.data(), args.size() }; fmt::format_args text_args{ args.data(), static_cast<int>(args.size()) };
return fmt::vformat(msg.format(), text_args); return fmt::vformat(msg.format(), text_args);
} }

3
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) 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 # 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/googletest)
#include_directories(googletest/googlemock) #include_directories(googletest/googlemock)

2
src/test/googletest

@ -1 +1 @@
Subproject commit d175c8bf823e709d570772b038757fadf63bc632 Subproject commit bf0701daa9f5b30e5882e2f8f9a5280bcba87e77

2
src/test/io/color.cpp

@ -74,7 +74,7 @@ TEST(ColorTest, copy) {
color color_rgb{ 0x12, 0x34, 0x56 }; color color_rgb{ 0x12, 0x34, 0x56 };
EXPECT_EQ(color_value, color_rgb); 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.red(), 0x12);
EXPECT_EQ(color_value.green(), 0x34); EXPECT_EQ(color_value.green(), 0x34);
EXPECT_EQ(color_value.blue(), 0x56); EXPECT_EQ(color_value.blue(), 0x56);

4
src/test/parser.cpp

@ -50,7 +50,7 @@ public:
return in_object.get<std::string>(); return in_object.get<std::string>();
} }
return DEFAULT_SERIALIZE_RESULT; return static_cast<std::string>(DEFAULT_SERIALIZE_RESULT);
} }
static object deserialize_default(std::string_view in_data) { static object deserialize_default(std::string_view in_data) {
@ -58,7 +58,7 @@ public:
} }
/** static members */ /** 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<std::string(const object&)> serialize_impl; static std::function<std::string(const object&)> serialize_impl;
static std::function<object(std::string_view)> deserialize_impl; static std::function<object(std::string_view)> deserialize_impl;
}; };

10
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); 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<typename LeftT, typename RightT>
void expect_eq(LeftT in_left, RightT in_right) {
EXPECT_EQ(in_left, in_right);
}
TEST(JsonParser, serialize_string) { TEST(JsonParser, serialize_string) {
json_parser parser; 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("\"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("\"te\x10xt\""), R"json("\"te\u0010xt\"")json");
} }
TEST(JsonParser, serialize_array) { TEST(JsonParser, serialize_array) {

2
src/test/timer.cpp

@ -169,7 +169,7 @@ TEST(TimerTest, simultaneousTimers) {
}}; }};
// Wait for some timers to fire // 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); EXPECT_GE(timers_running, 2);
// Notify timers to close // Notify timers to close

Loading…
Cancel
Save