mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 03:17:55 +00:00
Fix bug in Expect package's string compare.
Review URL: https://codereview.chromium.org//15745024 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23455 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
974e0c62b5
commit
969a5f27b8
|
@ -29,6 +29,7 @@ class Expect {
|
|||
* Control characters may be encoded as "\xhh" codes.
|
||||
*/
|
||||
static String _truncateString(String string, int start, int end, int length) {
|
||||
print("$string: $start: $end: $length");
|
||||
if (end - start > length) {
|
||||
end = start + length;
|
||||
} else if (end - start < length) {
|
||||
|
@ -68,6 +69,7 @@ class Expect {
|
|||
* only a slice containing the first difference will be shown.
|
||||
*/
|
||||
static String _stringDifference(String expected, String actual) {
|
||||
print("digg: $expected, $actual");
|
||||
if (expected.length < 20 && actual.length < 20) return null;
|
||||
for (int i = 0; i < expected.length && i < actual.length; i++) {
|
||||
if (expected.codeUnitAt(i) != actual.codeUnitAt(i)) {
|
||||
|
@ -75,6 +77,7 @@ class Expect {
|
|||
i++;
|
||||
while (i < expected.length && i < actual.length) {
|
||||
if (expected.codeUnitAt(i) == actual.codeUnitAt(i)) break;
|
||||
i++;
|
||||
}
|
||||
int end = i;
|
||||
var truncExpected = _truncateString(expected, start, end, 20);
|
||||
|
@ -92,7 +95,6 @@ class Expect {
|
|||
static void equals(var expected, var actual, [String reason = null]) {
|
||||
if (expected == actual) return;
|
||||
String msg = _getMessage(reason);
|
||||
stringSpecialCase:
|
||||
if (expected is String && actual is String) {
|
||||
String stringDifference = _stringDifference(expected, actual);
|
||||
if (stringDifference != null) {
|
||||
|
|
Loading…
Reference in a new issue