| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "extensions/renderer/api_invocation_errors.h" | 5 #include "extensions/renderer/api_invocation_errors.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 namespace extensions { | 9 namespace extensions { |
| 10 namespace api_errors { | 10 namespace api_errors { |
| 11 | 11 |
| 12 // Tests chaining errors for more complicated errors. More of a set of example | 12 // Tests chaining errors for more complicated errors. More of a set of example |
| 13 // strings than a test of the logic itself (which is pretty simple). | 13 // strings than a test of the logic itself (which is pretty simple). |
| 14 TEST(APIInvocationErrors, ChainedErrors) { | 14 TEST(APIInvocationErrors, ChainedErrors) { |
| 15 EXPECT_EQ("Error at index 0: Invalid type: expected string, found integer.", | 15 EXPECT_EQ("Error at index 0: Invalid type: expected string, found integer.", |
| 16 IndexError(0, InvalidType(kTypeString, kTypeInteger))); | 16 IndexError(0, InvalidType(kTypeString, kTypeInteger))); |
| 17 EXPECT_EQ( | 17 EXPECT_EQ( |
| 18 "Error at property 'foo': Invalid type: expected string, found integer.", | 18 "Error at property 'foo': Invalid type: expected string, found integer.", |
| 19 PropertyError("foo", InvalidType(kTypeString, kTypeInteger))); | 19 PropertyError("foo", InvalidType(kTypeString, kTypeInteger))); |
| 20 EXPECT_EQ( | 20 EXPECT_EQ( |
| 21 "Error at property 'foo': Error at index 1: " | 21 "Error at property 'foo': Error at index 1: " |
| 22 "Invalid type: expected string, found integer.", | 22 "Invalid type: expected string, found integer.", |
| 23 PropertyError("foo", | 23 PropertyError("foo", |
| 24 IndexError(1, InvalidType(kTypeString, kTypeInteger)))); | 24 IndexError(1, InvalidType(kTypeString, kTypeInteger)))); |
| 25 |
| 26 EXPECT_EQ( |
| 27 "Error at parameter 'foo': Invalid type: expected string, found integer.", |
| 28 ArgumentError("foo", InvalidType(kTypeString, kTypeInteger))); |
| 29 EXPECT_EQ( |
| 30 "Error at parameter 'foo': Error at index 0: " |
| 31 "Invalid type: expected string, found integer.", |
| 32 ArgumentError("foo", |
| 33 IndexError(0, InvalidType(kTypeString, kTypeInteger)))); |
| 25 } | 34 } |
| 26 | 35 |
| 27 } // namespace api_errors | 36 } // namespace api_errors |
| 28 } // namespace extensions | 37 } // namespace extensions |
| OLD | NEW |