From bd0cafa33f819e332c3d40a36c4f0090fe35fc6d Mon Sep 17 00:00:00 2001 From: David Markowitz Date: Tue, 4 Jun 2024 21:58:38 -0700 Subject: [PATCH] testing works --- dGame/Character.h | 4 ++++ .../dComponentsTests/SavingTests.cpp | 20 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/dGame/Character.h b/dGame/Character.h index 4a86f64b..0f41c634 100644 --- a/dGame/Character.h +++ b/dGame/Character.h @@ -460,6 +460,10 @@ public: User* GetParentUser() const { return m_ParentUser; } + void _doQuickXMLDataParse() { DoQuickXMLDataParse(); } + + void _setXmlData(const std::string& xmlData) { m_XMLData = xmlData; } + private: void UpdateInfoFromDatabase(); /** diff --git a/tests/dGameTests/dComponentsTests/SavingTests.cpp b/tests/dGameTests/dComponentsTests/SavingTests.cpp index 97e7002d..59b865c1 100644 --- a/tests/dGameTests/dComponentsTests/SavingTests.cpp +++ b/tests/dGameTests/dComponentsTests/SavingTests.cpp @@ -8,14 +8,21 @@ protected: std::unique_ptr entity; std::unique_ptr character; tinyxml2::XMLDocument doc; + tinyxml2::XMLPrinter printer{0, true, 0}; + void SetUp() override { SetUpDependencies(); + Game::zoneManager->LoadZone(LWOZONEID(1800, 2, 0)); + GameDependenciesTest::info.lot = 1; entity = std::make_unique(1, GameDependenciesTest::info); character = std::make_unique(1, nullptr); doc.LoadFile("./test_xml_data.xml"); entity->SetCharacter(character.get()); - character->_setXmlDoc(doc); character->SetEntity(entity.get()); + doc.Print(&printer); + character->_setXmlData(printer.CStr()); + doc.Clear(); + character->_doQuickXMLDataParse(); } void TearDown() override { @@ -27,5 +34,16 @@ protected: }; TEST_F(SavingTest, EntityLevelTest) { + doc.Print(&printer); + std::string xmlDataOriginal(printer.CStr()); + doc.Clear(); character->SaveXMLToDatabase(); + doc.Print(&printer); + std::string xmlDataModified(printer.CStr()); + doc.Clear(); + std::ofstream oldXml("./test_xml_data_original.xml"); + std::ofstream newXml("./test_xml_data_new.xml"); + oldXml << xmlDataOriginal; + newXml << xmlDataModified; + LOG("Component count: %i Same: %i", entity->GetComponents().size(), xmlDataOriginal == xmlDataModified); }