Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Unified Diff: third_party/WebKit/Source/modules/payments/PaymentsValidatorsTest.cpp

Issue 2410143003: Add currencySystem field to PaymentCurrencyAmount (Closed)
Patch Set: Add currencySystem field to PaymentCurrencyAmount Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/payments/PaymentsValidatorsTest.cpp
diff --git a/third_party/WebKit/Source/modules/payments/PaymentsValidatorsTest.cpp b/third_party/WebKit/Source/modules/payments/PaymentsValidatorsTest.cpp
index e2d904bd83430a1b235c17ba84de5235ff5e09a6..8e500768de756dad3295db7879b6d5a4b667e48f 100644
--- a/third_party/WebKit/Source/modules/payments/PaymentsValidatorsTest.cpp
+++ b/third_party/WebKit/Source/modules/payments/PaymentsValidatorsTest.cpp
@@ -26,9 +26,19 @@ std::ostream& operator<<(std::ostream& out, const TestCase& testCase) {
return out;
}
-class PaymentsCurrencyValidatorTest : public testing::TestWithParam<TestCase> {
+struct CurrencyCodeTestCase {
+ CurrencyCodeTestCase(const char* code, const char* system, bool expectedValid)
+ : code(code), system(system), expectedValid(expectedValid) {}
+ ~CurrencyCodeTestCase() {}
+
+ const char* code;
+ const char* system;
+ bool expectedValid;
};
+class PaymentsCurrencyValidatorTest
+ : public testing::TestWithParam<CurrencyCodeTestCase> {};
+
const char* longString2048() {
static char longString[2049];
for (int i = 0; i < 2048; i++)
@@ -48,14 +58,14 @@ const char* longString2049() {
TEST_P(PaymentsCurrencyValidatorTest, IsValidCurrencyCodeFormat) {
String errorMessage;
EXPECT_EQ(GetParam().expectedValid,
- PaymentsValidators::isValidCurrencyCodeFormat(GetParam().input,
- &errorMessage))
+ PaymentsValidators::isValidCurrencyCodeFormat(
+ GetParam().code, GetParam().system, &errorMessage))
<< errorMessage;
EXPECT_EQ(GetParam().expectedValid, errorMessage.isEmpty()) << errorMessage;
- EXPECT_EQ(
- GetParam().expectedValid,
- PaymentsValidators::isValidCurrencyCodeFormat(GetParam().input, nullptr));
+ EXPECT_EQ(GetParam().expectedValid,
+ PaymentsValidators::isValidCurrencyCodeFormat(
+ GetParam().code, GetParam().system, nullptr));
}
INSTANTIATE_TEST_CASE_P(
@@ -63,15 +73,17 @@ INSTANTIATE_TEST_CASE_P(
PaymentsCurrencyValidatorTest,
testing::Values(
// Any string of at most 2048 characters can be a valid currency code
- TestCase("USD", true),
- TestCase("US1", true),
- TestCase("US", true),
- TestCase("USDO", true),
- TestCase("usd", true),
- TestCase("ANYSTRING", true),
- TestCase("", true),
- TestCase(longString2048(), true),
- TestCase(longString2049(), false)));
+ CurrencyCodeTestCase("USD", "urn:iso:std:iso:4217", true),
+ CurrencyCodeTestCase("US1", "http://www.example.com", true),
please use gerrit instead 2016/10/12 23:35:50 For each of the valid example.com currency systems
pals 2016/10/13 09:30:39 Done.
+ CurrencyCodeTestCase("US", "http://www.example.com", true),
+ CurrencyCodeTestCase("USDO", "http://www.example.com", true),
+ CurrencyCodeTestCase("usd", "http://www.example.com", true),
+ CurrencyCodeTestCase("ANYSTRING", "http://www.example.com", true),
+ CurrencyCodeTestCase("", "http://www.example.com", true),
+ CurrencyCodeTestCase(longString2048(), "http://www.example.com", true),
+ CurrencyCodeTestCase(longString2049(),
+ "http://www.example.com",
+ false)));
class PaymentsAmountValidatorTest : public testing::TestWithParam<TestCase> {};

Powered by Google App Engine
This is Rietveld 408576698