Mercurial > hg4j
comparison test/org/tmatesoft/hg/test/TestConfigFileParser.java @ 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 | 02140be396d5 |
children |
comparison
equal
deleted
inserted
replaced
498:0205a5c4566b | 499:899a1b68ef03 |
---|---|
123 String text2 = "[sect-a]\n%s\n%skey2 = value 2\n[sect-b]\nkey3=value3\n"; | 123 String text2 = "[sect-a]\n%s\n%skey2 = value 2\n[sect-b]\nkey3=value3\n"; |
124 withTwoCommentsDeleteKey1(text1, text2); | 124 withTwoCommentsDeleteKey1(text1, text2); |
125 } | 125 } |
126 | 126 |
127 @Test | 127 @Test |
128 public void testOnlyKeyInSection() throws IOException { | 128 public void testDeleteOnlyKeyInSection() throws IOException { |
129 String text1 = "[sect-a]\n%skey1=value1\n%s[sect-b]\nkey3=value3\n"; | 129 String text1 = "[sect-a]\n%skey1=value1\n%s[sect-b]\nkey3=value3\n"; |
130 String text2 = "[sect-a]\n%s\n%s[sect-b]\nkey3=value3\n"; | 130 String text2 = "[sect-a]\n%s\n%s[sect-b]\nkey3=value3\n"; |
131 withTwoCommentsDeleteKey1(text1, text2); | 131 withTwoCommentsDeleteKey1(text1, text2); |
132 } | |
133 | |
134 @Test | |
135 public void testAddNewSection() throws IOException { | |
136 byte[] inp = "[sect-a]\nkey1=value1\n".getBytes(); | |
137 byte[] exp = "[sect-a]\nkey1=value1\n\n[sect-b]\nkey2 = value2\n".getBytes(); | |
138 doTest(inp, exp, new Inspector() { | |
139 | |
140 public void visit(ConfigFileParser p) { | |
141 p.add("sect-b", "key2", "value2"); | |
142 } | |
143 }); | |
132 } | 144 } |
133 | 145 |
134 private void withTwoCommentsDeleteKey1(String text1, String text2) throws IOException { | 146 private void withTwoCommentsDeleteKey1(String text1, String text2) throws IOException { |
135 String comment = "# line comment\n"; | 147 String comment = "# line comment\n"; |
136 Inspector insp = new Inspector() { | 148 Inspector insp = new Inspector() { |