Intensive refactor of DRAMSys project structure and CMakeFiles
This commit is contained in:
38
tests/tests_util/test_json.cpp
Normal file
38
tests/tests_util/test_json.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <DRAMSys/util/json.h>
|
||||
|
||||
class JsonTest : public ::testing::Test {
|
||||
protected:
|
||||
virtual void SetUp()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void TearDown()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(JsonTest, Test)
|
||||
{
|
||||
auto in = json_t::parse(R"(
|
||||
{
|
||||
"test": 5,
|
||||
"null": null
|
||||
}
|
||||
)");
|
||||
|
||||
std::optional<int> opt_in;
|
||||
std::optional<int> opt_null;
|
||||
std::optional<int> opt_nil;
|
||||
|
||||
in["test"].get_to(opt_in);
|
||||
in["null"].get_to(opt_null);
|
||||
in["nil"].get_to(opt_nil);
|
||||
|
||||
ASSERT_TRUE(opt_in.has_value());
|
||||
ASSERT_EQ(*opt_in, 5);
|
||||
|
||||
ASSERT_FALSE(opt_null.has_value());
|
||||
ASSERT_FALSE(opt_nil.has_value());
|
||||
};
|
||||
Reference in New Issue
Block a user