private byte[] upTo(int size) { assertThat(size).isLessThan(currentValue); byte[] result = new byte[size]; for (int i = 0; i < size; i++) { result[i] = (byte) (i + 1); } return result; }
@Override public long selectTracks(TrackSelection[] selections, boolean[] mayRetainStreamFlags, SampleStream[] streams, boolean[] streamResetFlags, long positionUs) { assertThat(prepared).isTrue(); int rendererCount = selections.length; for (int i = 0; i < rendererCount; i++) { if (streams[i] != null && (selections[i] == null || !mayRetainStreamFlags[i])) { streams[i] = null; } if (streams[i] == null && selections[i] != null) { TrackSelection selection = selections[i]; assertThat(selection.length()).isAtLeast(1); TrackGroup trackGroup = selection.getTrackGroup(); assertThat(trackGroupArray.indexOf(trackGroup) != C.INDEX_UNSET).isTrue(); int indexInTrackGroup = selection.getIndexInTrackGroup(selection.getSelectedIndex()); assertThat(indexInTrackGroup).isAtLeast(0); assertThat(indexInTrackGroup).isLessThan(trackGroup.length); streams[i] = createSampleStream(selection); streamResetFlags[i] = true; } } return positionUs; }
@Test public void matchData_NoMatchType() throws IntentFilter.MalformedMimeTypeException { IntentFilter intentFilter = new IntentFilter(); intentFilter.addDataType("image/testFail"); Uri uriTest1 = Uri.parse("http://testHost1:1"); assertThat(intentFilter.matchData("image/test", "http", uriTest1)) .isLessThan(0); }
@Test public void matchData_MatchSchemeNoMatchType() throws IntentFilter.MalformedMimeTypeException { IntentFilter intentFilter = new IntentFilter(); intentFilter.addDataScheme("http"); intentFilter.addDataType("image/testFail"); Uri uriTest1 = Uri.parse("http://testHost1:1"); assertThat(intentFilter.matchData("image/test", "http", uriTest1)) .isLessThan(0); }
@Test public void matchData_NoMatchScheme() throws IntentFilter.MalformedMimeTypeException { IntentFilter intentFilter = new IntentFilter(); intentFilter.addDataScheme("http"); intentFilter.addDataType("image/test"); Uri uriTest1 = Uri.parse("https://testHost1:1"); assertThat(intentFilter.matchData("image/test", "https", uriTest1)) .isLessThan(0); }
@Test public void matchData_MatchesPartialType() throws IntentFilter.MalformedMimeTypeException { IntentFilter intentFilter = new IntentFilter(); intentFilter.addDataScheme("content"); intentFilter.addDataType("image/*"); Uri uri = Uri.parse("content://authority/images"); assertThat(intentFilter.matchData("image/test", "content", uri)).isAtLeast(0); assertThat(intentFilter.matchData("video/test", "content", uri)).isLessThan(0); }
@Test public void matchData_NoMatchDataAuthority() throws IntentFilter.MalformedMimeTypeException { IntentFilter intentFilter = new IntentFilter(); intentFilter.addDataType("image/test"); intentFilter.addDataScheme("http"); intentFilter.addDataAuthority("testHost1", "1"); Uri uriTest1 = Uri.parse("http://testHost1:2"); assertThat(intentFilter.matchData("image/test", "http", uriTest1)) .isLessThan(0); }
private static void check(String v1, String v2) { assertThat(new JavaVersion(v1).compareTo(new JavaVersion(v2))).isLessThan(0); }
@Test @SandboxConfig(shadows = ShadowThrowInShadowMethod.class) public void shouldRemoveNoiseFromShadowedStackTraces() throws Exception { ThrowInShadowMethod instance = new ThrowInShadowMethod(); Exception e = null; try { instance.method(); } catch (Exception e1) { e = e1; } assertNotNull(e); assertEquals(IOException.class, e.getClass()); assertEquals("fake exception", e.getMessage()); StackTraceElement[] stackTrace = e.getStackTrace(); assertThat(stackTrace[0].getClassName()).isEqualTo(ShadowThrowInShadowMethod.class.getName()); assertThat(stackTrace[0].getMethodName()).isEqualTo("method"); assertThat(stackTrace[0].getLineNumber()).isGreaterThan(0); assertThat(stackTrace[1].getClassName()).isEqualTo(ThrowInShadowMethod.class.getName()); assertThat(stackTrace[1].getMethodName()).isEqualTo("method"); assertThat(stackTrace[1].getLineNumber()).isLessThan(0); assertThat(stackTrace[2].getClassName()).isEqualTo(ShadowWranglerIntegrationTest.class.getName()); assertThat(stackTrace[2].getMethodName()).isEqualTo("shouldRemoveNoiseFromShadowedStackTraces"); assertThat(stackTrace[2].getLineNumber()).isGreaterThan(0); }
@Test public void testCumulativePoolAndMemoryCacheSizesAreSmallerOnLowMemoryDevices() { Shadows.shadowOf(harness.activityManager).setMemoryClass(getLargeEnoughMemoryClass() / 2); final int normalMemoryCacheSize = harness.getCalculator().getMemoryCacheSize(); final int normalBitmapPoolSize = harness.getCalculator().getBitmapPoolSize(); Util.setSdkVersionInt(10); // Keep the bitmap pool size constant, even though normally it would change. harness.byteArrayPoolSizeBytes *= 2; final int smallMemoryCacheSize = harness.getCalculator().getMemoryCacheSize(); final int smallBitmapPoolSize = harness.getCalculator().getBitmapPoolSize(); assertThat(smallMemoryCacheSize).isLessThan(normalMemoryCacheSize); assertThat(smallBitmapPoolSize).isLessThan(normalBitmapPoolSize); }
@Override public long selectTracks(TrackSelection[] selections, boolean[] mayRetainStreamFlags, SampleStream[] streams, boolean[] streamResetFlags, long positionUs) { assertThat(prepared).isTrue(); int rendererCount = selections.length; for (int i = 0; i < rendererCount; i++) { if (streams[i] != null && (selections[i] == null || !mayRetainStreamFlags[i])) { streams[i] = null; } if (streams[i] == null && selections[i] != null) { TrackSelection selection = selections[i]; assertThat(selection.length()).isAtLeast(1); TrackGroup trackGroup = selection.getTrackGroup(); assertThat(trackGroupArray.indexOf(trackGroup) != C.INDEX_UNSET).isTrue(); int indexInTrackGroup = selection.getIndexInTrackGroup(selection.getSelectedIndex()); assertThat(indexInTrackGroup).isAtLeast(0); assertThat(indexInTrackGroup).isLessThan(trackGroup.length); streams[i] = createSampleStream(selection); streamResetFlags[i] = true; } } return positionUs; }
@Test public void compareLongs() { assertThat(TimeUtils.compareLongs(-1L, 1L)).isLessThan(0); assertThat(TimeUtils.compareLongs(10L, 10L)).isEqualTo(0); assertThat(TimeUtils.compareLongs(1L, 0L)).isGreaterThan(0); }
@Test public void starts_empty_signInScreen_noSelection() { assertThat(projectSelectionDialog.getCenterPanelWrapper().getComponent(0)) .isInstanceOf(ProjectSelectorSignInPanel.class); assertThat(projectSelectionDialog.getAccountComboBox().getSelectedItem()).isNull(); assertThat(projectSelectionDialog.getProjectListTable().getSelectedRow()).isLessThan(0); assertThat(projectSelectionDialog.getProjectListTableModel().getRowCount()).isEqualTo(0); }
@Test public void spanId_CompareTo() { assertThat(first.compareTo(second)).isGreaterThan(0); assertThat(second.compareTo(first)).isLessThan(0); assertThat(first.compareTo(SpanId.fromBytes(firstBytes))).isEqualTo(0); }
@Test public void traceId_CompareTo() { assertThat(first.compareTo(second)).isGreaterThan(0); assertThat(second.compareTo(first)).isLessThan(0); assertThat(first.compareTo(TraceId.fromBytes(firstBytes))).isEqualTo(0); }
assertThat(tree.successors(predecessor)).contains(node); assertThat(tree.hasEdgeConnecting(predecessor, node)).isTrue(); assertThat(tree.depth(predecessor)).isLessThan(tree.depth(node));