From 2a0b7ef3b53d20fb739fbee0092c1b62ac3e2e77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Mon, 6 Mar 2017 15:49:40 +0100 Subject: [PATCH] Added tests covering simple choice rules. --- tests/TestTranslation.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/TestTranslation.cpp b/tests/TestTranslation.cpp index 9cfcdfa..491de37 100644 --- a/tests/TestTranslation.cpp +++ b/tests/TestTranslation.cpp @@ -204,4 +204,28 @@ TEST_CASE("[translation] Rules are translated correctly", "[translation]") REQUIRE(output.str() == "V1 in q(s(t(_X1))) and V2 in u(_X2) and exists X1, X2 (X1 in v(w(_X2)) and X2 in z(_X1) and u(X1, X2)) -> p(V1, V2)\n"); } + + SECTION("choice rule (simple)") + { + input << "{p}."; + anthem::translate("input", input, context); + + REQUIRE(output.str() == "p -> p\n"); + } + + SECTION("choice rule (two elements)") + { + input << "{p; q}."; + anthem::translate("input", input, context); + + REQUIRE(output.str() == "p or q -> p or q\n"); + } + + SECTION("choice rule (n-ary elements)") + { + input << "{p(1..3, N); q(2..4)}."; + anthem::translate("input", input, context); + + REQUIRE(output.str() == "V1 in (1..3) and V2 in N and V3 in (2..4) and (p(V1, V2) or q(V3)) -> p(V1, V2) or q(V3)\n"); + } }