示例#1
0
  @Test
  public void list_clear() {
    CollectionBuilder cb = new CollectionBuilder().setPrintCount(true);

    cb.append("111\n222\n333");
    cb.append("444\n555\n");
    cb.append("666");

    buf.append("list ");
    buf.append(cb);

    result += "[\n";
    result += "  [1/3] 111\n";
    result += "        222\n";
    result += "        333\n";
    result += "  [2/3] 444\n";
    result += "        555\n";
    result += "  [3/3] 666\n";
    result += "]";

    assertEquals("list " + result, buf.toString());
    assertEquals(result, cb.toString());

    cb.clear();
    buf.clear();

    assertEquals("[]", cb.toString());
    assertEquals("", buf.toString());
  }
示例#2
0
  @Test
  public void map_clear() {
    MapBuilder mb = new MapBuilder().setSortKeys(true).setPrintCount(true);

    mb.append("dddd", "111\n222\n333");
    mb.append("ccc", "444\n555\n");
    mb.append("a", "666");

    buf.append("map ");
    buf.append(mb);

    result += "{\n";
    result += "  [1/3] a    = 666\n";
    result += "  [2/3] ccc  = 444\n";
    result += "               555\n";
    result += "  [3/3] dddd = 111\n";
    result += "               222\n";
    result += "               333\n";
    result += "}";

    assertEquals("map " + result, buf.toString());
    assertEquals(result, mb.toString());

    mb.clear();
    buf.clear();

    assertEquals("{}", mb.toString());
    assertEquals("", buf.toString());
  }