Mercurial > jhg
changeset 499:899a1b68ef03
Issue 38: add test for new keys and new section
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 26 Oct 2012 18:21:50 +0200 |
parents | 0205a5c4566b |
children | 465316bf97e8 |
files | test/org/tmatesoft/hg/test/TestConfigFileParser.java |
diffstat | 1 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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() {