/** Regression test for https://github.com/google/guava/issues/2658 */ public void testRemoveRegression() { MinMaxPriorityQueue<Long> queue = MinMaxPriorityQueue.create(ImmutableList.of(2L, 3L, 0L, 4L, 1L)); queue.remove(4L); queue.remove(1L); assertThat(queue).doesNotContain(1L); }
public void testZipInfiniteWithInfinite() { // zip is doing an infinite zip, but we truncate the result so we can actually test it // but we want the zip itself to work assertThat( Streams.zip( Stream.iterate(1, i -> i + 1).map(String::valueOf), Stream.iterate(1, i -> i + 1), (String str, Integer i) -> str.equals(Integer.toString(i))) .limit(100)) .doesNotContain(false); }
/** * In some cases our graph implementations return custom sets that define their own size() and * contains(). Verify that these sets are consistent with the elements of their iterator. */ @CanIgnoreReturnValue static <T> Set<T> sanityCheckSet(Set<T> set) { assertThat(set).hasSize(Iterators.size(set.iterator())); for (Object element : set) { assertThat(set).contains(element); } assertThat(set).doesNotContain(new Object()); assertThat(set).isEqualTo(ImmutableSet.copyOf(set)); return set; } }
public void testRandomRemoves() { Random random = new Random(0); for (int attempts = 0; attempts < reduceIterationsIfGwt(1000); attempts++) { ArrayList<Integer> elements = createOrderedList(10); Collections.shuffle(elements, random); MinMaxPriorityQueue<Integer> queue = MinMaxPriorityQueue.create(elements); Collections.shuffle(elements, random); for (Integer element : elements) { assertThat(queue.remove(element)).isTrue(); assertIntact(queue); assertThat(queue).doesNotContain(element); } assertThat(queue).isEmpty(); } }
@Test public void edges_containsOrderMismatch() { addEdge(N1, N2, E12); EndpointPair<Integer> endpointsN1N2 = EndpointPair.unordered(N1, N2); EndpointPair<Integer> endpointsN2N1 = EndpointPair.unordered(N2, N1); assertThat(network.asGraph().edges()).doesNotContain(endpointsN1N2); assertThat(network.asGraph().edges()).doesNotContain(endpointsN2N1); }
@Test public void testBuild_withModelClass_excludesModelLoadersForOtherModelClasses() { multiFactory.append(String.class, String.class, firstFactory); List<ModelLoader<Integer, ?>> modelLoaders = multiFactory.build(Integer.class); assertThat(modelLoaders).doesNotContain(firstModelLoader); }
@Test public void testBuild_withModelClass_doesNotMatchSubclassesOfModelClass() { ModelLoader<String, Object> subclass = appendFactoryFor(String.class, Object.class); List<ModelLoader<Object, ?>> modelLoaders = multiFactory.build(Object.class); assertThat(modelLoaders).doesNotContain(subclass); }
@Test public void endpointPair_directed_contains() { MutableGraph<Integer> directedGraph = GraphBuilder.directed().allowsSelfLoops(true).build(); directedGraph.putEdge(N1, N1); directedGraph.putEdge(N1, N2); Set<EndpointPair<Integer>> edges = directedGraph.edges(); assertThat(edges).hasSize(2); assertThat(edges).contains(EndpointPair.ordered(N1, N1)); assertThat(edges).contains(EndpointPair.ordered(N1, N2)); // unordered endpoints not OK for directed graph (undefined behavior) assertThat(edges).doesNotContain(EndpointPair.unordered(N1, N2)); assertThat(edges).doesNotContain(EndpointPair.ordered(N2, N1)); // wrong order assertThat(edges).doesNotContain(EndpointPair.ordered(N2, N2)); // edge not present assertThat(edges).doesNotContain(EndpointPair.ordered(N3, N4)); // nodes not in graph }
@Test public void removeEdge_existingSelfLoopEdge() { addEdge(N1, N1, E11); assertThat(network.removeEdge(E11)).isTrue(); assertThat(network.edges()).doesNotContain(E11); assertThat(network.edgesConnecting(N1, N1)).isEmpty(); } }
@Test public void removeEdge_existingSelfLoopEdge() { addEdge(N1, N1, E11); assertThat(network.removeEdge(E11)).isTrue(); assertThat(network.edges()).doesNotContain(E11); assertThat(network.edgesConnecting(N1, N1)).isEmpty(); } }
@Test public void removeNode_existingNode() { addEdge(N1, N2, E12); addEdge(N4, N1, E41); assertTrue(network.removeNode(N1)); assertFalse(network.removeNode(N1)); assertThat(network.nodes()).containsExactly(N2, N4); assertThat(network.edges()).doesNotContain(E12); assertThat(network.edges()).doesNotContain(E41); }
@Test public void removeNode_existingNodeWithSelfLoopEdge() { addNode(N1); addEdge(N1, N1, E11); assertThat(network.removeNode(N1)).isTrue(); assertThat(network.nodes()).isEmpty(); assertThat(network.edges()).doesNotContain(E11); }
@Test public void removeNode_existingNodeWithSelfLoopEdge() { addNode(N1); addEdge(N1, N1, E11); assertThat(network.removeNode(N1)).isTrue(); assertThat(network.nodes()).isEmpty(); assertThat(network.edges()).doesNotContain(E11); }
@Test public void removeCallback() { surfaceHolder.addCallback(callback1); surfaceHolder.addCallback(callback2); assertThat(fakeSurfaceHolder.getCallbacks().size()).isEqualTo(2); surfaceHolder.removeCallback(callback1); assertThat(fakeSurfaceHolder.getCallbacks()).doesNotContain(callback1); assertThat(fakeSurfaceHolder.getCallbacks()).contains(callback2); }
@Test public void exifHorizontalFlip() { Request data = new Request.Builder(URI_1).rotate(-45).build(); Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888); Bitmap result = transformResult(data, source, ORIENTATION_FLIP_HORIZONTAL); ShadowBitmap shadowBitmap = shadowOf(result); assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source); Matrix matrix = shadowBitmap.getCreatedFromMatrix(); ShadowMatrix shadowMatrix = shadowOf(matrix); assertThat(shadowMatrix.getPostOperations()).containsExactly("scale -1.0 1.0"); assertThat(shadowMatrix.getPreOperations()).doesNotContain("rotate 180.0"); assertThat(shadowMatrix.getPreOperations()).doesNotContain("rotate 90.0"); assertThat(shadowMatrix.getPreOperations()).doesNotContain("rotate 270.0"); }
@Test public void endpointPair_undirected_contains() { MutableGraph<Integer> undirectedGraph = GraphBuilder.undirected().allowsSelfLoops(true).build(); undirectedGraph.putEdge(N1, N1); undirectedGraph.putEdge(N1, N2); Set<EndpointPair<Integer>> edges = undirectedGraph.edges(); assertThat(edges).hasSize(2); assertThat(edges).contains(EndpointPair.unordered(N1, N1)); assertThat(edges).contains(EndpointPair.unordered(N1, N2)); assertThat(edges).contains(EndpointPair.unordered(N2, N1)); // equal to unordered(N1, N2) // ordered endpoints OK for undirected graph (because ordering is irrelevant) assertThat(edges).contains(EndpointPair.ordered(N1, N2)); assertThat(edges).doesNotContain(EndpointPair.unordered(N2, N2)); // edge not present assertThat(edges).doesNotContain(EndpointPair.unordered(N3, N4)); // nodes not in graph }
@Test public void builderWithoutRequestHandler() { Picasso picasso = new Picasso.Builder(RuntimeEnvironment.application).build(); assertThat(picasso.getRequestHandlers()).isNotEmpty(); assertThat(picasso.getRequestHandlers()).doesNotContain(requestHandler); }
@Test public void removeEdge_existingEdge() { addEdge(N1, N2, E12); assertTrue(network.removeEdge(E12)); assertFalse(network.removeEdge(E12)); assertThat(network.edges()).doesNotContain(E12); assertThat(network.edgesConnecting(N1, N2)).isEmpty(); }
@Test public void windowFocusChanged() { controller.setup(); assertThat(transcript).doesNotContain("finishedOnWindowFocusChanged"); assertThat(controller.get().hasWindowFocus()).isFalse(); transcript.clear(); controller.windowFocusChanged(true); assertThat(transcript).containsExactly("finishedOnWindowFocusChanged"); assertThat(controller.get().hasWindowFocus()).isTrue(); }
@Test public void transpose_directedGraph() { MutableGraph<Integer> directedGraph = GraphBuilder.directed().allowsSelfLoops(true).build(); directedGraph.putEdge(N1, N3); directedGraph.putEdge(N3, N1); directedGraph.putEdge(N1, N2); directedGraph.putEdge(N1, N1); directedGraph.putEdge(N3, N4); MutableGraph<Integer> expectedTranspose = GraphBuilder.directed().allowsSelfLoops(true).build(); expectedTranspose.putEdge(N3, N1); expectedTranspose.putEdge(N1, N3); expectedTranspose.putEdge(N2, N1); expectedTranspose.putEdge(N1, N1); expectedTranspose.putEdge(N4, N3); Graph<Integer> transpose = transpose(directedGraph); assertThat(transpose).isEqualTo(expectedTranspose); assertThat(transpose(transpose)).isSameAs(directedGraph); AbstractGraphTest.validateGraph(transpose); for (Integer node : directedGraph.nodes()) { assertThat(directedGraph.inDegree(node)).isSameAs(transpose.outDegree(node)); assertThat(directedGraph.outDegree(node)).isSameAs(transpose.inDegree(node)); } assertThat(transpose.successors(N1)).doesNotContain(N2); directedGraph.putEdge(N2, N1); // View should be updated. assertThat(transpose.successors(N1)).contains(N2); AbstractGraphTest.validateGraph(transpose); }