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

Unified Diff: tests/corelib/string_test.dart

Issue 171773003: Allow multi-codeunit padding in String.padLeft/padRight. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: repeat -> operator*. Created 6 years, 10 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
« sdk/lib/core/string.dart ('K') | « sdk/lib/core/string.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/string_test.dart
diff --git a/tests/corelib/string_test.dart b/tests/corelib/string_test.dart
index 107ba68d8e6ab2c834792d658e9e98134ac4e548..d4a271ac3d2228a90d3157b8caacd3f233327a6a 100644
--- a/tests/corelib/string_test.dart
+++ b/tests/corelib/string_test.dart
@@ -414,32 +414,28 @@ void testRepeat() {
10,
100
];
- void testRepeat(str, repeat, sep) {
+ void testRepeat(str, repeat) {
String expect;
- if (repeat == 0) {
+ if (repeat <= 0) {
expect = "";
} else if (repeat == 1) {
expect = str;
} else {
- StringBuffer buf = new StringBuffer(str);
- for (int i = 1; i < repeat; i++) {
- buf.write(sep);
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < repeat; i++) {
buf.write(str);
}
expect = buf.toString();
}
- String actual = str.repeat(repeat, sep);
+ String actual = str * repeat;
Expect.equals(expect, actual,
- "$str#${str.length}*$repeat/$sep#${sep.length}");
+ "$str#${str.length} * $repeat");
}
for (String str in testStrings) {
- for (String sep in testStrings) {
- for (int repeat in counts) {
- testRepeat(str, repeat, sep);
- }
+ for (int repeat in counts) {
+ testRepeat(str, repeat);
}
}
- Expect.throws(() { "a".repeat(-1); });
}
void testPadLeft() {
@@ -455,9 +451,11 @@ void testPadLeft() {
Expect.equals('aaaaa', ''.padLeft(5, 'a'));
Expect.equals('', ''.padLeft(-2, 'a'));
- Expect.throws(() { ' '.padLeft(5, ''); });
- Expect.throws(() { ' '.padLeft(5, 'xx'); });
- Expect.throws(() { ' '.padLeft(5, '\u{10002}'); });
+ Expect.equals('xyzxyzxyzxyzxyz', ''.padLeft(5, 'xyz'));
+ Expect.equals('xyzxyzxyzxyza', 'a'.padLeft(5, 'xyz'));
+ Expect.equals('xyzxyzxyzaa', 'aa'.padLeft(5, 'xyz'));
+ Expect.equals('\u{10002}\u{10002}\u{10002}aa', 'aa'.padLeft(5, '\u{10002}'));
+ Expect.equals('a', 'a'.padLeft(10, ''));
}
void testPadRight() {
@@ -473,7 +471,9 @@ void testPadRight() {
Expect.equals('aaaaa', ''.padRight(5, 'a'));
Expect.equals('', ''.padRight(-2, 'a'));
- Expect.throws(() { ' '.padRight(5, ''); });
- Expect.throws(() { ' '.padRight(5, 'xx'); });
- Expect.throws(() { ' '.padRight(5, '\u{10002}'); });
+ Expect.equals('xyzxyzxyzxyzxyz', ''.padRight(5, 'xyz'));
+ Expect.equals('axyzxyzxyzxyz', 'a'.padRight(5, 'xyz'));
+ Expect.equals('aaxyzxyzxyz', 'aa'.padRight(5, 'xyz'));
+ Expect.equals('aa\u{10002}\u{10002}\u{10002}', 'aa'.padRight(5, '\u{10002}'));
+ Expect.equals('a', 'a'.padRight(10, ''));
}
« sdk/lib/core/string.dart ('K') | « sdk/lib/core/string.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698