- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 29 for checkedCast (0.17 sec)
-
guava-tests/test/com/google/common/primitives/SignedBytesTest.java
private static final byte GREATEST = Byte.MAX_VALUE; private static final byte[] VALUES = {LEAST, -1, 0, 1, GREATEST}; public void testCheckedCast() { for (byte value : VALUES) { assertThat(SignedBytes.checkedCast((long) value)).isEqualTo(value); } assertCastFails(GREATEST + 1L); assertCastFails(LEAST - 1L); assertCastFails(Long.MAX_VALUE); assertCastFails(Long.MIN_VALUE); }
Java - Registered: Fri Apr 12 12:43:09 GMT 2024 - Last Modified: Tue Feb 20 17:00:05 GMT 2024 - 7K bytes - Viewed (0) -
android/guava-tests/test/com/google/common/primitives/UnsignedBytesTest.java
assertThat(UnsignedBytes.toInt((byte) -1)).isEqualTo(255); } public void testCheckedCast() { for (byte value : VALUES) { assertThat(UnsignedBytes.checkedCast(UnsignedBytes.toInt(value))).isEqualTo(value); } assertCastFails(256L); assertCastFails(-1L); assertCastFails(Long.MAX_VALUE); assertCastFails(Long.MIN_VALUE); }
Java - Registered: Fri May 03 12:43:13 GMT 2024 - Last Modified: Tue Feb 20 17:00:05 GMT 2024 - 13.4K bytes - Viewed (0) -
android/guava-tests/test/com/google/common/primitives/UnsignedIntsTest.java
for (long value : UNSIGNED_INTS) { assertThat(UnsignedInts.toLong(UnsignedInts.checkedCast(value))).isEqualTo(value); } assertCastFails(1L << 32); assertCastFails(-1L); assertCastFails(Long.MAX_VALUE); assertCastFails(Long.MIN_VALUE); } private static void assertCastFails(long value) { try { UnsignedInts.checkedCast(value); fail("Cast to int should have failed: " + value);
Java - Registered: Fri May 03 12:43:13 GMT 2024 - Last Modified: Tue Feb 06 16:10:08 GMT 2024 - 12.7K bytes - Viewed (0) -
android/guava-tests/benchmark/com/google/common/cache/LoadingCacheSingleThreadBenchmark.java
@BeforeExperiment void setUp() { // random integers will be generated in this range, then raised to the // power of (1/concentration) and floor()ed max = Ints.checkedCast((long) Math.pow(distinctKeys, concentration)); cache = CacheBuilder.newBuilder() .concurrencyLevel(segments) .maximumSize(maximumSize) .build(
Java - Registered: Fri May 03 12:43:13 GMT 2024 - Last Modified: Mon Dec 04 17:37:03 GMT 2017 - 3.4K bytes - Viewed (0) -
guava-tests/test/com/google/common/primitives/UnsignedIntsTest.java
for (long value : UNSIGNED_INTS) { assertThat(UnsignedInts.toLong(UnsignedInts.checkedCast(value))).isEqualTo(value); } assertCastFails(1L << 32); assertCastFails(-1L); assertCastFails(Long.MAX_VALUE); assertCastFails(Long.MIN_VALUE); } private static void assertCastFails(long value) { try { UnsignedInts.checkedCast(value); fail("Cast to int should have failed: " + value);
Java - Registered: Fri Apr 12 12:43:09 GMT 2024 - Last Modified: Tue Feb 06 16:10:08 GMT 2024 - 12.7K bytes - Viewed (0) -
android/guava/src/com/google/common/primitives/UnsignedBytes.java
* @return the {@code byte} value that, when treated as unsigned, equals {@code value} * @throws IllegalArgumentException if {@code value} is negative or greater than 255 */ @CanIgnoreReturnValue public static byte checkedCast(long value) { checkArgument(value >> Byte.SIZE == 0, "out of range: %s", value); return (byte) value; } /** * Returns the {@code byte} value that, when treated as unsigned, is nearest in value to {@code
Java - Registered: Fri Apr 26 12:43:10 GMT 2024 - Last Modified: Thu Feb 22 17:40:56 GMT 2024 - 18.3K bytes - Viewed (0) -
android/guava-tests/test/com/google/common/primitives/SignedBytesTest.java
private static final byte GREATEST = Byte.MAX_VALUE; private static final byte[] VALUES = {LEAST, -1, 0, 1, GREATEST}; public void testCheckedCast() { for (byte value : VALUES) { assertThat(SignedBytes.checkedCast((long) value)).isEqualTo(value); } assertCastFails(GREATEST + 1L); assertCastFails(LEAST - 1L); assertCastFails(Long.MAX_VALUE); assertCastFails(Long.MIN_VALUE); }
Java - Registered: Fri May 03 12:43:13 GMT 2024 - Last Modified: Tue Feb 20 17:00:05 GMT 2024 - 7K bytes - Viewed (0) -
android/guava/src/com/google/common/collect/DiscreteDomain.java
int i = value; return (i == Integer.MIN_VALUE) ? null : i - 1; } @Override Integer offset(Integer origin, long distance) { checkNonnegative(distance, "distance"); return Ints.checkedCast(origin.longValue() + distance); } @Override public long distance(Integer start, Integer end) { return (long) end - start; } @Override public Integer minValue() {
Java - Registered: Fri May 03 12:43:13 GMT 2024 - Last Modified: Thu Feb 22 21:19:52 GMT 2024 - 10.3K bytes - Viewed (0) -
guava-tests/benchmark/com/google/common/cache/LoadingCacheSingleThreadBenchmark.java
@BeforeExperiment void setUp() { // random integers will be generated in this range, then raised to the // power of (1/concentration) and floor()ed max = Ints.checkedCast((long) Math.pow(distinctKeys, concentration)); cache = CacheBuilder.newBuilder() .concurrencyLevel(segments) .maximumSize(maximumSize) .build(
Java - Registered: Fri Apr 19 12:43:09 GMT 2024 - Last Modified: Mon Dec 04 17:37:03 GMT 2017 - 3.4K bytes - Viewed (0) -
guava-tests/test/com/google/common/primitives/UnsignedBytesTest.java
assertThat(UnsignedBytes.toInt((byte) -1)).isEqualTo(255); } public void testCheckedCast() { for (byte value : VALUES) { assertThat(UnsignedBytes.checkedCast(UnsignedBytes.toInt(value))).isEqualTo(value); } assertCastFails(256L); assertCastFails(-1L); assertCastFails(Long.MAX_VALUE); assertCastFails(Long.MIN_VALUE); }
Java - Registered: Fri Apr 12 12:43:09 GMT 2024 - Last Modified: Tue Feb 20 17:00:05 GMT 2024 - 13.4K bytes - Viewed (0)