| 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 "platform/wtf/text/WTFString.h" | 8 #include "platform/wtf/text/WTFString.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 std::ostream& operator<<(std::ostream& out, const TestCase& test_case) { | 99 std::ostream& operator<<(std::ostream& out, const TestCase& test_case) { |
| 100 out << "'" << test_case.input << "' is expected to be " | 100 out << "'" << test_case.input << "' is expected to be " |
| 101 << (test_case.expected_valid ? "valid" : "invalid"); | 101 << (test_case.expected_valid ? "valid" : "invalid"); |
| 102 return out; | 102 return out; |
| 103 } | 103 } |
| 104 | 104 |
| 105 class PaymentsAmountValidatorTest : public testing::TestWithParam<TestCase> {}; | 105 class PaymentsAmountValidatorTest : public testing::TestWithParam<TestCase> {}; |
| 106 | 106 |
| 107 TEST_P(PaymentsAmountValidatorTest, IsValidAmountFormat) { | 107 TEST_P(PaymentsAmountValidatorTest, IsValidAmountFormat) { |
| 108 String error_message; | 108 String error_message; |
| 109 EXPECT_EQ(GetParam().expected_valid, PaymentsValidators::IsValidAmountFormat( | 109 EXPECT_EQ(GetParam().expected_valid, |
| 110 GetParam().input, &error_message)) | 110 PaymentsValidators::IsValidAmountFormat( |
| 111 GetParam().input, "test value", &error_message)) |
| 111 << error_message; | 112 << error_message; |
| 112 EXPECT_EQ(GetParam().expected_valid, error_message.IsEmpty()) | 113 EXPECT_EQ(GetParam().expected_valid, error_message.IsEmpty()) |
| 113 << error_message; | 114 << error_message; |
| 114 | 115 |
| 115 EXPECT_EQ(GetParam().expected_valid, | 116 EXPECT_EQ(GetParam().expected_valid, |
| 116 PaymentsValidators::IsValidAmountFormat(GetParam().input, nullptr)); | 117 PaymentsValidators::IsValidAmountFormat(GetParam().input, |
| 118 "test value", nullptr)); |
| 117 } | 119 } |
| 118 | 120 |
| 119 INSTANTIATE_TEST_CASE_P( | 121 INSTANTIATE_TEST_CASE_P( |
| 120 Amounts, | 122 Amounts, |
| 121 PaymentsAmountValidatorTest, | 123 PaymentsAmountValidatorTest, |
| 122 testing::Values(TestCase("0", true), | 124 testing::Values(TestCase("0", true), |
| 123 TestCase("-0", true), | 125 TestCase("-0", true), |
| 124 TestCase("1", true), | 126 TestCase("1", true), |
| 125 TestCase("10", true), | 127 TestCase("10", true), |
| 126 TestCase("-3", true), | 128 TestCase("-3", true), |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 ShippingAddressTestCase("US", "", "", true), | 278 ShippingAddressTestCase("US", "", "", true), |
| 277 // Invalid shipping addresses | 279 // Invalid shipping addresses |
| 278 ShippingAddressTestCase("", "", "", false), | 280 ShippingAddressTestCase("", "", "", false), |
| 279 ShippingAddressTestCase("InvalidCountryCode", "", "", false), | 281 ShippingAddressTestCase("InvalidCountryCode", "", "", false), |
| 280 ShippingAddressTestCase("US", "InvalidLanguageCode", "", false), | 282 ShippingAddressTestCase("US", "InvalidLanguageCode", "", false), |
| 281 ShippingAddressTestCase("US", "en", "InvalidScriptCode", false), | 283 ShippingAddressTestCase("US", "en", "InvalidScriptCode", false), |
| 282 ShippingAddressTestCase("US", "", "Latn", false))); | 284 ShippingAddressTestCase("US", "", "Latn", false))); |
| 283 | 285 |
| 284 } // namespace | 286 } // namespace |
| 285 } // namespace blink | 287 } // namespace blink |
| OLD | NEW |