1#include <gtest/gtest.h>
44 EXPECT_DOUBLE_EQ(obj.
get(
"c").
value, 2.99792458e10);
45 EXPECT_EQ(obj.
get(
"c").
unit,
"cm / s");
55 EXPECT_DOUBLE_EQ(obj[
"c"].value, 2.99792458e10);
56 EXPECT_EQ(obj[
"c"].unit,
"cm / s");
57 EXPECT_DOUBLE_EQ(obj[
"c"].uncertainty, 0.0);
58 EXPECT_EQ(obj[
"c"].reference,
"CODATA2022");
67 EXPECT_TRUE(obj.
has(
"c"));
68 EXPECT_FALSE(obj.
has(
"c4"));
69 EXPECT_TRUE(obj.
has(
"hbar"));
74 std::set<std::string> checkKeys;
75 checkKeys.insert(
"c");
76 checkKeys.insert(
"wienK");
77 checkKeys.insert(
"hbar");
78 checkKeys.insert(
"g_h");
79 checkKeys.insert(
"R_sun");
81 std::set<std::string> keys = obj.
keys();
83 for (
const auto& key : checkKeys) {
84 bool found = keys.find(key) != keys.end();
88 std::set<std::string> checkBadKeys;
89 checkBadKeys.insert(
"c4");
90 checkBadKeys.insert(
"wienK4");
91 checkBadKeys.insert(
"hbar4");
92 checkBadKeys.insert(
"g_h4");
93 checkBadKeys.insert(
"R_sun4");
95 for (
const auto& key : checkBadKeys) {
96 bool found = keys.find(key) != keys.end();
103 std::ostringstream os;
106 std::string expected =
"<speed of light in vacuum: 2.99792e+10±0 cm / s (CODATA2022)>\n";
108 EXPECT_EQ(os.str(), expected);
Test suite for the const class.
Class to manage a collection of constants.
bool has(const std::string &key) const
Check if a constant exists by key.
std::set< std::string > keys() const
Get a list of all constant keys.
static Constants & getInstance()
get instance of constants singleton
Constant get(const std::string &key) const
Get a constant by key.
TEST_F(constTest, DefaultConstructor)
const std::string unit
Unit of the constant.
const double uncertainty
Uncertainty in the constant's value.
const std::string reference
Reference for the constant's value.
const double value
Value of the constant.