From c893e0b72b718a851dde39ef1e5c5a1cb0b1c780 Mon Sep 17 00:00:00 2001 From: JosiahWI <41302989+JosiahWI@users.noreply.github.com> Date: Wed, 28 Aug 2024 08:36:02 -0500 Subject: [PATCH] Convert nodedef tests to Catch2 (#15045) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Lars Müller <34514239+appgurueu@users.noreply.github.com> --- src/unittest/test_nodedef.cpp | 36 +++++++++-------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/src/unittest/test_nodedef.cpp b/src/unittest/test_nodedef.cpp index acf669783..85dadd17d 100644 --- a/src/unittest/test_nodedef.cpp +++ b/src/unittest/test_nodedef.cpp @@ -17,38 +17,22 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "test.h" - -#include - #include "gamedef.h" #include "nodedef.h" #include "network/networkprotocol.h" -class TestNodeDef : public TestBase -{ -public: - TestNodeDef() { TestManager::registerTestModule(this); } - const char *getName() { return "TestNodeDef"; } +#include - void runTests(IGameDef *gamedef); +#include +#include - void testContentFeaturesSerialization(); -}; -static TestNodeDef g_test_instance; - -void TestNodeDef::runTests(IGameDef *gamedef) -{ - TEST(testContentFeaturesSerialization); -} - -//////////////////////////////////////////////////////////////////////////////// - -void TestNodeDef::testContentFeaturesSerialization() +TEST_CASE("Given a node definition, " + "when we serialize and then deserialize it, " + "then the deserialized one should be equal to the original.", + "[nodedef]") { ContentFeatures f; - f.name = "default:stone"; for (TileDef &tiledef : f.tiledef) tiledef.name = "default_stone.png"; @@ -56,12 +40,10 @@ void TestNodeDef::testContentFeaturesSerialization() std::ostringstream os(std::ios::binary); f.serialize(os, LATEST_PROTOCOL_VERSION); - // verbosestream<<"Test ContentFeatures size: "<