Skip to content

Commit 58769d6

Browse files
committed
ポンドとオンスをキログラムに変換しました。
1 parent 7581e20 commit 58769d6

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

src/main/resources/rule-template.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ templates:
88
- rule: rules/weight/poundToKilogram.txt
99
template: templates/kilogram.st
1010
- rule: rules/weight/ounceToGram.txt
11-
template: templates/gram.st
11+
template: templates/gram.st
12+
- rule: rules/weight/poundOunceToKilogram.txt
13+
template: templates/kilogram.st
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
x=P2:数
2+
SF:ポンド|"lb"
3+
y=P2:数
4+
SF:オンス|"oz"
5+
SF?キログラム|"kg"|"kg"
6+
7+
kg = (x * 0.45359237) + (y * 0.0283495)
8+
format(kg, 5)

src/test/kotlin/xyz/javecs/tools/text2expr/test/kotlin/rules/weight/WeightTest.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,9 @@ class WeightTest {
2626
assertEquals("113.3981g", text2Expr.eval("4オンス?", rendered = true))
2727
}
2828

29+
@Test fun poundOunceToKilogram1() {
30+
assertEquals("3.40194", text2Expr.eval("7ポンド8オンスは、なんキログラム?"))
31+
assertEquals("3.40194kg", text2Expr.eval("7ポンド8オンスは?", rendered = true))
32+
assertEquals("1.02058", text2Expr.eval("2lb4ozは?"))
33+
}
2934
}

0 commit comments

Comments
 (0)