aboutsummaryrefslogtreecommitdiffstats
path: root/guava-tests/test/com/google/common/primitives/UnsignedIntsTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'guava-tests/test/com/google/common/primitives/UnsignedIntsTest.java')
-rw-r--r--guava-tests/test/com/google/common/primitives/UnsignedIntsTest.java134
1 files changed, 14 insertions, 120 deletions
diff --git a/guava-tests/test/com/google/common/primitives/UnsignedIntsTest.java b/guava-tests/test/com/google/common/primitives/UnsignedIntsTest.java
index d1fd13c..4ab36de 100644
--- a/guava-tests/test/com/google/common/primitives/UnsignedIntsTest.java
+++ b/guava-tests/test/com/google/common/primitives/UnsignedIntsTest.java
@@ -1,11 +1,11 @@
/*
* Copyright (C) 2011 The Guava Authors
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing permissions and
@@ -14,21 +14,17 @@
package com.google.common.primitives;
-import com.google.common.annotations.GwtCompatible;
-import com.google.common.annotations.GwtIncompatible;
-import com.google.common.collect.testing.Helpers;
-import com.google.common.testing.NullPointerTester;
+import java.util.Random;
import junit.framework.TestCase;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Random;
+import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
+import com.google.common.testing.NullPointerTester;
/**
* Tests for UnsignedInts
- *
+ *
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
@@ -45,9 +41,6 @@ public class UnsignedIntsTest extends TestCase {
0xfffffffdL,
0xfffffffeL,
0xffffffffL};
-
- private static final int LEAST = (int) 0L;
- private static final int GREATEST = (int) 0xffffffffL;
public void testToLong() {
for (long a : UNSIGNED_INTS) {
@@ -64,57 +57,6 @@ public class UnsignedIntsTest extends TestCase {
}
}
}
-
- public void testMax_noArgs() {
- try {
- UnsignedInts.max();
- fail();
- } catch (IllegalArgumentException expected) {
- }
- }
-
- public void testMax() {
- assertEquals(LEAST, UnsignedInts.max(LEAST));
- assertEquals(GREATEST, UnsignedInts.max(GREATEST));
- assertEquals((int) 0xff1a618bL, UnsignedInts.max(
- (int) 8L, (int) 6L, (int) 7L,
- (int) 0x12345678L, (int) 0x5a4316b8L,
- (int) 0xff1a618bL, (int) 0L));
- }
-
- public void testMin_noArgs() {
- try {
- UnsignedInts.min();
- fail();
- } catch (IllegalArgumentException expected) {
- }
- }
-
- public void testMin() {
- assertEquals(LEAST, UnsignedInts.min(LEAST));
- assertEquals(GREATEST, UnsignedInts.min(GREATEST));
- assertEquals((int) 0L, UnsignedInts.min(
- (int) 8L, (int) 6L, (int) 7L,
- (int) 0x12345678L, (int) 0x5a4316b8L,
- (int) 0xff1a618bL, (int) 0L));
- }
-
- public void testLexicographicalComparator() {
- List<int[]> ordered = Arrays.asList(
- new int[] {},
- new int[] {LEAST},
- new int[] {LEAST, LEAST},
- new int[] {LEAST, (int) 1L},
- new int[] {(int) 1L},
- new int[] {(int) 1L, LEAST},
- new int[] {GREATEST, (GREATEST - (int) 1L)},
- new int[] {GREATEST, GREATEST},
- new int[] {GREATEST, GREATEST, GREATEST}
- );
-
- Comparator<int[]> comparator = UnsignedInts.lexicographicalComparator();
- Helpers.testComparator(comparator, ordered);
- }
public void testDivide() {
for (long a : UNSIGNED_INTS) {
@@ -171,7 +113,7 @@ public class UnsignedIntsTest extends TestCase {
} catch (NumberFormatException expected) {}
}
- public void testParseIntWithRadix() throws NumberFormatException {
+ public void testParseLongWithRadix() throws NumberFormatException {
for (long a : UNSIGNED_INTS) {
for (int radix = Character.MIN_RADIX; radix <= Character.MAX_RADIX; radix++) {
assertEquals((int) a, UnsignedInts.parseUnsignedInt(Long.toString(a, radix), radix));
@@ -194,7 +136,7 @@ public class UnsignedIntsTest extends TestCase {
}
}
- public void testParseIntThrowsExceptionForInvalidRadix() {
+ public void testParseLongThrowsExceptionForInvalidRadix() {
// Valid radix values are Character.MIN_RADIX to Character.MAX_RADIX,
// inclusive.
try {
@@ -214,43 +156,6 @@ public class UnsignedIntsTest extends TestCase {
} catch (NumberFormatException expected) {}
}
- public void testDecodeInt() {
- assertEquals(0xffffffff, UnsignedInts.decode("0xffffffff"));
- assertEquals(01234567, UnsignedInts.decode("01234567")); // octal
- assertEquals(0x12345678, UnsignedInts.decode("#12345678"));
- assertEquals(76543210, UnsignedInts.decode("76543210"));
- assertEquals(0x13579135, UnsignedInts.decode("0x13579135"));
- assertEquals(0x13579135, UnsignedInts.decode("0X13579135"));
- assertEquals(0, UnsignedInts.decode("0"));
- }
-
- public void testDecodeIntFails() {
- try {
- // One more than maximum value
- UnsignedInts.decode("0xfffffffff");
- fail();
- } catch (NumberFormatException expected) {
- }
-
- try {
- UnsignedInts.decode("-5");
- fail();
- } catch (NumberFormatException expected) {
- }
-
- try {
- UnsignedInts.decode("-0x5");
- fail();
- } catch (NumberFormatException expected) {
- }
-
- try {
- UnsignedInts.decode("-05");
- fail();
- } catch (NumberFormatException expected) {
- }
- }
-
public void testToString() {
int[] bases = {2, 5, 7, 8, 10, 16};
for (long a : UNSIGNED_INTS) {
@@ -260,21 +165,10 @@ public class UnsignedIntsTest extends TestCase {
}
}
- public void testJoin() {
- assertEquals("", join());
- assertEquals("1", join(1));
- assertEquals("1,2", join(1, 2));
- assertEquals("4294967295,2147483648", join(-1, Integer.MIN_VALUE));
-
- assertEquals("123", UnsignedInts.join("", 1, 2, 3));
- }
-
- private static String join(int... values) {
- return UnsignedInts.join(",", values);
- }
-
@GwtIncompatible("NullPointerTester")
- public void testNulls() {
- new NullPointerTester().testAllPublicStaticMethods(UnsignedInts.class);
+ public void testNulls() throws Exception {
+ NullPointerTester tester = new NullPointerTester();
+ tester.setDefault(int[].class, new int[0]);
+ tester.testAllPublicStaticMethods(UnsignedInts.class);
}
}