Skip to content

Commit 60b93c7

Browse files
committed
Update tests.
1 parent a322ca8 commit 60b93c7

1 file changed

Lines changed: 98 additions & 10 deletions

File tree

kilo-client/src/test/java/org/httprpc/kilo/io/TemplateEncoderTest.java

Lines changed: 98 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void testPath() throws IOException {
9090
}
9191

9292
@Test
93-
public void testConditionalSection1() throws IOException {
93+
public void testConditionalSection() throws IOException {
9494
var templateEncoder = new TemplateEncoder(getClass(), "conditional.txt");
9595

9696
var writer = new StringWriter();
@@ -101,7 +101,7 @@ public void testConditionalSection1() throws IOException {
101101
}
102102

103103
@Test
104-
public void testConditionalSection2a() throws IOException {
104+
public void testConditionalSectionList() throws IOException {
105105
var templateEncoder = new TemplateEncoder(getClass(), "conditional.txt");
106106

107107
var writer = new StringWriter();
@@ -112,7 +112,7 @@ public void testConditionalSection2a() throws IOException {
112112
}
113113

114114
@Test
115-
public void testConditionalSection2b() throws IOException {
115+
public void testConditionalSectionEmptyList() throws IOException {
116116
var templateEncoder = new TemplateEncoder(getClass(), "conditional.txt");
117117

118118
var writer = new StringWriter();
@@ -123,7 +123,51 @@ public void testConditionalSection2b() throws IOException {
123123
}
124124

125125
@Test
126-
public void testConditionalSection3a() throws IOException {
126+
public void testConditionalSectionString() throws IOException {
127+
var templateEncoder = new TemplateEncoder(getClass(), "conditional.txt");
128+
129+
var writer = new StringWriter();
130+
131+
templateEncoder.write(mapOf(entry("a", "abc")), writer);
132+
133+
assertEquals("found", writer.toString());
134+
}
135+
136+
@Test
137+
public void testConditionalSectionEmptyString() throws IOException {
138+
var templateEncoder = new TemplateEncoder(getClass(), "conditional.txt");
139+
140+
var writer = new StringWriter();
141+
142+
templateEncoder.write(mapOf(entry("a", "")), writer);
143+
144+
assertEquals("", writer.toString());
145+
}
146+
147+
@Test
148+
public void testConditionalSectionNonZero() throws IOException {
149+
var templateEncoder = new TemplateEncoder(getClass(), "conditional.txt");
150+
151+
var writer = new StringWriter();
152+
153+
templateEncoder.write(mapOf(entry("a", 123)), writer);
154+
155+
assertEquals("found", writer.toString());
156+
}
157+
158+
@Test
159+
public void testConditionalSectionZero() throws IOException {
160+
var templateEncoder = new TemplateEncoder(getClass(), "conditional.txt");
161+
162+
var writer = new StringWriter();
163+
164+
templateEncoder.write(mapOf(entry("a", 0)), writer);
165+
166+
assertEquals("", writer.toString());
167+
}
168+
169+
@Test
170+
public void testConditionalSectionTrue() throws IOException {
127171
var templateEncoder = new TemplateEncoder(getClass(), "conditional.txt");
128172

129173
var writer = new StringWriter();
@@ -134,7 +178,7 @@ public void testConditionalSection3a() throws IOException {
134178
}
135179

136180
@Test
137-
public void testConditionalSection3b() throws IOException {
181+
public void testConditionalSectionFalse() throws IOException {
138182
var templateEncoder = new TemplateEncoder(getClass(), "conditional.txt");
139183

140184
var writer = new StringWriter();
@@ -316,7 +360,7 @@ public void testMapRepeatingSection2() throws IOException {
316360
}
317361

318362
@Test
319-
public void testInvertedSection1() throws IOException {
363+
public void testInvertedSection() throws IOException {
320364
var templateEncoder = new TemplateEncoder(getClass(), "inverted.txt");
321365

322366
var writer = new StringWriter();
@@ -327,7 +371,7 @@ public void testInvertedSection1() throws IOException {
327371
}
328372

329373
@Test
330-
public void testInvertedSection2a() throws IOException {
374+
public void testInvertedSectionList() throws IOException {
331375
var templateEncoder = new TemplateEncoder(getClass(), "inverted.txt");
332376

333377
var writer = new StringWriter();
@@ -338,7 +382,7 @@ public void testInvertedSection2a() throws IOException {
338382
}
339383

340384
@Test
341-
public void testInvertedSection2b() throws IOException {
385+
public void testInvertedSectionEmptyList() throws IOException {
342386
var templateEncoder = new TemplateEncoder(getClass(), "inverted.txt");
343387

344388
var writer = new StringWriter();
@@ -349,7 +393,51 @@ public void testInvertedSection2b() throws IOException {
349393
}
350394

351395
@Test
352-
public void testInvertedSection3a() throws IOException {
396+
public void testInvertedSectionString() throws IOException {
397+
var templateEncoder = new TemplateEncoder(getClass(), "inverted.txt");
398+
399+
var writer = new StringWriter();
400+
401+
templateEncoder.write(mapOf(entry("a", "abc")), writer);
402+
403+
assertEquals("", writer.toString());
404+
}
405+
406+
@Test
407+
public void testInvertedSectionEmptyString() throws IOException {
408+
var templateEncoder = new TemplateEncoder(getClass(), "inverted.txt");
409+
410+
var writer = new StringWriter();
411+
412+
templateEncoder.write(mapOf(entry("a", "")), writer);
413+
414+
assertEquals("not found", writer.toString());
415+
}
416+
417+
@Test
418+
public void testInvertedSectionNonZero() throws IOException {
419+
var templateEncoder = new TemplateEncoder(getClass(), "inverted.txt");
420+
421+
var writer = new StringWriter();
422+
423+
templateEncoder.write(mapOf(entry("a", 123)), writer);
424+
425+
assertEquals("", writer.toString());
426+
}
427+
428+
@Test
429+
public void testInvertedSectionZero() throws IOException {
430+
var templateEncoder = new TemplateEncoder(getClass(), "inverted.txt");
431+
432+
var writer = new StringWriter();
433+
434+
templateEncoder.write(mapOf(entry("a", 0)), writer);
435+
436+
assertEquals("not found", writer.toString());
437+
}
438+
439+
@Test
440+
public void testInvertedSectionTrue() throws IOException {
353441
var templateEncoder = new TemplateEncoder(getClass(), "inverted.txt");
354442

355443
var writer = new StringWriter();
@@ -360,7 +448,7 @@ public void testInvertedSection3a() throws IOException {
360448
}
361449

362450
@Test
363-
public void testInvertedSection3b() throws IOException {
451+
public void testInvertedSectionFalse() throws IOException {
364452
var templateEncoder = new TemplateEncoder(getClass(), "inverted.txt");
365453

366454
var writer = new StringWriter();

0 commit comments

Comments
 (0)