| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "tools/json_schema_compiler/test/choices.h" | 5 #include "tools/json_schema_compiler/test/choices.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 using namespace test::api::choices; | 9 using namespace test::api::choices; |
| 10 | 10 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 ObjectWithChoices::Params::Create(*params_value)); | 109 ObjectWithChoices::Params::Create(*params_value)); |
| 110 EXPECT_FALSE(params.get()); | 110 EXPECT_FALSE(params.get()); |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 TEST(JsonSchemaCompilerChoicesTest, ReturnChoices) { | 114 TEST(JsonSchemaCompilerChoicesTest, ReturnChoices) { |
| 115 { | 115 { |
| 116 std::vector<int> integers; | 116 std::vector<int> integers; |
| 117 integers.push_back(1); | 117 integers.push_back(1); |
| 118 integers.push_back(2); | 118 integers.push_back(2); |
| 119 scoped_ptr<Value> array_result(ReturnChoices::Result::Create(integers)); | 119 scoped_ptr<ListValue> array_results( |
| 120 ListValue* list = NULL; | 120 ReturnChoices::Result::Create(integers)); |
| 121 EXPECT_TRUE(array_result->GetAsList(&list)); | 121 |
| 122 EXPECT_EQ((size_t) 2, list->GetSize()); | 122 ListValue expected; |
| 123 int temp; | 123 ListValue* expected_argument = new ListValue(); |
| 124 EXPECT_TRUE(list->GetInteger(0, &temp)); | 124 expected_argument->Append(Value::CreateIntegerValue(1)); |
| 125 EXPECT_EQ(1, temp); | 125 expected_argument->Append(Value::CreateIntegerValue(2)); |
| 126 EXPECT_TRUE(list->GetInteger(1, &temp)); | 126 expected.Append(expected_argument); |
| 127 EXPECT_EQ(2, temp); | 127 EXPECT_TRUE(array_results->Equals(&expected)); |
| 128 } | 128 } |
| 129 { | 129 { |
| 130 scoped_ptr<Value> single_result(ReturnChoices::Result::Create(5)); | 130 scoped_ptr<ListValue> integer_results(ReturnChoices::Result::Create(5)); |
| 131 int temp; | 131 ListValue expected; |
| 132 EXPECT_TRUE(single_result->GetAsInteger(&temp)); | 132 expected.Append(Value::CreateIntegerValue(5)); |
| 133 EXPECT_EQ(5, temp); | 133 EXPECT_TRUE(integer_results->Equals(&expected)); |
| 134 } | 134 } |
| 135 } | 135 } |
| OLD | NEW |