mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-11 08:01:32 +00:00
ICU-2516 Added unsigned comparison test case
X-SVN-Rev: 12301
This commit is contained in:
parent
86f78fd50a
commit
ef399a4b0d
1 changed files with 28 additions and 0 deletions
|
@ -34,4 +34,32 @@ public class UtilityTest extends TestFmwk {
|
|||
errln("FAIL: Utility.unescape() returned " + result + ", exp. " + expect);
|
||||
}
|
||||
}
|
||||
|
||||
public void TestCompareUnsigned()
|
||||
{
|
||||
int data[] = {0, 1, 0x8fffffff, -1, Integer.MAX_VALUE,
|
||||
Integer.MIN_VALUE, 2342423, -2342423};
|
||||
for (int i = 0; i < data.length; i ++) {
|
||||
for (int j = 0; j < data.length; j ++) {
|
||||
if (Utility.compareUnsigned(data[i], data[j])
|
||||
!= compareLongUnsigned(data[i], data[j])) {
|
||||
errln("Fail: Unsigned comparison failed with " + data[i]
|
||||
+ " " + data[i + 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int compareLongUnsigned(int x, int y)
|
||||
{
|
||||
long x1 = x & 0xFFFFFFFFl;
|
||||
long y1 = y & 0xFFFFFFFFl;
|
||||
if (x1 < y1) {
|
||||
return -1;
|
||||
}
|
||||
else if (x1 > y1) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue