xref: /llvm-project/clang-tools-extra/clangd/unittests/xpc/ConversionTests.cpp (revision b804eef09052cf40e79aa2ed8a23f2f39e2dda1b)
1*b804eef0SSam McCall //===-- ConversionTests.cpp  --------------------------*- C++ -*-----------===//
2*b804eef0SSam McCall //
3*b804eef0SSam McCall // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*b804eef0SSam McCall // See https://llvm.org/LICENSE.txt for license information.
5*b804eef0SSam McCall // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*b804eef0SSam McCall //
7*b804eef0SSam McCall //===----------------------------------------------------------------------===//
8*b804eef0SSam McCall 
9*b804eef0SSam McCall #include "xpc/Conversion.h"
10*b804eef0SSam McCall #include "gtest/gtest.h"
11*b804eef0SSam McCall 
12*b804eef0SSam McCall #include <limits>
13*b804eef0SSam McCall 
14*b804eef0SSam McCall namespace clang {
15*b804eef0SSam McCall namespace clangd {
16*b804eef0SSam McCall namespace {
17*b804eef0SSam McCall 
18*b804eef0SSam McCall using namespace llvm;
19*b804eef0SSam McCall 
TEST(JsonXpcConversionTest,JsonToXpcToJson)20*b804eef0SSam McCall TEST(JsonXpcConversionTest, JsonToXpcToJson) {
21*b804eef0SSam McCall 
22*b804eef0SSam McCall   for (auto &testcase :
23*b804eef0SSam McCall        {json::Value(false), json::Value(3.14), json::Value(42),
24*b804eef0SSam McCall         json::Value(-100), json::Value("foo"), json::Value(""),
25*b804eef0SSam McCall         json::Value("123"), json::Value(" "),
26*b804eef0SSam McCall         json::Value{true, "foo", nullptr, 42},
27*b804eef0SSam McCall         json::Value(json::Object{
28*b804eef0SSam McCall             {"a", true}, {"b", "foo"}, {"c", nullptr}, {"d", 42}})}) {
29*b804eef0SSam McCall     EXPECT_TRUE(testcase == xpcToJson(jsonToXpc(testcase))) << testcase;
30*b804eef0SSam McCall   }
31*b804eef0SSam McCall }
32*b804eef0SSam McCall 
33*b804eef0SSam McCall } // namespace
34*b804eef0SSam McCall } // namespace clangd
35*b804eef0SSam McCall } // namespace clang
36