@Config(maxSdk = LOLLIPOP) @Test public void testSomeApiLevel() { assertThat(Build.VERSION.SDK_INT).isAtMost(LOLLIPOP); } }
public static void assertConsecutiveDroppedBufferLimit(String name, DecoderCounters counters, int limit) { counters.ensureUpdated(); int actual = counters.maxConsecutiveDroppedBufferCount; assertWithMessage( "Codec(" + name + ") was late decoding: " + actual + " buffers consecutively. " + "Limit: " + limit + ".") .that(actual) .isAtMost(limit); }
@Test public void testSomeApiLevel() { assertThat(Build.VERSION.SDK_INT).isAtMost(LOLLIPOP); } }
public static void assertDroppedBufferLimit(String name, DecoderCounters counters, int limit) { counters.ensureUpdated(); int actual = counters.droppedBufferCount; assertWithMessage( "Codec(" + name + ") was late decoding: " + actual + " buffers. " + "Limit: " + limit + ".") .that(actual) .isAtMost(limit); }
private void testDrainTimesOut(BlockingQueue<Object> q) throws Exception { for (boolean interruptibly : new boolean[] {true, false}) { assertEquals(0, Queues.drain(q, ImmutableList.of(), 1, 10, MILLISECONDS)); Producer producer = new Producer(q, 1); // producing one, will ask for two Future<?> producerThread = threadPool.submit(producer); producer.beganProducing.await(); // make sure we time out Stopwatch timer = Stopwatch.createStarted(); int drained = drain(q, newArrayList(), 2, 10, MILLISECONDS, interruptibly); assertThat(drained).isAtMost(1); assertThat(timer.elapsed(MILLISECONDS)).isAtLeast(10L); // If even the first one wasn't there, clean up so that the next test doesn't see an element. producerThread.cancel(true); producer.doneProducing.await(); if (drained == 0) { q.poll(); // not necessarily there if producer was interrupted } } }
static void checkValidState(LocalCache<?, ?> cchm) { for (Segment<?, ?> segment : cchm.segments) { segment.cleanUp(); assertFalse(segment.isLocked()); Map<?, ?> table = segmentTable(segment); // cleanup and then check count after we have a strong reference to all entries segment.cleanUp(); // under high memory pressure keys/values may be nulled out but not yet enqueued assertThat(table.size()).isAtMost(segment.count); for (Entry<?, ?> entry : table.entrySet()) { assertNotNull(entry.getKey()); assertNotNull(entry.getValue()); assertSame(entry.getValue(), cchm.get(entry.getKey())); } } checkEviction(cchm); checkExpiration(cchm); }
@Test public void obtainStyledAttributesShouldDereferenceValues() { Resources.Theme theme = resources.newTheme(); theme.applyStyle(R.style.MyBlackTheme, false); TypedArray arr = theme.obtainStyledAttributes(new int[]{android.R.attr.windowBackground}); TypedValue value = new TypedValue(); arr.getValue(0, value); arr.recycle(); assertThat(value.type).isAtLeast(TYPE_FIRST_COLOR_INT); assertThat(value.type).isAtMost(TYPE_LAST_INT); }
public static void assertDroppedBufferLimit(String name, DecoderCounters counters, int limit) { counters.ensureUpdated(); int actual = counters.droppedBufferCount; assertWithMessage( "Codec(" + name + ") was late decoding: " + actual + " buffers. " + "Limit: " + limit + ".") .that(actual) .isAtMost(limit); }
public static void assertConsecutiveDroppedBufferLimit(String name, DecoderCounters counters, int limit) { counters.ensureUpdated(); int actual = counters.maxConsecutiveDroppedBufferCount; assertWithMessage( "Codec(" + name + ") was late decoding: " + actual + " buffers consecutively. " + "Limit: " + limit + ".") .that(actual) .isAtMost(limit); }
private void validate(ResultSet resultSet) { int i = 0; while (resultSet.next()) { assertThat(resultSet.getLong(0)).isEqualTo(i); ByteArray data = resultSet.getBytes(1); assertThat(data.length()).isEqualTo(resultSet.getLong(3)); assertThat(resultSet.getLong(2)).isEqualTo(hasher.hashBytes(data.toByteArray()).asLong()); assertThat(++i).isAtMost(numRows); } assertThat(i).isEqualTo(numRows); } }
@Test public void checkAndMutateRowSettingsAreSane() { UnaryCallSettings.Builder<ConditionalRowMutation, Boolean> builder = EnhancedBigtableStubSettings.newBuilder().checkAndMutateRowSettings(); // CheckAndMutateRow is not retryable in the case of toggle mutations. So it's disabled by // default. assertThat(builder.getRetrySettings().getMaxAttempts()).isAtMost(1); assertThat(builder.getRetryableCodes()).isEmpty(); }
@Test public void shouldHaveCompareAndBeforeAfter() throws Exception { Time a = new Time(); Time b = new Time(); assertThat(Time.compare(a, b)).isEqualTo(0); assertThat(a.before(b)).isFalse(); assertThat(a.after(b)).isFalse(); a.year = 2000; assertThat(Time.compare(a, b)).isAtLeast(0); assertThat(a.after(b)).isTrue(); assertThat(b.before(a)).isTrue(); b.year = 2001; assertThat(Time.compare(a, b)).isAtMost(0); assertThat(b.after(a)).isTrue(); assertThat(a.before(b)).isTrue(); }
assertThat(edgesConnecting.size()).isAtMost(1);
threadsDone.await(); synchronized (lock) { assertThat(maxAliveSessions).isAtMost(maxSessions);
private void assertInvariants(Parcel p) { assertWithMessage("capacity >= size").that(p.dataCapacity()).isAtLeast(p.dataSize()); assertWithMessage("position <= size").that(p.dataPosition()).isAtMost(p.dataSize()); assertWithMessage("available = size - position") .that(p.dataAvail()) .isEqualTo(p.dataSize() - p.dataPosition()); assertWithMessage("size % 4 == 0").that(p.dataSize() % 4).isEqualTo(0); assertWithMessage("capacity % 4 == 0").that(p.dataSize() % 4).isEqualTo(0); } }
private void testDrainTimesOut(BlockingQueue<Object> q) throws Exception { for (boolean interruptibly : new boolean[] {true, false}) { assertEquals(0, Queues.drain(q, ImmutableList.of(), 1, 10, MILLISECONDS)); Producer producer = new Producer(q, 1); // producing one, will ask for two Future<?> producerThread = threadPool.submit(producer); producer.beganProducing.await(); // make sure we time out Stopwatch timer = Stopwatch.createStarted(); int drained = drain(q, newArrayList(), 2, 10, MILLISECONDS, interruptibly); assertThat(drained).isAtMost(1); assertThat(timer.elapsed(MILLISECONDS)).isAtLeast(10L); // If even the first one wasn't there, clean up so that the next test doesn't see an element. producerThread.cancel(true); producer.doneProducing.await(); if (drained == 0) { q.poll(); // not necessarily there if producer was interrupted } } }
static void checkValidState(LocalCache<?, ?> cchm) { for (Segment<?, ?> segment : cchm.segments) { segment.cleanUp(); assertFalse(segment.isLocked()); Map<?, ?> table = segmentTable(segment); // cleanup and then check count after we have a strong reference to all entries segment.cleanUp(); // under high memory pressure keys/values may be nulled out but not yet enqueued assertThat(table.size()).isAtMost(segment.count); for (Entry<?, ?> entry : table.entrySet()) { assertNotNull(entry.getKey()); assertNotNull(entry.getValue()); assertSame(entry.getValue(), cchm.get(entry.getKey())); } } checkEviction(cchm); checkExpiration(cchm); }
assertThat(edgesConnecting.size()).isAtMost(1);