OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "modules/payments/PaymentsValidators.h" | 5 #include "modules/payments/PaymentsValidators.h" |
6 | 6 |
7 #include <ostream> // NOLINT | 7 #include <ostream> // NOLINT |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "wtf/text/WTFString.h" | 9 #include "wtf/text/WTFString.h" |
10 | 10 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 std::ostream& operator<<(std::ostream& out, const TestCase& testCase) { | 96 std::ostream& operator<<(std::ostream& out, const TestCase& testCase) { |
97 out << "'" << testCase.input << "' is expected to be " | 97 out << "'" << testCase.input << "' is expected to be " |
98 << (testCase.expectedValid ? "valid" : "invalid"); | 98 << (testCase.expectedValid ? "valid" : "invalid"); |
99 return out; | 99 return out; |
100 } | 100 } |
101 | 101 |
102 class PaymentsAmountValidatorTest : public testing::TestWithParam<TestCase> {}; | 102 class PaymentsAmountValidatorTest : public testing::TestWithParam<TestCase> {}; |
103 | 103 |
104 TEST_P(PaymentsAmountValidatorTest, IsValidAmountFormat) { | 104 TEST_P(PaymentsAmountValidatorTest, IsValidAmountFormat) { |
105 String errorMessage; | 105 String errorMessage; |
106 EXPECT_EQ(GetParam().expectedValid, PaymentsValidators::isValidAmountFormat( | 106 EXPECT_EQ( |
107 GetParam().input, &errorMessage)) | 107 GetParam().expectedValid, |
| 108 PaymentsValidators::isValidAmountFormat(GetParam().input, &errorMessage)) |
108 << errorMessage; | 109 << errorMessage; |
109 EXPECT_EQ(GetParam().expectedValid, errorMessage.isEmpty()) << errorMessage; | 110 EXPECT_EQ(GetParam().expectedValid, errorMessage.isEmpty()) << errorMessage; |
110 | 111 |
111 EXPECT_EQ(GetParam().expectedValid, | 112 EXPECT_EQ(GetParam().expectedValid, |
112 PaymentsValidators::isValidAmountFormat(GetParam().input, nullptr)); | 113 PaymentsValidators::isValidAmountFormat(GetParam().input, nullptr)); |
113 } | 114 } |
114 | 115 |
115 INSTANTIATE_TEST_CASE_P( | 116 INSTANTIATE_TEST_CASE_P( |
116 Amounts, | 117 Amounts, |
117 PaymentsAmountValidatorTest, | 118 PaymentsAmountValidatorTest, |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 ShippingAddressTestCase("US", "", "", true), | 269 ShippingAddressTestCase("US", "", "", true), |
269 // Invalid shipping addresses | 270 // Invalid shipping addresses |
270 ShippingAddressTestCase("", "", "", false), | 271 ShippingAddressTestCase("", "", "", false), |
271 ShippingAddressTestCase("InvalidCountryCode", "", "", false), | 272 ShippingAddressTestCase("InvalidCountryCode", "", "", false), |
272 ShippingAddressTestCase("US", "InvalidLanguageCode", "", false), | 273 ShippingAddressTestCase("US", "InvalidLanguageCode", "", false), |
273 ShippingAddressTestCase("US", "en", "InvalidScriptCode", false), | 274 ShippingAddressTestCase("US", "en", "InvalidScriptCode", false), |
274 ShippingAddressTestCase("US", "", "Latn", false))); | 275 ShippingAddressTestCase("US", "", "Latn", false))); |
275 | 276 |
276 } // namespace | 277 } // namespace |
277 } // namespace blink | 278 } // namespace blink |
OLD | NEW |