aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/ci.yml16
-rw-r--r--.gitmodules9
-rw-r--r--.gitpod.yml3
-rw-r--r--CMakeLists.txt17
-rw-r--r--README.md6
m---------lib/Catch20
m---------lib/GSL0
m---------lib/double-conversion0
-rw-r--r--src/common/CMakeLists.txt4
-rw-r--r--test/CMakeLists.txt6
-rw-r--r--test/common/CMakeLists.txt2
-rw-r--r--test/common/HandlerRegistryTest.cpp11
-rw-r--r--test/common/PropertyTreeTest.cpp18
-rw-r--r--test/common/StringTest.cpp96
-rw-r--r--test/common/StringToNumberConverterTest.cpp174
-rw-r--r--test/common/StringUtilTest.cpp118
-rw-r--r--test/common/platform/unix/UnixFileStreamTest.cpp8
-rw-r--r--test/platform/CMakeLists.txt2
-rw-r--r--test/platform/ColorTest.cpp16
-rw-r--r--test/platform/MatrixTest.cpp30
-rw-r--r--test/toml/CMakeLists.txt2
-rw-r--r--test/toml/ParserTest.cpp16
-rw-r--r--test/win/graphics/direct/CMakeLists.txt2
-rw-r--r--test/win/graphics/direct/ConvertTest.cpp14
-rw-r--r--test/xml/CMakeLists.txt2
-rw-r--r--test/xml/ParserTest.cpp104
-rw-r--r--vcpkg.json10
27 files changed, 331 insertions, 355 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 8d84ba18..bafbb59b 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -18,13 +18,9 @@ jobs:
runs-on: macos-latest
steps:
- - uses: actions/checkout@v2
-
- - name: Restore Cache
- uses: actions/cache@v3
+ - uses: actions/checkout@v3
with:
- path: ~/.cache/vcpkg/archives
- key: vcpkg-${{ runner.os }}
+ submodules: true
- name: Setup Ninja
run: |
@@ -45,13 +41,9 @@ jobs:
runs-on: windows-latest
steps:
- - uses: actions/checkout@v2
-
- - name: Restore Cache
- uses: actions/cache@v3
+ - uses: actions/checkout@v3
with:
- path: ~/AppData/Local/vcpkg/archives
- key: vcpkg-${{ runner.os }}
+ submodules: true
- name: Setup Ninja
run: |
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 00000000..056b9ef1
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,9 @@
+[submodule "lib/double-conversion"]
+ path = lib/double-conversion
+ url = https://github.com/google/double-conversion.git
+[submodule "lib/GSL"]
+ path = lib/GSL
+ url = https://github.com/microsoft/GSL.git
+[submodule "lib/Catch2"]
+ path = lib/Catch2
+ url = https://github.com/catchorg/Catch2.git
diff --git a/.gitpod.yml b/.gitpod.yml
index 90a88a72..1624c093 100644
--- a/.gitpod.yml
+++ b/.gitpod.yml
@@ -2,9 +2,6 @@ tasks:
- name: vcpkg
init: |
brew install ninja
- git clone https://github.com/Microsoft/vcpkg.git
- ./vcpkg/bootstrap-vcpkg.sh
- ./vcpkg/vcpkg install
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -H. -B./build -G Ninja
ln -s build/compile_commands.json compile_commands.json
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a56119a3..48e6b21d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,22 +1,13 @@
cmake_minimum_required(VERSION 3.21)
-if(NOT CMAKE_TOOLCHAIN_FILE)
- message("CMAKE_TOOLCHAIN_FILE not set. Begin to find vcpkg toolchain file.")
- if(DEFINED ENV{VCPKG_INSTALLATION_ROOT})
- message("VCPKG_INSTALLATION_ROOT environment variable is set. Use that vcpkg.")
- set(CMAKE_TOOLCHAIN_FILE $ENV{VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake
- CACHE STRING "Vcpkg toolchain file")
- else()
- message("VCPKG_INSTALLATION_ROOT environment variable is NOT set. Use local vcpkg.")
- set(CMAKE_TOOLCHAIN_FILE vcpkg/scripts/buildsystems/vcpkg.cmake
- CACHE STRING "Vcpkg toolchain file")
- endif()
-endif()
-
set(CMAKE_CXX_STANDARD 20)
project(cru)
+add_subdirectory(lib/Catch2)
+add_subdirectory(lib/double-conversion)
+add_subdirectory(lib/GSL)
+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
diff --git a/README.md b/README.md
index 9079099a..86ba2bc7 100644
--- a/README.md
+++ b/README.md
@@ -14,11 +14,7 @@ Check the code or fire a issue if you have any problem.
## build
-_cru_ is built with [_CMake_](https://cmake.org/) and [_vcpkg_](https://github.com/microsoft/vcpkg). You must setup vcpkg first. There are two ways.
-
-1. Set environment variable `VCPKG_INSTALLATION_ROOT` to your vcpkg installation directory.
-
-2. Symlink the vcpkg installation directory to `vcpkg` of project root directory. Or just put real vcpkg there.
+_cru_ is built with [_CMake_](https://cmake.org/).
## structure of repository
diff --git a/lib/Catch2 b/lib/Catch2
new file mode 160000
+Subproject d9b0a38f81df4bd5876888ba7937f5750b59b5a
diff --git a/lib/GSL b/lib/GSL
new file mode 160000
+Subproject da01eb28dbb75bed11a51acff0f80ecedd62257
diff --git a/lib/double-conversion b/lib/double-conversion
new file mode 160000
+Subproject a109d7d05165b338513e3e379ecb5697a22b05c
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 8bfcb867..043ee5ea 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -55,6 +55,4 @@ else()
target_compile_definitions(cru_base PUBLIC CRU_PLATFORM_LINUX)
endif()
-find_package(double-conversion CONFIG REQUIRED)
-find_package(Microsoft.GSL CONFIG REQUIRED)
-target_link_libraries(cru_base PUBLIC Microsoft.GSL::GSL double-conversion::double-conversion)
+target_link_libraries(cru_base PUBLIC GSL double-conversion)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 1cd54b47..c354fba9 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,9 +1,7 @@
-find_package(GTest CONFIG REQUIRED)
-
-include(GoogleTest)
+include(Catch)
add_library(cru_test_base INTERFACE)
-target_link_libraries(cru_test_base INTERFACE GTest::gtest GTest::gtest_main)
+target_link_libraries(cru_test_base INTERFACE Catch2::Catch2WithMain)
add_subdirectory(common)
add_subdirectory(platform)
diff --git a/test/common/CMakeLists.txt b/test/common/CMakeLists.txt
index 6b2b594b..18f69e32 100644
--- a/test/common/CMakeLists.txt
+++ b/test/common/CMakeLists.txt
@@ -25,4 +25,4 @@ if (WIN32)
)
endif()
-gtest_discover_tests(cru_base_test)
+catch_discover_tests(cru_base_test)
diff --git a/test/common/HandlerRegistryTest.cpp b/test/common/HandlerRegistryTest.cpp
index cf64ef4d..03e190e3 100644
--- a/test/common/HandlerRegistryTest.cpp
+++ b/test/common/HandlerRegistryTest.cpp
@@ -1,9 +1,10 @@
#include "cru/common/HandlerRegistry.h"
-#include <gtest/gtest.h>
+#include <catch2/catch_test_macros.hpp>
+
#include <algorithm>
-TEST(HandlerRegistry, Work) {
+TEST_CASE("HandlerRegistry", "[handler_registry]") {
using namespace cru;
HandlerRegistry<void()> registry;
@@ -16,7 +17,7 @@ TEST(HandlerRegistry, Work) {
handler();
}
- ASSERT_EQ(counter, 3);
+ REQUIRE(counter == 3);
registry.RemoveHandler(tag1);
@@ -24,7 +25,7 @@ TEST(HandlerRegistry, Work) {
handler();
}
- ASSERT_EQ(counter, 4);
+ REQUIRE(counter == 4);
registry.RemoveHandler(tag2);
@@ -32,5 +33,5 @@ TEST(HandlerRegistry, Work) {
handler();
}
- ASSERT_EQ(counter, 4);
+ REQUIRE(counter == 4);
}
diff --git a/test/common/PropertyTreeTest.cpp b/test/common/PropertyTreeTest.cpp
index 620bc10d..a14fe924 100644
--- a/test/common/PropertyTreeTest.cpp
+++ b/test/common/PropertyTreeTest.cpp
@@ -1,8 +1,8 @@
#include "cru/common/PropertyTree.h"
-#include <gtest/gtest.h>
+#include <catch2/catch_test_macros.hpp>
-TEST(PropertyTree, Test) {
+TEST_CASE("PropertyTree", "[property_tree]") {
using cru::PropertySubTreeRef;
using cru::PropertyTree;
@@ -12,15 +12,15 @@ TEST(PropertyTree, Test) {
{u"k3.sub", u"v3"},
});
- ASSERT_EQ(tree.GetValue(u"k1"), u"v1");
- ASSERT_EQ(tree.GetValue(u"k2"), u"v2");
- ASSERT_EQ(tree.GetValue(u"k3.sub"), u"v3");
+ REQUIRE(tree.GetValue(u"k1") == u"v1");
+ REQUIRE(tree.GetValue(u"k2") == u"v2");
+ REQUIRE(tree.GetValue(u"k3.sub") == u"v3");
PropertySubTreeRef sub_tree = tree.GetSubTreeRef(u"k3");
- ASSERT_EQ(sub_tree.GetValue(u"sub"), u"v3");
+ REQUIRE(sub_tree.GetValue(u"sub") == u"v3");
PropertySubTreeRef root_tree = sub_tree.GetParent();
- ASSERT_EQ(root_tree.GetValue(u"k1"), u"v1");
- ASSERT_EQ(root_tree.GetValue(u"k2"), u"v2");
- ASSERT_EQ(root_tree.GetValue(u"k3.sub"), u"v3");
+ REQUIRE(root_tree.GetValue(u"k1") == u"v1");
+ REQUIRE(root_tree.GetValue(u"k2") == u"v2");
+ REQUIRE(root_tree.GetValue(u"k3.sub") == u"v3");
}
diff --git a/test/common/StringTest.cpp b/test/common/StringTest.cpp
index 1faab1cf..adbd5598 100644
--- a/test/common/StringTest.cpp
+++ b/test/common/StringTest.cpp
@@ -1,112 +1,112 @@
#include "cru/common/Format.h"
#include "cru/common/String.h"
-#include <gtest/gtest.h>
+#include <catch2/catch_test_macros.hpp>
-TEST(String, Append) {
+TEST_CASE("String Append", "[string]") {
using cru::String;
String s;
s.append(u"ha");
s.append(s);
- ASSERT_EQ(s, String(u"haha"));
+ REQUIRE(s == String(u"haha"));
}
-TEST(String, IndexConvert) {
+TEST_CASE("String IndexConvert", "[string]") {
using cru::String;
String s(u"123");
- ASSERT_EQ(s.IndexFromCodePointToCodeUnit(1), 1);
- ASSERT_EQ(s.IndexFromCodeUnitToCodePoint(1), 1);
- ASSERT_EQ(s.IndexFromCodeUnitToCodePoint(3), 3);
- ASSERT_EQ(s.IndexFromCodeUnitToCodePoint(3), 3);
+ REQUIRE(s.IndexFromCodePointToCodeUnit(1) == 1);
+ REQUIRE(s.IndexFromCodeUnitToCodePoint(1) == 1);
+ REQUIRE(s.IndexFromCodeUnitToCodePoint(3) == 3);
+ REQUIRE(s.IndexFromCodeUnitToCodePoint(3) == 3);
}
-TEST(String, Format) {
+TEST_CASE("String Format", "[string]") {
using cru::Format;
using cru::String;
- ASSERT_EQ(Format(u"{} + {} = {}", 123, 321, 444), String(u"123 + 321 = 444"));
+ REQUIRE(Format(u"{} + {} = {}", 123, 321, 444) == String(u"123 + 321 = 444"));
}
-TEST(String, Trim) {
+TEST_CASE("String Trim", "[string]") {
using cru::String;
- ASSERT_EQ(String(u" abc ").Trim(), u"abc");
+ REQUIRE(String(u" abc ").Trim() == u"abc");
}
-TEST(String, SplitToLines) {
+TEST_CASE("String SplitToLines", "[string]") {
using cru::String;
String s(u"abc\ndef\nghi");
auto lines = s.SplitToLines();
- ASSERT_EQ(lines.size(), 3);
- ASSERT_EQ(lines[0], String(u"abc"));
- ASSERT_EQ(lines[1], String(u"def"));
- ASSERT_EQ(lines[2], String(u"ghi"));
+ REQUIRE(lines.size() == 3);
+ REQUIRE(lines[0] == String(u"abc"));
+ REQUIRE(lines[1] == String(u"def"));
+ REQUIRE(lines[2] == String(u"ghi"));
}
-TEST(String, SplitToLinesWithEmptyLine) {
+TEST_CASE("String SplitToLinesWithEmptyLine", "[string]") {
using cru::String;
String s(u"abc\n \ndef\n\nghi\n");
auto lines = s.SplitToLines();
- ASSERT_EQ(lines.size(), 6);
- ASSERT_EQ(lines[0], String(u"abc"));
- ASSERT_EQ(lines[1], String(u" "));
- ASSERT_EQ(lines[2], String(u"def"));
- ASSERT_EQ(lines[3], String(u""));
- ASSERT_EQ(lines[4], String(u"ghi"));
- ASSERT_EQ(lines[5], String(u""));
+ REQUIRE(lines.size() == 6);
+ REQUIRE(lines[0] == String(u"abc"));
+ REQUIRE(lines[1] == String(u" "));
+ REQUIRE(lines[2] == String(u"def"));
+ REQUIRE(lines[3] == String(u""));
+ REQUIRE(lines[4] == String(u"ghi"));
+ REQUIRE(lines[5] == String(u""));
}
-TEST(String, SplitToLinesRemoveSpaceLine) {
+TEST_CASE("String SplitToLinesRemoveSpaceLine", "[string]") {
using cru::String;
String s(u"abc\n \ndef\n\nghi\n");
auto lines = s.SplitToLines(true);
- ASSERT_EQ(lines.size(), 3);
- ASSERT_EQ(lines[0], String(u"abc"));
- ASSERT_EQ(lines[1], String(u"def"));
- ASSERT_EQ(lines[2], String(u"ghi"));
+ REQUIRE(lines.size() == 3);
+ REQUIRE(lines[0] == String(u"abc"));
+ REQUIRE(lines[1] == String(u"def"));
+ REQUIRE(lines[2] == String(u"ghi"));
}
-TEST(StringView, ToUtf8) {
+TEST_CASE("StringView ToUtf8", "[string]") {
using cru::StringView;
StringView utf16_text = u"aπ你🤣!";
std::string_view utf8_text = "aπ你🤣!";
- ASSERT_EQ(utf16_text.ToUtf8(), utf8_text);
+ REQUIRE(utf16_text.ToUtf8() == utf8_text);
}
-TEST(String, FromUtf8) {
+TEST_CASE("String FromUtf8", "[string]") {
std::u16string_view utf16_text = u"aπ你🤣!";
std::string_view utf8_text = "aπ你🤣!";
- ASSERT_EQ(cru::String::FromUtf8(utf8_text), utf16_text);
+ REQUIRE(cru::String::FromUtf8(utf8_text) == utf16_text);
}
-TEST(StringView, ParseToDouble) {
+TEST_CASE("StringView ParseToDouble", "[string]") {
using cru::StringToNumberFlags;
using cru::StringView;
- ASSERT_EQ(StringView(u"3.14159").ParseToDouble(), 3.14159);
- ASSERT_EQ(
+ REQUIRE(StringView(u"3.14159").ParseToDouble() == 3.14159);
+ REQUIRE(
StringView(u" 3.14159")
- .ParseToDouble(nullptr, StringToNumberFlags::kAllowLeadingSpaces),
- 3.14159);
- ASSERT_EQ(
- StringView(u" 3.14159 ")
- .ParseToDouble(nullptr, StringToNumberFlags::kAllowLeadingSpaces |
- StringToNumberFlags::kAllowTrailingSpaces),
+ .ParseToDouble(nullptr, StringToNumberFlags::kAllowLeadingSpaces) ==
3.14159);
+ REQUIRE(StringView(u" 3.14159 ")
+ .ParseToDouble(nullptr,
+ StringToNumberFlags::kAllowLeadingSpaces |
+ StringToNumberFlags::kAllowTrailingSpaces) ==
+ 3.14159);
}
-TEST(String, ParseToDoubleList) {
+TEST_CASE("String ParseToDoubleList", "[string]") {
using cru::StringView;
auto list = StringView(u" 1.23 2.34 3.45 ").ParseToDoubleList();
- ASSERT_EQ(list.size(), 3);
- ASSERT_EQ(list[0], 1.23);
- ASSERT_EQ(list[1], 2.34);
- ASSERT_EQ(list[2], 3.45);
+ REQUIRE(list.size() == 3);
+ REQUIRE(list[0] == 1.23);
+ REQUIRE(list[1] == 2.34);
+ REQUIRE(list[2] == 3.45);
}
diff --git a/test/common/StringToNumberConverterTest.cpp b/test/common/StringToNumberConverterTest.cpp
index 7b009d1e..dc37bac0 100644
--- a/test/common/StringToNumberConverterTest.cpp
+++ b/test/common/StringToNumberConverterTest.cpp
@@ -1,136 +1,138 @@
#include "cru/common/Exception.h"
#include "cru/common/StringToNumberConverter.h"
-#include <gtest/gtest.h>
+#include <catch2/catch_test_macros.hpp>
-TEST(StringToIntegerConverterImpl, Base0) {
+TEST_CASE("StringToIntegerConverterImpl Base0", "[string]") {
using namespace cru;
StringToIntegerConverterImpl converter(0, 0);
Index processed_characters_count;
- ASSERT_EQ(converter.Parse("12345678", &processed_characters_count),
- StringToIntegerConverterImplResult(false, 12345678));
- ASSERT_EQ(processed_characters_count, 8);
+ REQUIRE(converter.Parse("12345678", &processed_characters_count) ==
+ StringToIntegerConverterImplResult(false, 12345678));
+ REQUIRE(processed_characters_count == 8);
- ASSERT_EQ(converter.Parse("0", &processed_characters_count),
- StringToIntegerConverterImplResult(false, 0));
- ASSERT_EQ(processed_characters_count, 1);
+ REQUIRE(converter.Parse("0", &processed_characters_count) ==
+ StringToIntegerConverterImplResult(false, 0));
+ REQUIRE(processed_characters_count == 1);
- ASSERT_EQ(converter.Parse("012", &processed_characters_count),
- StringToIntegerConverterImplResult(false, 012));
- ASSERT_EQ(processed_characters_count, 3);
+ REQUIRE(converter.Parse("012", &processed_characters_count) ==
+ StringToIntegerConverterImplResult(false, 012));
+ REQUIRE(processed_characters_count == 3);
- ASSERT_EQ(converter.Parse("0x12", &processed_characters_count),
- StringToIntegerConverterImplResult(false, 0x12));
- ASSERT_EQ(processed_characters_count, 4);
+ REQUIRE(converter.Parse("0x12", &processed_characters_count) ==
+ StringToIntegerConverterImplResult(false, 0x12));
+ REQUIRE(processed_characters_count == 4);
- ASSERT_EQ(converter.Parse("0X12", &processed_characters_count),
- StringToIntegerConverterImplResult(false, 0x12));
- ASSERT_EQ(processed_characters_count, 4);
+ REQUIRE(converter.Parse("0X12", &processed_characters_count) ==
+ StringToIntegerConverterImplResult(false, 0x12));
+ REQUIRE(processed_characters_count == 4);
- ASSERT_EQ(converter.Parse("0b101", &processed_characters_count),
- StringToIntegerConverterImplResult(false, 0b101));
- ASSERT_EQ(processed_characters_count, 5);
+ REQUIRE(converter.Parse("0b101", &processed_characters_count) ==
+ StringToIntegerConverterImplResult(false, 0b101));
+ REQUIRE(processed_characters_count == 5);
- ASSERT_EQ(converter.Parse("0B101", &processed_characters_count),
- StringToIntegerConverterImplResult(false, 0b101));
- ASSERT_EQ(processed_characters_count, 5);
+ REQUIRE(converter.Parse("0B101", &processed_characters_count) ==
+ StringToIntegerConverterImplResult(false, 0b101));
+ REQUIRE(processed_characters_count == 5);
- ASSERT_EQ(converter.Parse("-123", &processed_characters_count),
- StringToIntegerConverterImplResult(true, 123));
- ASSERT_EQ(processed_characters_count, 4);
+ REQUIRE(converter.Parse("-123", &processed_characters_count) ==
+ StringToIntegerConverterImplResult(true, 123));
+ REQUIRE(processed_characters_count == 4);
- ASSERT_EQ(converter.Parse("-0x10", &processed_characters_count),
- StringToIntegerConverterImplResult(true, 0x10));
- ASSERT_EQ(processed_characters_count, 5);
+ REQUIRE(converter.Parse("-0x10", &processed_characters_count) ==
+ StringToIntegerConverterImplResult(true, 0x10));
+ REQUIRE(processed_characters_count == 5);
}
-TEST(StringToIntegerConverterImpl, Base0ForError) {
+TEST_CASE("StringToIntegerConverterImpl Base0ForError", "[string]") {
using namespace cru;
StringToIntegerConverterImpl converter(0, 0);
Index processed_characters_count;
- ASSERT_EQ(converter.Parse("a", &processed_characters_count),
- StringToIntegerConverterImplResult(false, 0));
- ASSERT_EQ(processed_characters_count, 0);
+ REQUIRE(converter.Parse("a", &processed_characters_count) ==
+ StringToIntegerConverterImplResult(false, 0));
+ REQUIRE(processed_characters_count == 0);
- ASSERT_EQ(converter.Parse("0a", &processed_characters_count),
- StringToIntegerConverterImplResult(false, 0));
- ASSERT_EQ(processed_characters_count, 0);
+ REQUIRE(converter.Parse("0a", &processed_characters_count) ==
+ StringToIntegerConverterImplResult(false, 0));
+ REQUIRE(processed_characters_count == 0);
- ASSERT_EQ(converter.Parse("0x", &processed_characters_count),
- StringToIntegerConverterImplResult(false, 0));
- ASSERT_EQ(processed_characters_count, 0);
+ REQUIRE(converter.Parse("0x", &processed_characters_count) ==
+ StringToIntegerConverterImplResult(false, 0));
+ REQUIRE(processed_characters_count == 0);
- ASSERT_EQ(converter.Parse("0xx", &processed_characters_count),
- StringToIntegerConverterImplResult(false, 0));
- ASSERT_EQ(processed_characters_count, 0);
+ REQUIRE(converter.Parse("0xx", &processed_characters_count) ==
+ StringToIntegerConverterImplResult(false, 0));
+ REQUIRE(processed_characters_count == 0);
- ASSERT_EQ(converter.Parse(" 0", &processed_characters_count),
- StringToIntegerConverterImplResult(false, 0));
- ASSERT_EQ(processed_characters_count, 0);
+ REQUIRE(converter.Parse(" 0", &processed_characters_count) ==
+ StringToIntegerConverterImplResult(false, 0));
+ REQUIRE(processed_characters_count == 0);
- ASSERT_EQ(converter.Parse("0 ", &processed_characters_count),
- StringToIntegerConverterImplResult(false, 0));
- ASSERT_EQ(processed_characters_count, 0);
+ REQUIRE(converter.Parse("0 ", &processed_characters_count) ==
+ StringToIntegerConverterImplResult(false, 0));
+ REQUIRE(processed_characters_count == 0);
}
-TEST(StringToIntegerConverterImpl, ThrowOnErrorFlag) {
+TEST_CASE("StringToIntegerConverterImpl ThrowOnErrorFlag", "[string]") {
using namespace cru;
StringToIntegerConverterImpl converter(StringToNumberFlags::kThrowOnError, 0);
Index processed_characters_count;
- ASSERT_THROW(converter.Parse("?", &processed_characters_count), Exception);
+ REQUIRE_THROWS_AS(converter.Parse("?", &processed_characters_count),
+ Exception);
}
-TEST(StringToIntegerConverterImpl, AllowLeadingZeroFlag) {
+TEST_CASE("StringToIntegerConverterImpl AllowLeadingZeroFlag", "[string]") {
using namespace cru;
StringToIntegerConverterImpl converter(
StringToNumberFlags::kAllowLeadingSpaces, 0);
Index processed_characters_count;
- ASSERT_EQ(converter.Parse(" 123", &processed_characters_count),
- StringToIntegerConverterImplResult(false, 123));
- ASSERT_EQ(processed_characters_count, 6);
+ REQUIRE(converter.Parse(" 123", &processed_characters_count) ==
+ StringToIntegerConverterImplResult(false, 123));
+ REQUIRE(processed_characters_count == 6);
}
-TEST(StringToIntegerConverterImpl, AllowTrailingZeroFlag) {
+TEST_CASE("StringToIntegerConverterImpl AllowTrailingZeroFlag", "[string]") {
using namespace cru;
StringToIntegerConverterImpl converter(
StringToNumberFlags::kAllowTrailingSpaces, 0);
Index processed_characters_count;
- ASSERT_EQ(converter.Parse("123 ", &processed_characters_count),
- StringToIntegerConverterImplResult(false, 123));
- ASSERT_EQ(processed_characters_count, 6);
+ REQUIRE(converter.Parse("123 ", &processed_characters_count) ==
+ StringToIntegerConverterImplResult(false, 123));
+ REQUIRE(processed_characters_count == 6);
}
-TEST(StringToIntegerConverterImpl, AllowTrailingJunk) {
+TEST_CASE("StringToIntegerConverterImpl AllowTrailingJunk", "[string]") {
using namespace cru;
StringToIntegerConverterImpl converter(
StringToNumberFlags::kAllowLeadingZeroForInteger, 0);
Index processed_characters_count;
- ASSERT_EQ(converter.Parse("123 12", &processed_characters_count),
- StringToIntegerConverterImplResult(false, 123));
- ASSERT_EQ(processed_characters_count, 3);
+ REQUIRE(converter.Parse("123 12", &processed_characters_count) ==
+ StringToIntegerConverterImplResult(false, 123));
+ REQUIRE(processed_characters_count == 3);
}
-TEST(StringToIntegerConverterImpl, AllowLeadingZeroForInteger) {
+TEST_CASE("StringToIntegerConverterImpl AllowLeadingZeroForInteger",
+ "[string]") {
using namespace cru;
StringToIntegerConverterImpl converter(
StringToNumberFlags::kAllowLeadingZeroForInteger, 0);
Index processed_characters_count;
- ASSERT_EQ(converter.Parse("0x0012", &processed_characters_count),
- StringToIntegerConverterImplResult(false, 0x12));
- ASSERT_EQ(processed_characters_count, 6);
+ REQUIRE(converter.Parse("0x0012", &processed_characters_count) ==
+ StringToIntegerConverterImplResult(false, 0x12));
+ REQUIRE(processed_characters_count == 6);
- ASSERT_EQ(converter.Parse("000011", &processed_characters_count),
- StringToIntegerConverterImplResult(false, 000011));
- ASSERT_EQ(processed_characters_count, 6);
+ REQUIRE(converter.Parse("000011", &processed_characters_count) ==
+ StringToIntegerConverterImplResult(false, 000011));
+ REQUIRE(processed_characters_count == 6);
- ASSERT_EQ(converter.Parse("0b0011", &processed_characters_count),
- StringToIntegerConverterImplResult(false, 0b0011));
- ASSERT_EQ(processed_characters_count, 6);
+ REQUIRE(converter.Parse("0b0011", &processed_characters_count) ==
+ StringToIntegerConverterImplResult(false, 0b0011));
+ REQUIRE(processed_characters_count == 6);
}
-TEST(StringToIntegerConverterImpl, CompositeFlags) {
+TEST_CASE("StringToIntegerConverterImpl CompositeFlags", "[string]") {
using namespace cru;
StringToIntegerConverterImpl converter(
StringToNumberFlags::kAllowLeadingSpaces |
@@ -139,26 +141,26 @@ TEST(StringToIntegerConverterImpl, CompositeFlags) {
0);
Index processed_characters_count;
- ASSERT_EQ(converter.Parse(" 0x00123!!!", &processed_characters_count),
- StringToIntegerConverterImplResult(false, 0x00123));
- ASSERT_EQ(processed_characters_count, 10);
+ REQUIRE(converter.Parse(" 0x00123!!!", &processed_characters_count) ==
+ StringToIntegerConverterImplResult(false, 0x00123));
+ REQUIRE(processed_characters_count == 10);
}
-TEST(StringToIntegerConverterImpl, OtherBase) {
+TEST_CASE("StringToIntegerConverterImpl OtherBase", "[string]") {
using namespace cru;
StringToIntegerConverterImpl converter(0, 7);
Index processed_characters_count;
- ASSERT_EQ(converter.Parse("12", &processed_characters_count),
- StringToIntegerConverterImplResult(false, 9));
- ASSERT_EQ(processed_characters_count, 2);
+ REQUIRE(converter.Parse("12", &processed_characters_count) ==
+ StringToIntegerConverterImplResult(false, 9));
+ REQUIRE(processed_characters_count == 2);
- ASSERT_EQ(converter.Parse("-12", &processed_characters_count),
- StringToIntegerConverterImplResult(true, 9));
- ASSERT_EQ(processed_characters_count, 3);
+ REQUIRE(converter.Parse("-12", &processed_characters_count) ==
+ StringToIntegerConverterImplResult(true, 9));
+ REQUIRE(processed_characters_count == 3);
converter.base = 11;
- ASSERT_EQ(converter.Parse("1a", &processed_characters_count),
- StringToIntegerConverterImplResult(false, 21));
- ASSERT_EQ(processed_characters_count, 2);
+ REQUIRE(converter.Parse("1a", &processed_characters_count) ==
+ StringToIntegerConverterImplResult(false, 21));
+ REQUIRE(processed_characters_count == 2);
}
diff --git a/test/common/StringUtilTest.cpp b/test/common/StringUtilTest.cpp
index 54cdf30f..2dd980f9 100644
--- a/test/common/StringUtilTest.cpp
+++ b/test/common/StringUtilTest.cpp
@@ -1,68 +1,68 @@
#include "cru/common/String.h"
#include "cru/common/StringUtil.h"
-#include <gtest/gtest.h>
+#include <catch2/catch_test_macros.hpp>
using cru::k_invalid_code_point;
-TEST(StringUtil, Utf8NextCodePoint) {
+TEST_CASE("StringUtil Utf8NextCodePoint", "[string]") {
using cru::Utf8NextCodePoint;
std::string_view text = "aπ你🤣!";
gsl::index current = 0;
- ASSERT_EQ(Utf8NextCodePoint(text.data(), text.size(), current, &current),
- 0x0061);
- ASSERT_EQ(Utf8NextCodePoint(text.data(), text.size(), current, &current),
- 0x03C0);
- ASSERT_EQ(Utf8NextCodePoint(text.data(), text.size(), current, &current),
- 0x4F60);
- ASSERT_EQ(Utf8NextCodePoint(text.data(), text.size(), current, &current),
- 0x1F923);
- ASSERT_EQ(Utf8NextCodePoint(text.data(), text.size(), current, &current),
- 0x0021);
- ASSERT_EQ(Utf8NextCodePoint(text.data(), text.size(), current, &current),
- k_invalid_code_point);
- ASSERT_EQ(current, static_cast<gsl::index>(text.size()));
+ REQUIRE(Utf8NextCodePoint(text.data(), text.size(), current, &current) ==
+ 0x0061);
+ REQUIRE(Utf8NextCodePoint(text.data(), text.size(), current, &current) ==
+ 0x03C0);
+ REQUIRE(Utf8NextCodePoint(text.data(), text.size(), current, &current) ==
+ 0x4F60);
+ REQUIRE(Utf8NextCodePoint(text.data(), text.size(), current, &current) ==
+ 0x1F923);
+ REQUIRE(Utf8NextCodePoint(text.data(), text.size(), current, &current) ==
+ 0x0021);
+ REQUIRE(Utf8NextCodePoint(text.data(), text.size(), current, &current) ==
+ k_invalid_code_point);
+ REQUIRE(current == static_cast<gsl::index>(text.size()));
}
-TEST(StringUtil, Utf16NextCodePoint) {
+TEST_CASE("StringUtil Utf16NextCodePoint", "[string]") {
using cru::Utf16NextCodePoint;
std::u16string_view text = u"aπ你🤣!";
gsl::index current = 0;
- ASSERT_EQ(Utf16NextCodePoint(text.data(), text.size(), current, &current),
- 0x0061);
- ASSERT_EQ(Utf16NextCodePoint(text.data(), text.size(), current, &current),
- 0x03C0);
- ASSERT_EQ(Utf16NextCodePoint(text.data(), text.size(), current, &current),
- 0x4F60);
- ASSERT_EQ(Utf16NextCodePoint(text.data(), text.size(), current, &current),
- 0x1F923);
- ASSERT_EQ(Utf16NextCodePoint(text.data(), text.size(), current, &current),
- 0x0021);
- ASSERT_EQ(Utf16NextCodePoint(text.data(), text.size(), current, &current),
- k_invalid_code_point);
- ASSERT_EQ(current, static_cast<gsl::index>(text.size()));
+ REQUIRE(Utf16NextCodePoint(text.data(), text.size(), current, &current) ==
+ 0x0061);
+ REQUIRE(Utf16NextCodePoint(text.data(), text.size(), current, &current) ==
+ 0x03C0);
+ REQUIRE(Utf16NextCodePoint(text.data(), text.size(), current, &current) ==
+ 0x4F60);
+ REQUIRE(Utf16NextCodePoint(text.data(), text.size(), current, &current) ==
+ 0x1F923);
+ REQUIRE(Utf16NextCodePoint(text.data(), text.size(), current, &current) ==
+ 0x0021);
+ REQUIRE(Utf16NextCodePoint(text.data(), text.size(), current, &current) ==
+ k_invalid_code_point);
+ REQUIRE(current == static_cast<gsl::index>(text.size()));
}
-TEST(StringUtil, Utf16PreviousCodePoint) {
+TEST_CASE("StringUtil Utf16PreviousCodePoint", "[string]") {
using cru::Utf16PreviousCodePoint;
std::u16string_view text = u"aπ你🤣!";
gsl::index current = text.size();
- ASSERT_EQ(Utf16PreviousCodePoint(text.data(), text.size(), current, &current),
- 0x0021);
- ASSERT_EQ(Utf16PreviousCodePoint(text.data(), text.size(), current, &current),
- 0x1F923);
- ASSERT_EQ(Utf16PreviousCodePoint(text.data(), text.size(), current, &current),
- 0x4F60);
- ASSERT_EQ(Utf16PreviousCodePoint(text.data(), text.size(), current, &current),
- 0x03C0);
- ASSERT_EQ(Utf16PreviousCodePoint(text.data(), text.size(), current, &current),
- 0x0061);
- ASSERT_EQ(Utf16PreviousCodePoint(text.data(), text.size(), current, &current),
- k_invalid_code_point);
- ASSERT_EQ(current, 0);
+ REQUIRE(Utf16PreviousCodePoint(text.data(), text.size(), current, &current) ==
+ 0x0021);
+ REQUIRE(Utf16PreviousCodePoint(text.data(), text.size(), current, &current) ==
+ 0x1F923);
+ REQUIRE(Utf16PreviousCodePoint(text.data(), text.size(), current, &current) ==
+ 0x4F60);
+ REQUIRE(Utf16PreviousCodePoint(text.data(), text.size(), current, &current) ==
+ 0x03C0);
+ REQUIRE(Utf16PreviousCodePoint(text.data(), text.size(), current, &current) ==
+ 0x0061);
+ REQUIRE(Utf16PreviousCodePoint(text.data(), text.size(), current, &current) ==
+ k_invalid_code_point);
+ REQUIRE(current == 0);
}
-TEST(StringUtil, Utf8CodePointIterator) {
+TEST_CASE("StringUtil Utf8CodePointIterator", "[string]") {
using cru::Utf8CodePointIterator;
std::string_view text = "aπ你🤣!";
std::vector<cru::CodePoint> code_points;
@@ -74,10 +74,10 @@ TEST(StringUtil, Utf8CodePointIterator) {
std::vector<cru::CodePoint> expected_code_points{0x0061, 0x03C0, 0x4F60,
0x1F923, 0x0021};
- ASSERT_EQ(code_points, expected_code_points);
+ REQUIRE(code_points == expected_code_points);
}
-TEST(StringUtil, Utf16CodePointIterator) {
+TEST_CASE("StringUtil Utf16CodePointIterator", "[string]") {
using cru::Utf16CodePointIterator;
std::u16string_view text = u"aπ你🤣!";
std::vector<cru::CodePoint> code_points;
@@ -89,29 +89,29 @@ TEST(StringUtil, Utf16CodePointIterator) {
std::vector<cru::CodePoint> expected_code_points{0x0061, 0x03C0, 0x4F60,
0x1F923, 0x0021};
- ASSERT_EQ(code_points, expected_code_points);
+ REQUIRE(code_points == expected_code_points);
}
// TEST(WinString, IndexUtf8ToUtf16) {
// using cru::platform::win::IndexUtf8ToUtf16;
// std::string_view utf8_string = "aπ你🤣!";
// std::wstring_view utf16_string = L"aπ你🤣!";
-// ASSERT_EQ(IndexUtf8ToUtf16(utf8_string, 0, utf16_string), 0);
-// ASSERT_EQ(IndexUtf8ToUtf16(utf8_string, 1, utf16_string), 1);
-// ASSERT_EQ(IndexUtf8ToUtf16(utf8_string, 3, utf16_string), 2);
-// ASSERT_EQ(IndexUtf8ToUtf16(utf8_string, 6, utf16_string), 3);
-// ASSERT_EQ(IndexUtf8ToUtf16(utf8_string, 10, utf16_string), 5);
-// ASSERT_EQ(IndexUtf8ToUtf16(utf8_string, 11, utf16_string), 6);
+// REQUIRE(IndexUtf8ToUtf16(utf8_string, 0, utf16_string), 0);
+// REQUIRE(IndexUtf8ToUtf16(utf8_string, 1, utf16_string), 1);
+// REQUIRE(IndexUtf8ToUtf16(utf8_string, 3, utf16_string), 2);
+// REQUIRE(IndexUtf8ToUtf16(utf8_string, 6, utf16_string), 3);
+// REQUIRE(IndexUtf8ToUtf16(utf8_string, 10, utf16_string), 5);
+// REQUIRE(IndexUtf8ToUtf16(utf8_string, 11, utf16_string), 6);
// }
// TEST(WinString, IndexUtf16ToUtf8) {
// using cru::platform::win::IndexUtf16ToUtf8;
// std::string_view utf8_string = "aπ你🤣!";
// std::wstring_view utf16_string = L"aπ你🤣!";
-// ASSERT_EQ(IndexUtf16ToUtf8(utf16_string, 0, utf8_string), 0);
-// ASSERT_EQ(IndexUtf16ToUtf8(utf16_string, 1, utf8_string), 1);
-// ASSERT_EQ(IndexUtf16ToUtf8(utf16_string, 2, utf8_string), 3);
-// ASSERT_EQ(IndexUtf16ToUtf8(utf16_string, 3, utf8_string), 6);
-// ASSERT_EQ(IndexUtf16ToUtf8(utf16_string, 5, utf8_string), 10);
-// ASSERT_EQ(IndexUtf16ToUtf8(utf16_string, 6, utf8_string), 11);
+// REQUIRE(IndexUtf16ToUtf8(utf16_string, 0, utf8_string), 0);
+// REQUIRE(IndexUtf16ToUtf8(utf16_string, 1, utf8_string), 1);
+// REQUIRE(IndexUtf16ToUtf8(utf16_string, 2, utf8_string), 3);
+// REQUIRE(IndexUtf16ToUtf8(utf16_string, 3, utf8_string), 6);
+// REQUIRE(IndexUtf16ToUtf8(utf16_string, 5, utf8_string), 10);
+// REQUIRE(IndexUtf16ToUtf8(utf16_string, 6, utf8_string), 11);
// }
diff --git a/test/common/platform/unix/UnixFileStreamTest.cpp b/test/common/platform/unix/UnixFileStreamTest.cpp
index 1ae8c48e..b9ff40da 100644
--- a/test/common/platform/unix/UnixFileStreamTest.cpp
+++ b/test/common/platform/unix/UnixFileStreamTest.cpp
@@ -1,12 +1,12 @@
#include "cru/common/io/OpenFileFlag.h"
#include "cru/common/platform/unix/UnixFileStream.h"
-#include <gtest/gtest.h>
+#include <catch2/catch_test_macros.hpp>
#include <cstdio>
#include <filesystem>
-TEST(UnixFileStream, Work) {
+TEST_CASE("UnixFileStream Work", "[stream]") {
using namespace cru;
using namespace cru::io;
using namespace cru::platform::unix;
@@ -25,8 +25,8 @@ TEST(UnixFileStream, Work) {
UnixFileStream file2(path, OpenFileFlags::Read);
auto buffer = std::make_unique<std::byte[]>(3);
file2.Read(buffer.get(), 3);
- ASSERT_EQ(std::string_view(reinterpret_cast<const char*>(buffer.get()), 3),
- "abc");
+ REQUIRE(std::string_view(reinterpret_cast<const char*>(buffer.get()), 3) ==
+ "abc");
file2.Close();
std::filesystem::remove(temp_file_path);
diff --git a/test/platform/CMakeLists.txt b/test/platform/CMakeLists.txt
index 5feec2d1..014e88fe 100644
--- a/test/platform/CMakeLists.txt
+++ b/test/platform/CMakeLists.txt
@@ -11,4 +11,4 @@ if (WIN32)
)
endif()
-gtest_discover_tests(cru_platform_base_test)
+catch_discover_tests(cru_platform_base_test)
diff --git a/test/platform/ColorTest.cpp b/test/platform/ColorTest.cpp
index 451fb069..0c7c18ba 100644
--- a/test/platform/ColorTest.cpp
+++ b/test/platform/ColorTest.cpp
@@ -1,14 +1,14 @@
#include "cru/platform/Color.h"
-#include <gtest/gtest.h>
+#include <catch2/catch_test_macros.hpp>
using cru::platform::Color;
-TEST(Color, Parse) {
- ASSERT_EQ(Color::Parse(u"blue"), Color::Parse(u"#0000ff"));
- ASSERT_EQ(Color::Parse(u"#12abAB"), Color::FromHex(0x12abAB));
- ASSERT_EQ(Color::Parse(u"#8812abAB"), Color::FromHexAlpha(0x8812abAB));
- ASSERT_EQ(Color::Parse(u"averystrangestring"), std::nullopt);
- ASSERT_EQ(Color::Parse(u"112233"), std::nullopt);
- ASSERT_EQ(Color::Parse(u"#7777777"), std::nullopt);
+TEST_CASE("Color Parse", "[color]") {
+ REQUIRE(Color::Parse(u"blue") == Color::Parse(u"#0000ff"));
+ REQUIRE(Color::Parse(u"#12abAB") == Color::FromHex(0x12abAB));
+ REQUIRE(Color::Parse(u"#8812abAB") == Color::FromHexAlpha(0x8812abAB));
+ REQUIRE(Color::Parse(u"averystrangestring") == std::nullopt);
+ REQUIRE(Color::Parse(u"112233") == std::nullopt);
+ REQUIRE(Color::Parse(u"#7777777") == std::nullopt);
}
diff --git a/test/platform/MatrixTest.cpp b/test/platform/MatrixTest.cpp
index 62492b4e..b19b25fe 100644
--- a/test/platform/MatrixTest.cpp
+++ b/test/platform/MatrixTest.cpp
@@ -1,37 +1,39 @@
#include "cru/platform/GraphicsBase.h"
#include "cru/platform/Matrix.h"
-#include <gtest/gtest.h>
+#include <catch2/catch_test_macros.hpp>
+#include "catch2/catch_approx.hpp"
+using Catch::Approx;
using cru::platform::Matrix;
using cru::platform::Point;
-TEST(Matrix, Rotation) {
+TEST_CASE("Matrix Rotation", "[matrix]") {
Point p(1, 1);
Point p90 = Matrix::Rotation(90).TransformPoint(p);
- ASSERT_FLOAT_EQ(p90.x, -1);
- ASSERT_FLOAT_EQ(p90.y, 1);
+ REQUIRE(p90.x == Approx(-1));
+ REQUIRE(p90.y == Approx(1));
Point p180 = Matrix::Rotation(180).TransformPoint(p);
- ASSERT_FLOAT_EQ(p180.x, -1);
- ASSERT_FLOAT_EQ(p180.y, -1);
+ REQUIRE(p180.x == Approx(-1));
+ REQUIRE(p180.y == Approx(-1));
Point p270 = Matrix::Rotation(270).TransformPoint(p);
- ASSERT_FLOAT_EQ(p270.x, 1);
- ASSERT_FLOAT_EQ(p270.y, -1);
+ REQUIRE(p270.x == Approx(1));
+ REQUIRE(p270.y == Approx(-1));
}
-TEST(Matrix, TranslationAndRotation) {
+TEST_CASE("Matrix TranslationAndRotation", "[matrix]") {
Point p =
(Matrix::Translation(1, 1) * Matrix::Rotation(90)).TransformPoint({1, 1});
- ASSERT_FLOAT_EQ(p.x, -2);
- ASSERT_FLOAT_EQ(p.y, 2);
+ REQUIRE(p.x == Approx(-2));
+ REQUIRE(p.y == Approx(2));
}
-TEST(Matrix, RotationAndTranslation) {
+TEST_CASE("Matrix RotationAndTranslation", "[matrix]") {
Point p =
(Matrix::Rotation(90) * Matrix::Translation(1, 1)).TransformPoint({1, 1});
- ASSERT_FLOAT_EQ(p.x, 0);
- ASSERT_FLOAT_EQ(p.y, 2);
+ REQUIRE(p.x == Approx(0));
+ REQUIRE(p.y == Approx(2));
}
diff --git a/test/toml/CMakeLists.txt b/test/toml/CMakeLists.txt
index 98270d30..c80355ed 100644
--- a/test/toml/CMakeLists.txt
+++ b/test/toml/CMakeLists.txt
@@ -10,4 +10,4 @@ if (WIN32)
)
endif()
-gtest_discover_tests(cru_toml_test)
+catch_discover_tests(cru_toml_test)
diff --git a/test/toml/ParserTest.cpp b/test/toml/ParserTest.cpp
index 5e9b84b9..b35b932a 100644
--- a/test/toml/ParserTest.cpp
+++ b/test/toml/ParserTest.cpp
@@ -1,11 +1,11 @@
#include "cru/toml/TomlDocument.h"
#include "cru/toml/TomlParser.h"
-#include <gtest/gtest.h>
+#include <catch2/catch_test_macros.hpp>
using namespace cru::toml;
-TEST(CruTomlParserTest, Simple) {
+TEST_CASE("CruTomlParserTest Simple", "[toml]") {
TomlParser parser(
uR"(
a1 = v1
@@ -22,10 +22,10 @@ a5 = v5
a6 = v6
)");
auto document = parser.Parse();
- ASSERT_EQ(document.GetSection(u"")->GetValue(u"a1"), u"v1");
- ASSERT_EQ(document.GetSection(u"")->GetValue(u"a2"), u"v2");
- ASSERT_EQ(document.GetSection(u"s1")->GetValue(u"a3"), u"v3");
- ASSERT_EQ(document.GetSection(u"s1")->GetValue(u"a4"), u"v4");
- ASSERT_EQ(document.GetSection(u"s2")->GetValue(u"a5"), u"v5");
- ASSERT_EQ(document.GetSection(u"s2")->GetValue(u"a6"), u"v6");
+ REQUIRE(document.GetSection(u"")->GetValue(u"a1") == u"v1");
+ REQUIRE(document.GetSection(u"")->GetValue(u"a2") == u"v2");
+ REQUIRE(document.GetSection(u"s1")->GetValue(u"a3") == u"v3");
+ REQUIRE(document.GetSection(u"s1")->GetValue(u"a4") == u"v4");
+ REQUIRE(document.GetSection(u"s2")->GetValue(u"a5") == u"v5");
+ REQUIRE(document.GetSection(u"s2")->GetValue(u"a6") == u"v6");
}
diff --git a/test/win/graphics/direct/CMakeLists.txt b/test/win/graphics/direct/CMakeLists.txt
index c68f14c5..01320312 100644
--- a/test/win/graphics/direct/CMakeLists.txt
+++ b/test/win/graphics/direct/CMakeLists.txt
@@ -10,4 +10,4 @@ if (WIN32)
)
endif()
-gtest_discover_tests(cru_win_graphics_direct_test)
+catch_discover_tests(cru_win_graphics_direct_test)
diff --git a/test/win/graphics/direct/ConvertTest.cpp b/test/win/graphics/direct/ConvertTest.cpp
index f19177fe..a0744e8b 100644
--- a/test/win/graphics/direct/ConvertTest.cpp
+++ b/test/win/graphics/direct/ConvertTest.cpp
@@ -1,29 +1,29 @@
#include "cru/platform/Matrix.h"
#include "cru/win/graphics/direct/ConvertUtil.h"
-#include <gtest/gtest.h>
+#include <catch2/catch_test_macros.hpp>
using cru::platform::Matrix;
using cru::platform::graphics::win::direct::Convert;
-TEST(MatrixConvert, Rotation) {
+TEST_CASE("MatrixConvert Rotation", "[matrix]") {
auto matrix = Convert(Matrix::Rotation(90));
auto m = *D2D1::Matrix3x2F::ReinterpretBaseType(&matrix);
auto p = m.TransformPoint({1, 1});
- ASSERT_FLOAT_EQ(p.x, -1);
- ASSERT_FLOAT_EQ(p.y, 1);
+ REQUIRE(p.x == -1);
+ REQUIRE(p.y == 1);
}
-TEST(MatrixConvert, RotationAndTranslation) {
+TEST_CASE("MatrixConvert RotationAndTranslation", "[matrix]") {
auto matrix = Convert(Matrix::Rotation(90) * Matrix::Translation(1, 1));
auto m = *D2D1::Matrix3x2F::ReinterpretBaseType(&matrix);
auto p = m.TransformPoint({1, 1});
- ASSERT_FLOAT_EQ(p.x, 0);
- ASSERT_FLOAT_EQ(p.y, 2);
+ REQUIRE(p.x == 0);
+ REQUIRE(p.y == 2);
}
diff --git a/test/xml/CMakeLists.txt b/test/xml/CMakeLists.txt
index d6ce4447..64f8eab3 100644
--- a/test/xml/CMakeLists.txt
+++ b/test/xml/CMakeLists.txt
@@ -10,4 +10,4 @@ if (WIN32)
)
endif()
-gtest_discover_tests(cru_xml_test)
+catch_discover_tests(cru_xml_test)
diff --git a/test/xml/ParserTest.cpp b/test/xml/ParserTest.cpp
index 8edebeb6..d998abb4 100644
--- a/test/xml/ParserTest.cpp
+++ b/test/xml/ParserTest.cpp
@@ -1,82 +1,82 @@
#include "cru/xml/XmlNode.h"
#include "cru/xml/XmlParser.h"
-#include <gtest/gtest.h>
+#include <catch2/catch_test_macros.hpp>
using namespace cru::xml;
-TEST(CruXmlParserTest, Simple) {
+TEST_CASE("CruXmlParserTest Simple", "[xml]") {
XmlParser parser(u"<root></root>");
auto n = parser.Parse();
- ASSERT_EQ(n->GetTag(), u"root");
- ASSERT_EQ(n->GetAttributes().empty(), true);
- ASSERT_EQ(n->GetChildCount(), 0);
+ REQUIRE(n->GetTag() == u"root");
+ REQUIRE(n->GetAttributes().empty() == true);
+ REQUIRE(n->GetChildCount() == 0);
delete n;
}
-TEST(CruXmlParserTest, SimpleWithAttribute) {
+TEST_CASE("CruXmlParserTest SimpleWithAttribute", "[xml]") {
XmlParser parser(u"<root a1=\"v1\" a2=\"v2\"></root>");
auto n = parser.Parse();
- ASSERT_EQ(n->GetTag(), u"root");
- ASSERT_EQ(n->GetAttributeValue(u"a1"), u"v1");
- ASSERT_EQ(n->GetAttributeValue(u"a2"), u"v2");
- ASSERT_EQ(n->GetChildCount(), 0);
+ REQUIRE(n->GetTag() == u"root");
+ REQUIRE(n->GetAttributeValue(u"a1") == u"v1");
+ REQUIRE(n->GetAttributeValue(u"a2") == u"v2");
+ REQUIRE(n->GetChildCount() == 0);
delete n;
}
-TEST(CruXmlParserTest, SimpleSelfClosing) {
+TEST_CASE("CruXmlParserTest SimpleSelfClosing", "[xml]") {
XmlParser parser(u"<root a1=\"v1\" a2=\"v2\"/>");
auto n = parser.Parse();
- ASSERT_EQ(n->GetTag(), u"root");
- ASSERT_EQ(n->GetAttributeValue(u"a1"), u"v1");
- ASSERT_EQ(n->GetAttributeValue(u"a2"), u"v2");
- ASSERT_EQ(n->GetChildCount(), 0);
+ REQUIRE(n->GetTag() == u"root");
+ REQUIRE(n->GetAttributeValue(u"a1") == u"v1");
+ REQUIRE(n->GetAttributeValue(u"a2") == u"v2");
+ REQUIRE(n->GetChildCount() == 0);
delete n;
}
-TEST(CruXmlParserTest, NestedElement) {
+TEST_CASE("CruXmlParserTest NestedElement", "[xml]") {
XmlParser parser(
u"<root><c1><d1></d1></c1><c2><d2></d2><d3></d3></c2></root>");
auto n = parser.Parse();
- ASSERT_EQ(n->GetChildren().size(), 2);
- ASSERT_EQ(n->GetChildAt(0)->AsElement()->GetTag(), u"c1");
- ASSERT_EQ(n->GetChildAt(1)->AsElement()->GetTag(), u"c2");
- ASSERT_EQ(n->GetChildAt(0)->AsElement()->GetChildCount(), 1);
- ASSERT_EQ(n->GetChildAt(0)->AsElement()->GetChildAt(0)->AsElement()->GetTag(),
- u"d1");
- ASSERT_EQ(n->GetChildAt(1)->AsElement()->GetChildCount(), 2);
- ASSERT_EQ(n->GetChildAt(1)->AsElement()->GetChildAt(0)->AsElement()->GetTag(),
- u"d2");
- ASSERT_EQ(n->GetChildAt(1)->AsElement()->GetChildAt(1)->AsElement()->GetTag(),
- u"d3");
+ REQUIRE(n->GetChildren().size() == 2);
+ REQUIRE(n->GetChildAt(0)->AsElement()->GetTag() == u"c1");
+ REQUIRE(n->GetChildAt(1)->AsElement()->GetTag() == u"c2");
+ REQUIRE(n->GetChildAt(0)->AsElement()->GetChildCount() == 1);
+ REQUIRE(n->GetChildAt(0)->AsElement()->GetChildAt(0)->AsElement()->GetTag() ==
+ u"d1");
+ REQUIRE(n->GetChildAt(1)->AsElement()->GetChildCount() == 2);
+ REQUIRE(n->GetChildAt(1)->AsElement()->GetChildAt(0)->AsElement()->GetTag() ==
+ u"d2");
+ REQUIRE(n->GetChildAt(1)->AsElement()->GetChildAt(1)->AsElement()->GetTag() ==
+ u"d3");
delete n;
}
-TEST(CruXmlParserTest, SimpleText) {
+TEST_CASE("CruXmlParserTest SimpleText", "[xml]") {
XmlParser parser(u"<root>text</root>");
auto n = parser.Parse();
- ASSERT_EQ(n->GetChildCount(), 1);
- ASSERT_EQ(n->GetChildAt(0)->AsText()->GetText(), u"text");
+ REQUIRE(n->GetChildCount() == 1);
+ REQUIRE(n->GetChildAt(0)->AsText()->GetText() == u"text");
delete n;
}
-TEST(CruXmlParserTest, Whitespace) {
+TEST_CASE("CruXmlParserTest Whitespace", "[xml]") {
XmlParser parser(u"\t\t<root>\n\t\t\ttext test\n\t\t</root>\t\t");
auto n = parser.Parse();
- ASSERT_EQ(n->GetChildCount(), 1);
- ASSERT_EQ(n->GetChildAt(0)->AsText()->GetText(), u"text test");
+ REQUIRE(n->GetChildCount() == 1);
+ REQUIRE(n->GetChildAt(0)->AsText()->GetText() == u"text test");
delete n;
}
-TEST(CruXmlParserTest, Comment) {
+TEST_CASE("CruXmlParserTest Comment", "[xml]") {
XmlParser parser(u"<!-- comment -->");
auto n = parser.Parse();
- ASSERT_TRUE(n->IsCommentNode());
- ASSERT_EQ(n->AsComment()->GetText(), u"comment");
+ REQUIRE(n->IsCommentNode());
+ REQUIRE(n->AsComment()->GetText() == u"comment");
delete n;
}
-TEST(CruXmlParserTest, Complex) {
+TEST_CASE("CruXmlParserTest Complex", "[xml]") {
XmlParser parser(
uR"(
<root a1="v1">
@@ -95,22 +95,22 @@ TEST(CruXmlParserTest, Complex) {
</root>
)");
auto n = parser.Parse();
- ASSERT_EQ(n->GetAttributeValue(u"a1"), u"v1");
- ASSERT_EQ(n->GetChildCount(), 3);
- ASSERT_EQ(n->GetChildAt(0)->AsElement()->GetTag(), u"c1");
- ASSERT_EQ(n->GetChildAt(0)->AsElement()->GetChildCount(), 1);
+ REQUIRE(n->GetAttributeValue(u"a1") == u"v1");
+ REQUIRE(n->GetChildCount() == 3);
+ REQUIRE(n->GetChildAt(0)->AsElement()->GetTag() == u"c1");
+ REQUIRE(n->GetChildAt(0)->AsElement()->GetChildCount() == 1);
auto c2 = n->GetChildAt(1)->AsElement();
- ASSERT_EQ(c2->GetTag(), u"c2");
- ASSERT_EQ(c2->GetAttributeValue(u"a2"), u"v2");
- ASSERT_EQ(c2->GetAttributeValue(u"a3"), u"v3");
- ASSERT_EQ(c2->GetChildAt(0)->AsText()->GetText(), u"t1");
+ REQUIRE(c2->GetTag() == u"c2");
+ REQUIRE(c2->GetAttributeValue(u"a2") == u"v2");
+ REQUIRE(c2->GetAttributeValue(u"a3") == u"v3");
+ REQUIRE(c2->GetChildAt(0)->AsText()->GetText() == u"t1");
auto d2 = c2->GetChildAt(1)->AsElement();
- ASSERT_EQ(d2->GetTag(), u"d2");
- ASSERT_EQ(d2->GetAttributeValue(u"a4"), u"v4");
- ASSERT_EQ(c2->GetChildAt(2)->AsText()->GetText(), u"text test");
- ASSERT_EQ(c2->GetChildAt(3)->AsElement()->GetTag(), u"d3");
- ASSERT_EQ(c2->GetChildAt(4)->AsText()->GetText(), u"t2");
- ASSERT_TRUE(n->GetChildAt(2)->IsCommentNode());
- ASSERT_EQ(n->GetChildAt(2)->AsComment()->GetText(), u"comment");
+ REQUIRE(d2->GetTag() == u"d2");
+ REQUIRE(d2->GetAttributeValue(u"a4") == u"v4");
+ REQUIRE(c2->GetChildAt(2)->AsText()->GetText() == u"text test");
+ REQUIRE(c2->GetChildAt(3)->AsElement()->GetTag() == u"d3");
+ REQUIRE(c2->GetChildAt(4)->AsText()->GetText() == u"t2");
+ REQUIRE(n->GetChildAt(2)->IsCommentNode());
+ REQUIRE(n->GetChildAt(2)->AsComment()->GetText() == u"comment");
delete n;
}
diff --git a/vcpkg.json b/vcpkg.json
deleted file mode 100644
index 1a110ef9..00000000
--- a/vcpkg.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
- "name": "cru",
- "version": "0.0.1",
- "dependencies": [
- "ms-gsl",
- "gtest",
- "double-conversion"
- ]
-}