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

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

Issue 2271113002: Accept any string for currency code in PaymentRequest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Allow null as per spec Created 4 years, 4 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 bf5b9826371a1810b3bb7fa47edc8323ebb3aae3..4084833ecd3d0dc3af957b2bd45a5060b7430112 100644
--- a/third_party/WebKit/Source/modules/payments/PaymentsValidatorsTest.cpp
+++ b/third_party/WebKit/Source/modules/payments/PaymentsValidatorsTest.cpp
@@ -32,6 +32,24 @@ std::ostream& operator<<(std::ostream& out, const TestCase& testCase)
class PaymentsCurrencyValidatorTest : public testing::TestWithParam<TestCase> {
};
+const char* longString2048()
+{
+ static char longString[2049];
+ for (int i = 0; i < 2048; i++)
+ longString[i] = 'a';
+ longString[2048] = '\0';
+ return longString;
+}
+
+const char* longString2049()
+{
+ static char longString[2050];
+ for (int i = 0; i < 2049; i++)
+ longString[i] = 'a';
+ longString[2049] = '\0';
+ return longString;
+}
+
TEST_P(PaymentsCurrencyValidatorTest, IsValidCurrencyCodeFormat)
{
String errorMessage;
@@ -44,13 +62,16 @@ TEST_P(PaymentsCurrencyValidatorTest, IsValidCurrencyCodeFormat)
INSTANTIATE_TEST_CASE_P(CurrencyCodes,
PaymentsCurrencyValidatorTest,
testing::Values(
+ // Any string of at most 2048 characters can be a valid currency code
TestCase("USD", true),
- // Invalid currency code formats
- TestCase("US1", false),
- TestCase("US", false),
- TestCase("USDO", false),
- TestCase("usd", false),
- TestCase("", false)));
+ TestCase("US1", true),
+ TestCase("US", true),
+ TestCase("USDO", true),
+ TestCase("usd", true),
+ TestCase("ANYSTRING", true),
+ TestCase("", true),
+ TestCase(longString2048(), true),
+ TestCase(longString2049(), false)));
class PaymentsAmountValidatorTest : public testing::TestWithParam<TestCase> {
};

Powered by Google App Engine
This is Rietveld 408576698