diff options
author | Brett Chabot <brettchabot@android.com> | 2012-05-09 11:00:26 -0700 |
---|---|---|
committer | Brett Chabot <brettchabot@android.com> | 2012-05-09 11:00:26 -0700 |
commit | 131ae36bedb326432f4b830c12abfb1274cc391b (patch) | |
tree | 1b89c53d9ff7e6dbb3815daa1312b482afc5a955 /src | |
parent | c62242988737e0204e6b01312faeda3b9a2b64cd (diff) | |
download | junit-131ae36bedb326432f4b830c12abfb1274cc391b.tar.gz |
Build a junit4-target library.
Bug 5826326
Change-Id: Iff8f25e2ab95f4eb4cfaaff215f7d608c9ae6fa6
Diffstat (limited to 'src')
-rw-r--r-- | src/junit/framework/ComparisonCompactor.java | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/junit/framework/ComparisonCompactor.java b/src/junit/framework/ComparisonCompactor.java index 24ad42f..e540f03 100644 --- a/src/junit/framework/ComparisonCompactor.java +++ b/src/junit/framework/ComparisonCompactor.java @@ -23,14 +23,17 @@ public class ComparisonCompactor { } public String compact(String message) { - if (fExpected == null || fActual == null || areStringsEqual()) - return Assert.format(message, fExpected, fActual); - + if (fExpected == null || fActual == null || areStringsEqual()) { + // android-changed use local method instead of Assert.format, since + // the later is not part of Android API till API 16 + return format(message, fExpected, fActual); + } findCommonPrefix(); findCommonSuffix(); String expected= compactString(fExpected); String actual= compactString(fActual); - return Assert.format(message, expected, actual); + // android-changed use local format method + return format(message, expected, actual); } private String compactString(String source) { @@ -73,4 +76,12 @@ public class ComparisonCompactor { private boolean areStringsEqual() { return fExpected.equals(fActual); } + + // android-changed copy of Assert.format for reasons described above + private static String format(String message, Object expected, Object actual) { + String formatted= ""; + if (message != null && message.length() > 0) + formatted= message+" "; + return formatted+"expected:<"+expected+"> but was:<"+actual+">"; + } } |