DescriptionUtilsTest.java 文件源码

java
阅读 22 收藏 0 点赞 0 评论 0

项目:java-hamcrest 作者:
@Test
public void describeNestMismatchesNoEllipsisBetweenConsecutiveMismatches() throws Exception {
  Set<String> allKeys = new LinkedHashSet<>(asList("first", "second", "third", "forth"));
  StringDescription description = new StringDescription();
  Map<String, Consumer<Description>> mismatchedKeys = ImmutableMap.of(
      "second", desc -> desc.appendText("mismatch!"),
      "third", desc -> desc.appendText("mismatch!"));
  BiConsumer<String, Description> describeKey = (str, desc) -> desc.appendText(str);

  DescriptionUtils.describeNestedMismatches(allKeys, description, mismatchedKeys, describeKey);

  assertThat(description.toString(), is(
      "{\n"
          + "  ...\n"
          + "  second: mismatch!\n"
          + "  third: mismatch!\n"
          + "  ...\n"
          + "}"
  ));
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号