|
1 | 1 | package xyz.javecs.tools.text2expr.test.kotlin |
2 | 2 |
|
3 | 3 | import org.junit.Test |
4 | | -import xyz.javecs.tools.text2expr.utils.TemplateConfig |
| 4 | +import xyz.javecs.tools.text2expr.utils.TemplateLoader |
5 | 5 | import kotlin.test.assertEquals |
6 | 6 |
|
7 | | -class TemplateConfigTest { |
| 7 | +class TemplateLoaderTest { |
8 | 8 | @Test fun template1() { |
9 | | - val config = TemplateConfig("config/rule-template-test1.yml") |
| 9 | + val config = TemplateLoader("config/rule-template-test1.yml") |
10 | 10 | assertEquals("HELLO", config.templateOf("hello")) |
11 | 11 | assertEquals("", config.templateOf("world")) |
12 | 12 |
|
13 | 13 | } |
14 | 14 |
|
15 | 15 | @Test fun template2() { |
16 | | - val config = TemplateConfig("config/rule-template-test2.yml") |
| 16 | + val config = TemplateLoader("config/rule-template-test2.yml") |
17 | 17 | assertEquals("HELLO", config.templateOf("hello")) |
18 | 18 | assertEquals("WORLD", config.templateOf("world")) |
19 | 19 | } |
20 | 20 |
|
21 | 21 | @Test fun template3() { |
22 | | - val config = TemplateConfig("config/rule-template-test2.yml") |
| 22 | + val config = TemplateLoader("config/rule-template-test2.yml") |
23 | 23 | assertEquals("HELLO", config.templateOf("hello")) |
24 | 24 | assertEquals("WORLD", config.templateOf("world")) |
25 | 25 | } |
26 | 26 |
|
27 | 27 | @Test fun template4() { |
28 | | - val config = TemplateConfig("config/rule-template-test1.yml", defaultTemplate = "Ok") |
| 28 | + val config = TemplateLoader("config/rule-template-test1.yml", defaultTemplate = "Ok") |
29 | 29 | assertEquals("Ok", config.templateOf("xyz")) |
30 | 30 | } |
31 | 31 |
|
32 | 32 | @Test fun template5() { |
33 | 33 | val expected = """ |
34 | | - |<if(variables)> |
35 | | - |<variables:{v|<v.key> = <v.value> |
36 | | - |}> |
37 | | - |<endif> |
38 | | - |<if(expr)> |
39 | | - |こうだから、 |
40 | | - |<expr:{e|<e> |
41 | | - |}> |
42 | | - |<endif> |
43 | 34 | |答えは、 |
44 | 35 | |<value> |
45 | 36 | | |
46 | 37 | """.trimMargin("|") |
47 | | - val config = TemplateConfig() |
48 | | - assertEquals(expected, config.templateOf("default")) |
| 38 | + val config = TemplateLoader() |
| 39 | + assertEquals(expected, config.templateOf("rules/length/mileToKilometer.txt")) |
49 | 40 | } |
50 | 41 |
|
51 | 42 | } |
0 commit comments