# HG changeset patch # User Artem Tikhomirov # Date 1351268510 -7200 # Node ID 899a1b68ef0369c48d09f808eb1373167d775e09 # Parent 0205a5c4566ba1c050aba3871c8944db252d9af3 Issue 38: add test for new keys and new section diff -r 0205a5c4566b -r 899a1b68ef03 test/org/tmatesoft/hg/test/TestConfigFileParser.java --- a/test/org/tmatesoft/hg/test/TestConfigFileParser.java Fri Oct 26 18:17:15 2012 +0200 +++ b/test/org/tmatesoft/hg/test/TestConfigFileParser.java Fri Oct 26 18:21:50 2012 +0200 @@ -125,12 +125,24 @@ } @Test - public void testOnlyKeyInSection() throws IOException { + public void testDeleteOnlyKeyInSection() throws IOException { String text1 = "[sect-a]\n%skey1=value1\n%s[sect-b]\nkey3=value3\n"; String text2 = "[sect-a]\n%s\n%s[sect-b]\nkey3=value3\n"; withTwoCommentsDeleteKey1(text1, text2); } + @Test + public void testAddNewSection() throws IOException { + byte[] inp = "[sect-a]\nkey1=value1\n".getBytes(); + byte[] exp = "[sect-a]\nkey1=value1\n\n[sect-b]\nkey2 = value2\n".getBytes(); + doTest(inp, exp, new Inspector() { + + public void visit(ConfigFileParser p) { + p.add("sect-b", "key2", "value2"); + } + }); + } + private void withTwoCommentsDeleteKey1(String text1, String text2) throws IOException { String comment = "# line comment\n"; Inspector insp = new Inspector() {