Пример #1
0
  @Test
  public void testAssertContainsSublistFailure() {
    List<String> actual = Arrays.asList("a", "b", "c");

    try {
      assertContainsSublist(actual, "d");
      fail("no exception thrown");
    } catch (AssertionError e) {
      assertThat(e.getMessage()).startsWith("Did not find [d] as a sublist of [a, b, c]");
    }

    try {
      assertContainsSublist(actual, "a", "c");
      fail("no exception thrown");
    } catch (AssertionError e) {
      assertThat(e.getMessage()).startsWith("Did not find [a, c] as a sublist of [a, b, c]");
    }

    try {
      assertContainsSublist(actual, "b", "c", "d");
      fail("no exception thrown");
    } catch (AssertionError e) {
      assertThat(e.getMessage()).startsWith("Did not find [b, c, d] as a sublist of [a, b, c]");
    }
  }
Пример #2
0
  @Test
  public void testAssertContainsSublistSuccess() {
    List<String> actual = Arrays.asList("a", "b", "c");

    // All single-string combinations.
    assertContainsSublist(actual, "a");
    assertContainsSublist(actual, "b");
    assertContainsSublist(actual, "c");

    // All two-string combinations.
    assertContainsSublist(actual, "a", "b");
    assertContainsSublist(actual, "b", "c");

    // The whole list.
    assertContainsSublist(actual, "a", "b", "c");
  }