diff --git a/tests/src/App/StringHasher.cpp b/tests/src/App/StringHasher.cpp index db5e77222f..d534816f8a 100644 --- a/tests/src/App/StringHasher.cpp +++ b/tests/src/App/StringHasher.cpp @@ -805,8 +805,8 @@ TEST_F(StringIDRefTest, operatorLess) // Arrange auto emptySIDA = App::StringIDRef(); auto emptySIDB = App::StringIDRef(); - auto lowID = App::StringIDRef(new App::StringID{1, nullptr}); - auto highID = App::StringIDRef(new App::StringID{2, nullptr}); + auto lowID = App::StringIDRef(new App::StringID {1, nullptr}); + auto highID = App::StringIDRef(new App::StringID {2, nullptr}); // Act & Assert EXPECT_FALSE(emptySIDA < emptySIDB); @@ -824,9 +824,9 @@ TEST_F(StringIDRefTest, operatorEquality) // Arrange auto emptySIDA = App::StringIDRef(); auto emptySIDB = App::StringIDRef(); - auto nonEmptyA = App::StringIDRef(new App::StringID{1, nullptr}); - auto nonEmptyB = App::StringIDRef(new App::StringID{1, nullptr}); - auto nonEmptyOther = App::StringIDRef(new App::StringID{2, nullptr}); + auto nonEmptyA = App::StringIDRef(new App::StringID {1, nullptr}); + auto nonEmptyB = App::StringIDRef(new App::StringID {1, nullptr}); + auto nonEmptyOther = App::StringIDRef(new App::StringID {2, nullptr}); // Act & Assert EXPECT_TRUE(emptySIDA == emptySIDB); @@ -840,9 +840,9 @@ TEST_F(StringIDRefTest, operatorInequality) // Arrange auto emptySIDA = App::StringIDRef(); auto emptySIDB = App::StringIDRef(); - auto nonEmptyA = App::StringIDRef(new App::StringID{1, nullptr}); - auto nonEmptyB = App::StringIDRef(new App::StringID{1, nullptr}); - auto nonEmptyOther = App::StringIDRef(new App::StringID{2, nullptr}); + auto nonEmptyA = App::StringIDRef(new App::StringID {1, nullptr}); + auto nonEmptyB = App::StringIDRef(new App::StringID {1, nullptr}); + auto nonEmptyOther = App::StringIDRef(new App::StringID {2, nullptr}); // Act & Assert EXPECT_FALSE(emptySIDA != emptySIDB); @@ -855,7 +855,7 @@ TEST_F(StringIDRefTest, booleanConversion) { // Arrange auto emptySID = App::StringIDRef(); - auto nonEmpty = App::StringIDRef(new App::StringID{1, nullptr}); + auto nonEmpty = App::StringIDRef(new App::StringID {1, nullptr}); // Act & Assert EXPECT_FALSE(emptySID); @@ -957,8 +957,8 @@ TEST_F(StringIDRefTest, isBinary) { // Arrange auto nothing = App::StringIDRef(); - auto binary = App::StringIDRef(new App::StringID{1, nullptr, App::StringID::Flag::Binary}); - auto nonBinary = App::StringIDRef(new App::StringID{1, nullptr, App::StringID::Flag::None}); + auto binary = App::StringIDRef(new App::StringID {1, nullptr, App::StringID::Flag::Binary}); + auto nonBinary = App::StringIDRef(new App::StringID {1, nullptr, App::StringID::Flag::None}); // Act & Assert EXPECT_FALSE(nothing.isBinary()); @@ -970,8 +970,8 @@ TEST_F(StringIDRefTest, isHashed) { // Arrange auto nothing = App::StringIDRef(); - auto hashed = App::StringIDRef(new App::StringID{1, nullptr, App::StringID::Flag::Hashed}); - auto nonHashed = App::StringIDRef(new App::StringID{1, nullptr, App::StringID::Flag::None}); + auto hashed = App::StringIDRef(new App::StringID {1, nullptr, App::StringID::Flag::Hashed}); + auto nonHashed = App::StringIDRef(new App::StringID {1, nullptr, App::StringID::Flag::None}); // Act & Assert EXPECT_FALSE(nothing.isHashed()); @@ -1004,7 +1004,7 @@ TEST_F(StringIDRefTest, getPyObject) // Assert EXPECT_TRUE(PyObject_TypeCheck(pyObject.ptr(), &App::StringIDPy::Type)); - EXPECT_TRUE(Py_IsNone(none.ptr())); + EXPECT_EQ(none.ptr(), Py_None); } TEST_F(StringIDRefTest, mark) diff --git a/tests/src/Base/Reader.cpp b/tests/src/Base/Reader.cpp index 47b5b926c9..64fbc92e67 100644 --- a/tests/src/Base/Reader.cpp +++ b/tests/src/Base/Reader.cpp @@ -8,7 +8,6 @@ #include #include #include -#include namespace fs = std::filesystem; @@ -19,13 +18,15 @@ protected: { xercesc_3_2::XMLPlatformUtils::Initialize(); _tempDir = fs::temp_directory_path(); - std::string filename = uniqueName() + ".xml"; + std::string filename = "unit_test_Reader.xml"; _tempFile = _tempDir / filename; } void TearDown() override { - std::filesystem::remove(_tempFile); + if (std::filesystem::exists(_tempFile)) { + std::filesystem::remove(_tempFile); + } } void givenDataAsXMLStream(const std::string& data) @@ -40,29 +41,11 @@ protected: _reader = std::make_unique(_tempFile.string().c_str(), inputStream); } - /// Generate a random, probably-unique 16-character alphanumeric filename. - static std::string uniqueName() - { - constexpr size_t filenameLength {16}; - static std::default_random_engine _generator; - auto random_char = []() -> char { - constexpr int numChars {63}; - std::array charset { - "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"}; - std::uniform_int_distribution distribution(0, numChars - 1); - return charset.at(distribution(_generator)); - }; - std::string str(filenameLength, 0); - std::generate_n(str.begin(), filenameLength, random_char); - return str; - } - Base::XMLReader* Reader() { return _reader.get(); } - private: std::unique_ptr _reader; fs::path _tempDir;