diff --git a/tests/data/example.ccl b/tests/data/example.ccl index bdabf498699f011abd580574685a2e2e47fcaa0c..3cbd81c9de6d0a878510c558a04eb8a416f11bbf 100644 --- a/tests/data/example.ccl +++ b/tests/data/example.ccl @@ -4,6 +4,7 @@ After the --- line comes the first test -- the operator string, followed by an e If the first operator line is "position=XXX", position is parsed as an int and that is used as the current position in the sentence for this and any following tests. Default position is 0. Tests are separated from one another by a --- line. This test loads no sentence, but can change the position anyway. Tagset is kipi by default. +Variable state can be checked by a name=value lines after the expected output. tagset=ikipi --- equal(["aaa"], "aaa") @@ -13,3 +14,10 @@ True lower(["A"]) ["a"] +--- +setvar($b:A, setvar($t:B, subst)) + +True +A=True +B={subst} + diff --git a/tests/data/iterations.ccl b/tests/data/iterations.ccl index 60b5052c329cc2bd79e4c686729ce0c0f652da65..f17e4ae05f3b8c69c16e6b8c5e25f069cdaca90d 100644 --- a/tests/data/iterations.ccl +++ b/tests/data/iterations.ccl @@ -1,6 +1,11 @@ tagset=kipi +sentence=t01.xml --- rlook(begin, end, $Test, True) True --- +llook(0, end, $V, False) + +False +V=nowhere diff --git a/tests/datadriven.cpp b/tests/datadriven.cpp index 5b62d31a324a2038455140271402a69a8490bde3..e0ee1516599c49e8223f0725c8568fd1ea615a10 100644 --- a/tests/datadriven.cpp +++ b/tests/datadriven.cpp @@ -98,7 +98,24 @@ void test_one_item_actual(const compare_test& c) expected_output = ""; operator_string = ""; ++line_no; - std::getline(ifs_in, line); + while (ifs_in.good() && line != "---" && line != "") { + std::getline(ifs_in, line); + std::vector<std::string> fields; + boost::algorithm::split(fields, line, boost::is_any_of(separators)); + if (fields.size() == 2) { + boost::shared_ptr<Wccl::Value> v; + v = fu.variables()->get<Wccl::Value>(fields[0]); + if (!v) { + BOOST_ERROR("Invalid variable name in test: " + << fields[0] << " on line " << line_no); + } else if (v->to_string(tagset) != fields[1]) { + BOOST_ERROR("Variable " << fields[0] + << "value mismatch on line " + << line_no << "\n: expected " << fields[1] + << " got " << v->to_string(tagset)); + } + } + } BOOST_REQUIRE(line == "---" || line == ""); } else { if (operator_string.empty() && line.substr(0, 9) == "position=") {