|
| 1 | +package xyz.javecs.tools.text2expr.test.kotlin |
| 2 | + |
| 3 | +import org.junit.Test |
| 4 | +import xyz.javecs.tools.text2expr.utils.TemplateConfig |
| 5 | +import kotlin.test.assertEquals |
| 6 | + |
| 7 | +class TemplateConfigTest { |
| 8 | + @Test fun template1() { |
| 9 | + val config = TemplateConfig("config/rule-template-test1.yml") |
| 10 | + assertEquals("HELLO", config.templateOf("hello")) |
| 11 | + assertEquals("", config.templateOf("world")) |
| 12 | + |
| 13 | + } |
| 14 | + |
| 15 | + @Test fun template2() { |
| 16 | + val config = TemplateConfig("config/rule-template-test2.yml") |
| 17 | + assertEquals("HELLO", config.templateOf("hello")) |
| 18 | + assertEquals("WORLD", config.templateOf("world")) |
| 19 | + } |
| 20 | + |
| 21 | + @Test fun template3() { |
| 22 | + val config = TemplateConfig("config/rule-template-test2.yml") |
| 23 | + assertEquals("HELLO", config.templateOf("hello")) |
| 24 | + assertEquals("WORLD", config.templateOf("world")) |
| 25 | + } |
| 26 | + |
| 27 | + @Test fun template4() { |
| 28 | + val config = TemplateConfig("config/rule-template-test1.yml", defaultTemplate = "Ok") |
| 29 | + assertEquals("Ok", config.templateOf("xyz")) |
| 30 | + } |
| 31 | + |
| 32 | + @Test fun template5() { |
| 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 | + |答えは、 |
| 44 | + |<value> |
| 45 | + | |
| 46 | + """.trimMargin("|") |
| 47 | + val config = TemplateConfig() |
| 48 | + assertEquals(expected, config.templateOf("default")) |
| 49 | + } |
| 50 | + |
| 51 | +} |
0 commit comments