Skip to content

Commit

Permalink
json string test
Browse files Browse the repository at this point in the history
  • Loading branch information
akhoroshev committed Feb 9, 2025
1 parent 04582f3 commit e49e78c
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions core/src/logging/json_string_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include <userver/logging/json_string.hpp>

#include <gtest/gtest.h>

#include <userver/utest/assert_macros.hpp>

USERVER_NAMESPACE_BEGIN

TEST(JsonString, ConstructFromJson) {
using formats::literals::operator""_json;

auto json = R"({
"a": "foo",
"b": {
"c": "d",
"e": [
1,
2
]
}
})"_json;

logging::JsonString json_string(json);

EXPECT_EQ(json_string.Value(), R"({"a":"foo","b":{"c":"d","e":[1,2]}})");
}

TEST(JsonString, ConstructFromString) {
std::string json = R"({"a":"foo",
"b":{"c":"d","e":
[1,2]}})";

logging::JsonString json_string(json);

EXPECT_EQ(json_string.Value(), R"({"a":"foo","b":{"c":"d","e":[1,2]}})");
}

TEST(JsonString, ConstructNull) {
logging::JsonString json_string;

EXPECT_EQ(json_string.Value(), R"(null)");
}

USERVER_NAMESPACE_END

0 comments on commit e49e78c

Please sign in to comment.