aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--thirdparty/licenses/Catch2.tps13
-rw-r--r--thirdparty/licenses/Catch2_License.txt23
-rw-r--r--xmake.lua1
-rw-r--r--zen/zen.cpp5
-rw-r--r--zencore-test/xmake.lua1
-rw-r--r--zencore-test/zencore-test.cpp5
-rw-r--r--zencore/blake3.cpp16
-rw-r--r--zencore/compactbinary.cpp4
-rw-r--r--zencore/compactbinarybuilder.cpp26
-rw-r--r--zencore/include/zencore/testing.h32
-rw-r--r--zencore/md5.cpp16
-rw-r--r--zencore/sha1.cpp16
-rw-r--r--zencore/xmake.lua1
-rw-r--r--zenserver-test/zenserver-test.cpp19
-rw-r--r--zenserver/zenserver.cpp5
-rw-r--r--zenstore-test/zenstore-test.cpp6
-rw-r--r--zenstore/blockstore.cpp6
-rw-r--r--zenstore/compactcas.cpp6
-rw-r--r--zenstore/include/zenstore/blockstore.h2
19 files changed, 139 insertions, 64 deletions
diff --git a/thirdparty/licenses/Catch2.tps b/thirdparty/licenses/Catch2.tps
new file mode 100644
index 000000000..e58e2cf3a
--- /dev/null
+++ b/thirdparty/licenses/Catch2.tps
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<TpsData xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <Name>Catch 2</Name>
+ <Location>https://github.com/EpicGames/zen</Location>
+ <Function>Unit test framework.</Function>
+ <Eula>https://github.com/catchorg/Catch2/blob/devel/LICENSE.txt</Eula>
+ <RedistributeTo>
+ <EndUserGroup>Licensees</EndUserGroup>
+ <EndUserGroup>Git</EndUserGroup>
+ <EndUserGroup>P4</EndUserGroup>
+ </RedistributeTo>
+ <LicenseFolder>https://github.com/EpicGames/zen/tree/main/thirdparty/licenses</LicenseFolder>
+</TpsData> \ No newline at end of file
diff --git a/thirdparty/licenses/Catch2_License.txt b/thirdparty/licenses/Catch2_License.txt
new file mode 100644
index 000000000..127a5bc39
--- /dev/null
+++ b/thirdparty/licenses/Catch2_License.txt
@@ -0,0 +1,23 @@
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE. \ No newline at end of file
diff --git a/xmake.lua b/xmake.lua
index 5ddcf7ce8..e4d795fcf 100644
--- a/xmake.lua
+++ b/xmake.lua
@@ -5,6 +5,7 @@ set_configvar("ZEN_SCHEMA_VERSION", 3) -- changed cas oplog format (p3rl)
add_requires(
"vcpkg::asio",
+ "vcpkg::catch2",
"vcpkg::cpr",
"vcpkg::curl",
"vcpkg::cxxopts",
diff --git a/zen/zen.cpp b/zen/zen.cpp
index dc9be5d15..302e8496f 100644
--- a/zen/zen.cpp
+++ b/zen/zen.cpp
@@ -23,9 +23,8 @@
#include <zenstore/cas.h>
#if ZEN_WITH_TESTS
-# define DOCTEST_CONFIG_IMPLEMENT
+# define ZEN_TEST_WITH_RUNNER
# include <zencore/testing.h>
-# undef DOCTEST_CONFIG_IMPLEMENT
#endif
#include <gsl/gsl-lite.hpp>
@@ -80,7 +79,7 @@ public:
return GetLastError();
# endif // ZEN_PLATFORM_WINDOWS
- return doctest::Context(argc, argv).run();
+ return ZEN_RUN_TESTS(argc, argv);
}
virtual cxxopts::Options* Options() override { return &m_Options; }
diff --git a/zencore-test/xmake.lua b/zencore-test/xmake.lua
index 74c7e74a7..2556a1399 100644
--- a/zencore-test/xmake.lua
+++ b/zencore-test/xmake.lua
@@ -5,4 +5,5 @@ target("zencore-test")
add_headerfiles("**.h")
add_files("*.cpp")
add_deps("zencore")
+ add_packages("vcpkg::catch2")
add_packages("vcpkg::doctest")
diff --git a/zencore-test/zencore-test.cpp b/zencore-test/zencore-test.cpp
index 7d7365c54..53413fb25 100644
--- a/zencore-test/zencore-test.cpp
+++ b/zencore-test/zencore-test.cpp
@@ -7,9 +7,8 @@
#include <zencore/zencore.h>
#if ZEN_WITH_TESTS
-# define DOCTEST_CONFIG_IMPLEMENT
+# define ZEN_TEST_WITH_RUNNER 1
# include <zencore/testing.h>
-# undef DOCTEST_CONFIG_IMPLEMENT
#endif
int
@@ -20,7 +19,7 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
zen::logging::InitializeLogging();
- return doctest::Context(argc, argv).run();
+ return ZEN_RUN_TESTS(argc, argv);
#else
return 0;
#endif
diff --git a/zencore/blake3.cpp b/zencore/blake3.cpp
index b2019d4e2..02d6eb241 100644
--- a/zencore/blake3.cpp
+++ b/zencore/blake3.cpp
@@ -127,14 +127,14 @@ BLAKE3Stream::GetHash()
#if ZEN_WITH_TESTS
-doctest::String
-toString(const BLAKE3& value)
-{
- char text[2 * sizeof(BLAKE3) + 1];
- value.ToHexString(text);
-
- return text;
-}
+// doctest::String
+// toString(const BLAKE3& value)
+// {
+// char text[2 * sizeof(BLAKE3) + 1];
+// value.ToHexString(text);
+
+// return text;
+// }
TEST_CASE("BLAKE3")
{
diff --git a/zencore/compactbinary.cpp b/zencore/compactbinary.cpp
index a51253989..375a97fc5 100644
--- a/zencore/compactbinary.cpp
+++ b/zencore/compactbinary.cpp
@@ -2133,8 +2133,8 @@ TEST_CASE("uson.json")
const double DoubleValue = Json["Double"].number_value();
CHECK(JsonError.empty());
- CHECK(FloatValue == doctest::Approx(ExpectedFloatValue));
- CHECK(DoubleValue == doctest::Approx(ExpectedDoubleValue));
+ CHECK(FloatValue == Approx(ExpectedFloatValue));
+ CHECK(DoubleValue == Approx(ExpectedDoubleValue));
}
SUBCASE("number.nan")
diff --git a/zencore/compactbinarybuilder.cpp b/zencore/compactbinarybuilder.cpp
index 1d2ba45df..d4ccd434d 100644
--- a/zencore/compactbinarybuilder.cpp
+++ b/zencore/compactbinarybuilder.cpp
@@ -706,19 +706,19 @@ usonbuilder_forcelink()
{
}
-doctest::String
-toString(const DateTime&)
-{
- // TODO:implement
- return "";
-}
-
-doctest::String
-toString(const TimeSpan&)
-{
- // TODO:implement
- return "";
-}
+// doctest::String
+// toString(const DateTime&)
+// {
+// // TODO:implement
+// return "";
+// }
+
+// doctest::String
+// toString(const TimeSpan&)
+// {
+// // TODO:implement
+// return "";
+// }
TEST_CASE("usonbuilder.object")
{
diff --git a/zencore/include/zencore/testing.h b/zencore/include/zencore/testing.h
index 80aebc26e..faa4eef6c 100644
--- a/zencore/include/zencore/testing.h
+++ b/zencore/include/zencore/testing.h
@@ -4,6 +4,36 @@
#include <zencore/zencore.h>
+#ifdef ZEN_TEST_WITH_RUNNER
+# define CATCH_CONFIG_RUNNER
+# define DOCTEST_CONFIG_IMPLEMENT
+#endif
+
+#ifndef ZEN_USE_CATCH2
+# define ZEN_USE_CATCH2 0
+#endif
+
#if ZEN_WITH_TESTS
-# include <doctest/doctest.h>
+# if ZEN_USE_CATCH2
+# include <catch2/catch.hpp>
+# define SUBCASE(x) SECTION(x)
+# define CHECK_EQ(x, y) CHECK((x) == (y))
+# define CHECK_MESSAGE(x, y) CHECK(x)
+# define ZEN_RUN_TESTS(argC, argV) Catch::Session().run(argC, argV)
+# else
+# include <doctest/doctest.h>
+# define ZEN_RUN_TESTS(argC, argV) doctest::Context(argc, argv).run()
+inline auto
+Approx(auto Value)
+{
+ return doctest::Approx(Value);
+}
+# endif
+#else
+# define ZEN_RUN_TESTS(argC, argV)
+#endif
+
+#ifdef ZEN_TEST_WITH_RUNNER
+# undef CATCH_CONFIG_RUNNER
+# undef DOCTEST_CONFIG_IMPLEMENT
#endif
diff --git a/zencore/md5.cpp b/zencore/md5.cpp
index faece3862..4ec145697 100644
--- a/zencore/md5.cpp
+++ b/zencore/md5.cpp
@@ -428,14 +428,14 @@ md5_forcelink()
{
}
-doctest::String
-toString(const MD5& value)
-{
- char md5text[2 * sizeof(MD5) + 1];
- value.ToHexString(md5text);
-
- return md5text;
-}
+// doctest::String
+// toString(const MD5& value)
+// {
+// char md5text[2 * sizeof(MD5) + 1];
+// value.ToHexString(md5text);
+
+// return md5text;
+// }
TEST_CASE("MD5")
{
diff --git a/zencore/sha1.cpp b/zencore/sha1.cpp
index 66e01f232..3ee74d7d8 100644
--- a/zencore/sha1.cpp
+++ b/zencore/sha1.cpp
@@ -364,14 +364,14 @@ sha1_forcelink()
{
}
-doctest::String
-toString(const SHA1& value)
-{
- char sha1text[2 * sizeof(SHA1) + 1];
- value.ToHexString(sha1text);
-
- return sha1text;
-}
+// doctest::String
+// toString(const SHA1& value)
+// {
+// char sha1text[2 * sizeof(SHA1) + 1];
+// value.ToHexString(sha1text);
+
+// return sha1text;
+// }
TEST_CASE("SHA1")
{
diff --git a/zencore/xmake.lua b/zencore/xmake.lua
index 1044c5025..63e874ac5 100644
--- a/zencore/xmake.lua
+++ b/zencore/xmake.lua
@@ -33,6 +33,7 @@ target('zencore')
"vcpkg::spdlog",
"vcpkg::fmt",
"vcpkg::doctest",
+ "vcpkg::catch2",
"vcpkg::json11",
"vcpkg::lz4",
"vcpkg::mimalloc",
diff --git a/zenserver-test/zenserver-test.cpp b/zenserver-test/zenserver-test.cpp
index a6e89e702..21837fc0a 100644
--- a/zenserver-test/zenserver-test.cpp
+++ b/zenserver-test/zenserver-test.cpp
@@ -65,9 +65,8 @@ ZEN_THIRD_PARTY_INCLUDES_END
//////////////////////////////////////////////////////////////////////////
#if ZEN_WITH_TESTS
-# define DOCTEST_CONFIG_IMPLEMENT
+# define ZEN_TEST_WITH_RUNNER 1
# include <zencore/testing.h>
-# undef DOCTEST_CONFIG_IMPLEMENT
#endif
using namespace std::literals;
@@ -331,7 +330,8 @@ main(int argc, char** argv)
TestEnv.InitializeForTest(ProgramBaseDir, TestBaseDir);
ZEN_INFO("Running tests...(base dir: '{}')", TestBaseDir);
- return doctest::Context(argc, argv).run();
+
+ return ZEN_RUN_TESTS(argc, argv);
}
namespace zen::tests {
@@ -2504,8 +2504,12 @@ private:
zen::BinaryWriter m_MemOut;
};
-TEST_CASE("exec.basic" * doctest::skip(true))
+TEST_CASE(".exec.basic" /* * doctest::skip(true) */)
{
+ if (true)
+ {
+ return;
+ }
# if ZEN_WITH_EXEC_SERVICES
using namespace std::literals;
@@ -2733,8 +2737,13 @@ TEST_CASE("http.package")
CHECK_EQ(ResponsePackage, TestPackage);
}
-TEST_CASE("websocket.basic" * doctest::skip(true))
+TEST_CASE("websocket.basic")
{
+ if (true)
+ {
+ return;
+ }
+
std::filesystem::path TestDir = TestEnv.CreateNewTestDir();
const uint16_t PortNumber = 13337;
const auto MaxWaitTime = std::chrono::seconds(5);
diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp
index 9e6c67d34..05ae4a09a 100644
--- a/zenserver/zenserver.cpp
+++ b/zenserver/zenserver.cpp
@@ -50,9 +50,8 @@ ZEN_THIRD_PARTY_INCLUDES_END
// in some shared code into the executable
#if ZEN_WITH_TESTS
-# define DOCTEST_CONFIG_IMPLEMENT
+# define ZEN_TEST_WITH_RUNNER
# include <zencore/testing.h>
-# undef DOCTEST_CONFIG_IMPLEMENT
#endif
//////////////////////////////////////////////////////////////////////////
@@ -1162,7 +1161,7 @@ test_main(int argc, char** argv)
zen::MaximizeOpenFileCount();
- return doctest::Context(argc, argv).run();
+ return ZEN_RUN_TESTS(argc, argv);
}
#endif
diff --git a/zenstore-test/zenstore-test.cpp b/zenstore-test/zenstore-test.cpp
index ebc0806d5..00c1136b6 100644
--- a/zenstore-test/zenstore-test.cpp
+++ b/zenstore-test/zenstore-test.cpp
@@ -12,9 +12,8 @@
#endif
#if ZEN_WITH_TESTS
-# define DOCTEST_CONFIG_IMPLEMENT
+# define ZEN_TEST_WITH_RUNNER 1
# include <zencore/testing.h>
-# undef DOCTEST_CONFIG_IMPLEMENT
#endif
int
@@ -26,7 +25,8 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
zen::logging::InitializeLogging();
zen::MaximizeOpenFileCount();
- return doctest::Context(argc, argv).run();
+ return ZEN_RUN_TESTS(argc, argv);
#else
+ return 0;
#endif
}
diff --git a/zenstore/blockstore.cpp b/zenstore/blockstore.cpp
index d490678b5..3e27b0d12 100644
--- a/zenstore/blockstore.cpp
+++ b/zenstore/blockstore.cpp
@@ -911,12 +911,6 @@ BlockStore::GetBlockPath(const std::filesystem::path& BlocksBasePath, const uint
#if ZEN_WITH_TESTS
-static bool
-operator==(const BlockStoreLocation& Lhs, const BlockStoreLocation& Rhs)
-{
- return Lhs.BlockIndex == Rhs.BlockIndex && Lhs.Offset == Rhs.Offset && Lhs.Size == Rhs.Size;
-}
-
TEST_CASE("blockstore.blockstoredisklocation")
{
BlockStoreLocation Zero = BlockStoreLocation{.BlockIndex = 0, .Offset = 0, .Size = 0};
diff --git a/zenstore/compactcas.cpp b/zenstore/compactcas.cpp
index 2d48265f7..65f959a0e 100644
--- a/zenstore/compactcas.cpp
+++ b/zenstore/compactcas.cpp
@@ -1894,8 +1894,12 @@ TEST_CASE("compactcas.threadedinsert")
}
}
-TEST_CASE("compactcas.migrate.large.data" * doctest::skip(true))
+TEST_CASE("compactcas.migrate.large.data") // * doctest::skip(true))
{
+ if (true)
+ {
+ return;
+ }
const char* BigDataPath = "D:\\zen-data\\dc4-zen-cache-t\\cas";
std::filesystem::path TobsBasePath = GetBasePath(BigDataPath, "tobs");
std::filesystem::path SobsBasePath = GetBasePath(BigDataPath, "sobs");
diff --git a/zenstore/include/zenstore/blockstore.h b/zenstore/include/zenstore/blockstore.h
index 34c475fb6..000395fb9 100644
--- a/zenstore/include/zenstore/blockstore.h
+++ b/zenstore/include/zenstore/blockstore.h
@@ -64,6 +64,8 @@ struct BlockStoreDiskLocation
inline uint64_t GetSize() const { return m_Size; }
+ inline auto operator<=>(const BlockStoreDiskLocation& Rhs) const = default;
+
private:
inline void Init(uint32_t BlockIndex, uint64_t Offset, uint64_t Size)
{