App/Toponaming: Fix Reader tests for Linux

This commit is contained in:
Chris Hennes
2023-04-05 16:44:58 -05:00
committed by Chris Hennes
parent 0d8cce1be5
commit e461f1bc27
2 changed files with 18 additions and 35 deletions

View File

@@ -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)

View File

@@ -8,7 +8,6 @@
#include <filesystem>
#include <fmt/format.h>
#include <fstream>
#include <random>
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<Base::XMLReader>(_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<char, numChars> charset {
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"};
std::uniform_int_distribution<int> 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<Base::XMLReader> _reader;
fs::path _tempDir;