public void testDoubler() { Iterable<Integer> doubled = new Iterable<Integer>() { @Override public Iterator<Integer> iterator() { return newDoubler(2, 32); } }; assertThat(doubled).containsExactly(2, 4, 8, 16, 32).inOrder(); }
@Override public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) { assertThat(command).isInstanceOf(WrappedRunnable.class); lastMethodCalled = "scheduleRunnable"; lastDelay = delay; lastUnit = unit; return null; }
@Override public ListenableFuture<Integer> apply(Throwable t) throws Exception { assertThat(t).isSameAs(raisedException); return secondary; } });
private static void verifyComplexMessage(Exception e) { assertThat(e).hasMessageThat().isEqualTo("I ate 5 pies."); } }
private static void containsExactlySanityCheck(Collection<?> collection, Object... varargs) { assertThat(collection).hasSize(varargs.length); for (Object obj : varargs) { assertThat(collection).contains(obj); } assertThat(collection).containsExactly(varargs); } }
/** * Asserts that {@code transformation} behaves as expected for {@link * LinearTransformation#forNaN}. */ static void assertLinearTransformationNaN(LinearTransformation transformation) { assertThat(transformation.isHorizontal()).isFalse(); assertThat(transformation.isVertical()).isFalse(); assertThat(transformation.slope()).isNaN(); assertThat(transformation.transform(0.0)).isNaN(); assertThat(transformation.inverse()).isSameAs(transformation); }
void assertWrapsInterruptedException(RuntimeException e) { assertThat(e).hasMessageThat().contains("Unexpected interrupt"); assertThat(e).hasCauseThat().isInstanceOf(InterruptedException.class); }
static void assertEdgeNotInGraphErrorMessage(Throwable throwable) { assertThat(throwable).hasMessageThat().startsWith(EDGE_STRING); assertThat(throwable).hasMessageThat().contains(ERROR_ELEMENT_NOT_IN_GRAPH); }
private static void assertNotEqualLenient(TreeSet<?> unexpected, SortedSet<?> actual) { try { assertThat(actual).isNotEqualTo(unexpected); } catch (ClassCastException accepted) { } }
@Override public void testNulls() throws Exception { try { super.testNulls(); } catch (AssertionFailedError e) { assertWithMessage("Method did not throw null pointer OR element not in graph exception.") .that(e) .hasCauseThat() .hasMessageThat() .contains(ERROR_ELEMENT_NOT_IN_GRAPH); } }
public void testCharacterSimpleSplitWithNoDelimiter() { String simple = "a,b,c"; Iterable<String> letters = Splitter.on('.').split(simple); assertThat(letters).containsExactly("a,b,c").inOrder(); }
@Override public ScheduledFuture<?> scheduleAtFixedRate( Runnable command, long initialDelay, long period, TimeUnit unit) { assertThat(command).isInstanceOf(WrappedRunnable.class); lastMethodCalled = "scheduleAtFixedRate"; lastInitialDelay = initialDelay; lastDelay = period; lastUnit = unit; return null; }
private static void checkMessage(Exception e) { assertThat(e).hasMessageThat().isEqualTo("I ate 5 pies."); } }
static void assertNodeNotInGraphErrorMessage(Throwable throwable) { assertThat(throwable).hasMessageThat().startsWith(NODE_STRING); assertThat(throwable).hasMessageThat().contains(ERROR_ELEMENT_NOT_IN_GRAPH); }
@Override public Integer apply(Throwable t) { assertThat(t).isSameAs(raisedException); return 20; } });
public void testStringSplitWithTrailingDelimiter() { String trailing = "a,b,c,"; Iterable<String> letters = Splitter.on(",").split(trailing); assertThat(letters).containsExactly("a", "b", "c", "").inOrder(); }
@Override public ScheduledFuture<?> scheduleWithFixedDelay( Runnable command, long initialDelay, long delay, TimeUnit unit) { assertThat(command).isInstanceOf(WrappedRunnable.class); lastMethodCalled = "scheduleWithFixedDelay"; lastInitialDelay = initialDelay; lastDelay = delay; lastUnit = unit; return null; }
public void testStringSplitWithMultipleLetters() { Iterable<String> testStringingMotto = Splitter.on("-").split("Testing-rocks-Debugging-sucks"); assertThat(testStringingMotto) .containsExactly("Testing", "rocks", "Debugging", "sucks") .inOrder(); }
@Override public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) { assertThat(callable).isInstanceOf(WrappedCallable.class); lastMethodCalled = "scheduleCallable"; lastDelay = delay; lastUnit = unit; return null; }
public void testLimitExtraSeparatorsTrim3() { String text = ",,a,, , b ,, c,d "; Iterable<String> items = COMMA_SPLITTER.limit(3).omitEmptyStrings().trimResults().split(text); assertThat(items).containsExactly("a", "b", "c,d").inOrder(); }