File: test_std_ref.cpp

package info (click to toggle)
reflect-cpp 0.21.0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,128 kB
  • sloc: cpp: 50,336; python: 139; makefile: 30; sh: 3
file content (27 lines) | stat: -rw-r--r-- 666 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <functional>
#include <iostream>
#include <rfl.hpp>
#include <rfl/json.hpp>
#include <string>

#include <gtest/gtest.h>

namespace test_std_ref {

struct StdRefStruct {
  std::reference_wrapper<int> a;
};

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})";
  EXPECT_EQ(json_string, expected) << "Test failed on write. Expected:" << std::endl
              << expected << std::endl
              << "Got: " << std::endl
              << json_string << std::endl
              << std::endl;
}
}  // namespace test_std_ref