feat(const): added << operator to constant so that constants

also added tests for the stream operator
This commit is contained in:
2025-02-12 10:38:22 -05:00
parent 7dfedcdbe2
commit 98f4474786
3 changed files with 22 additions and 4 deletions

View File

@@ -4,6 +4,7 @@
#include <string>
#include <vector>
#include <set>
#include <sstream>
std::string RELATIVE_PATH = "../src/resources/const/const.dat";
/**
@@ -22,7 +23,6 @@ protected:
void SetUp() override {
// Create a DObject with initial data and metadata
constants initializedConstants(RELATIVE_PATH);
std::cout << "speed of light (tests) " << initializedConstants["c"].value << std::endl;
}
};
@@ -88,7 +88,6 @@ TEST_F(constTest, Keys) {
for (const auto& key : checkKeys) {
bool found = keys.find(key) != keys.end();
std::cout << "FOUND SIMILAR KEY " << key << ", found: " << found << std::endl;
EXPECT_TRUE(found);
}
@@ -101,7 +100,16 @@ TEST_F(constTest, Keys) {
for (const auto& key : checkBadKeys) {
bool found = keys.find(key) != keys.end();
std::cout << "FOUND BAD KEY " << key << ", found: " << found << std::endl;
EXPECT_FALSE(found);
}
}
TEST_F(constTest, Output) {
constants obj(RELATIVE_PATH);
std::ostringstream os;
os << obj.get("c");
std::string expected = "<speed of light in vacuum: 2.99792e+10±0 cm / s (CODATA2022)>\n";
EXPECT_EQ(os.str(), expected);
}