@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()); }
@Test public void map_noCount() { MapBuilder mb = new MapBuilder().setSortKeys(true).setPrintCount(false); mb.append("dddd", "111\n222\n333"); mb.append("ccc", "444\n555\n"); mb.append("a", "666"); buf.append(mb); result += "{\n"; result += " a = 666\n"; result += " ccc = 444\n"; result += " 555\n"; result += " dddd = 111\n"; result += " 222\n"; result += " 333\n"; result += "}"; assertEquals(result, mb.toString()); }