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

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: Fixed 640847 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..48afa2f2eeaf5e72391b0418b5974751cbdfede9 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 < 2049; i++)
please use gerrit instead 2016/08/25 16:47:38 i < 2048
pals 2016/08/26 07:20:26 One extra space for '\0'. strlen() does not includ
please use gerrit instead 2016/08/26 17:01:37 In the current state, the last value if "i" is "20
pals 2016/08/27 11:16:31 I'm sorry. You are correct. Rectified the issue.
+ longString[i] = 'a';
+ longString[2048] = '\0';
+ return longString;
+}
+
+const char* longString2049()
+{
+ static char longString[2050];
+ for (int i = 0; i < 2050; i++)
please use gerrit instead 2016/08/25 16:47:38 i < 2049
pals 2016/08/26 07:20:26 Same reason.
+ 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 can be a 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