Use GTest; resolves #34 (#90)

This commit is contained in:
liuzicheng1987
2024-04-22 23:12:35 +02:00
committed by GitHub
parent bf1c9bea36
commit 325d163196
682 changed files with 1123 additions and 4799 deletions
+4 -11
View File
@@ -1,5 +1,3 @@
#include "test_std_ref.hpp"
#include <functional>
#include <iostream>
#include <rfl.hpp>
@@ -7,29 +5,24 @@
#include <source_location>
#include <string>
#include <gtest/gtest.h>
namespace test_std_ref {
struct StdRefStruct {
std::reference_wrapper<int> a;
};
void test() {
std::cout << std::source_location::current().function_name() << std::endl;
TEST(json, test_std_ref) {
int i = 10;
StdRefStruct struct_ = {.a = std::ref(i)};
const auto json_string = rfl::json::write(struct_);
const std::string& expected = R"({"a":10})";
if (json_string != expected) {
std::cout << "Test failed on write. Expected:" << std::endl
EXPECT_EQ(json_string, expected) << "Test failed on write. Expected:" << std::endl
<< expected << std::endl
<< "Got: " << std::endl
<< json_string << std::endl
<< std::endl;
return;
}
std::cout << "OK" << std::endl << std::endl;
}
} // namespace test_std_ref