#include "tools/json_schema_compiler/test/crossref.h"
#include <memory>
#include <utility>
#include <vector>
#include "base/values.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "tools/json_schema_compiler/test/simple_api.h"
namespace crossref = test::api::crossref;
namespace simple_api = test::api::simple_api;
namespace {
base::Value::Dict CreateTestTypeValue() { … }
}
TEST(…) {
base::Value::Dict crossref_orig;
crossref_orig.Set("testType", CreateTestTypeValue());
crossref_orig.Set("testEnumRequired", "one");
crossref_orig.Set("testEnumOptional", "two");
auto crossref_type = crossref::CrossrefType::FromValue(crossref_orig);
ASSERT_TRUE(…);
EXPECT_EQ(…);
EXPECT_EQ(…);
EXPECT_EQ(…);
EXPECT_EQ(…);
EXPECT_EQ(…);
EXPECT_EQ(…);
EXPECT_EQ(…);
base::Value::Dict crossref_value = crossref_type->ToValue();
EXPECT_EQ(…);
EXPECT_EQ(…);
}
TEST(…) {
base::Value::List params_value;
params_value.Append(CreateTestTypeValue());
std::optional<crossref::TestTypeOptionalParam::Params> params(
crossref::TestTypeOptionalParam::Params::Create(params_value));
EXPECT_TRUE(…);
EXPECT_TRUE(…);
EXPECT_EQ(…);
}
TEST(…) {
base::Value::List params_value;
base::Value::Dict test_type_value = CreateTestTypeValue();
test_type_value.Remove("number");
params_value.Append(std::move(test_type_value));
std::optional<crossref::TestTypeOptionalParam::Params> params(
crossref::TestTypeOptionalParam::Params::Create(params_value));
EXPECT_FALSE(…);
}
TEST(…) {
base::Value::Dict value = CreateTestTypeValue();
auto test_type = simple_api::TestType::FromValue(value);
ASSERT_TRUE(…);
base::Value::List results =
crossref::GetTestType::Results::Create(*test_type);
ASSERT_EQ(…);
EXPECT_EQ(…);
}
TEST(…) {
{
base::Value::List params_value;
base::Value::Dict param_object_value;
param_object_value.Set("testType", CreateTestTypeValue());
param_object_value.Set("boolean", true);
params_value.Append(std::move(param_object_value));
std::optional<crossref::TestTypeInObject::Params> params(
crossref::TestTypeInObject::Params::Create(params_value));
EXPECT_TRUE(…);
EXPECT_TRUE(…);
EXPECT_TRUE(…);
EXPECT_EQ(…);
}
{
base::Value::List params_value;
base::Value::Dict param_object_value;
param_object_value.Set("boolean", true);
params_value.Append(std::move(param_object_value));
std::optional<crossref::TestTypeInObject::Params> params(
crossref::TestTypeInObject::Params::Create(params_value));
EXPECT_TRUE(…);
EXPECT_FALSE(…);
EXPECT_TRUE(…);
}
{
base::Value::List params_value;
base::Value::Dict param_object_value;
param_object_value.Set("testType", "invalid");
param_object_value.Set("boolean", true);
params_value.Append(std::move(param_object_value));
std::optional<crossref::TestTypeInObject::Params> params(
crossref::TestTypeInObject::Params::Create(params_value));
EXPECT_FALSE(…);
}
{
base::Value::List params_value;
base::Value::Dict param_object_value;
param_object_value.Set("testType", CreateTestTypeValue());
params_value.Append(std::move(param_object_value));
std::optional<crossref::TestTypeInObject::Params> params(
crossref::TestTypeInObject::Params::Create(params_value));
EXPECT_FALSE(…);
}
}