diff options
author | Patrick Simianer <simianer@cl.uni-heidelberg.de> | 2012-05-02 15:03:24 +0200 |
---|---|---|
committer | Patrick Simianer <simianer@cl.uni-heidelberg.de> | 2012-05-02 15:03:24 +0200 |
commit | 45cb0f7426de97cc181079daf3ca04dbc52dee3c (patch) | |
tree | abd2158a559480504525082760a618c78847fcf7 /decoder/trule_test.cc | |
parent | 5a8ef8ba65b244837e9cedbd64793b82bf284f93 (diff) | |
parent | 1c32f3e2831aefdf50fd226d3e1b314c804afc3b (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'decoder/trule_test.cc')
-rw-r--r-- | decoder/trule_test.cc | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/decoder/trule_test.cc b/decoder/trule_test.cc index dfb6d417..0cb7e2e8 100644 --- a/decoder/trule_test.cc +++ b/decoder/trule_test.cc @@ -1,19 +1,14 @@ #include "trule.h" -#include <gtest/gtest.h> -#include <cassert> +#define BOOST_TEST_MODULE TRuleTest +#include <boost/test/unit_test.hpp> +#include <boost/test/floating_point_comparison.hpp> #include <iostream> #include "tdict.h" using namespace std; -class TRuleTest : public testing::Test { - protected: - virtual void SetUp() { } - virtual void TearDown() { } -}; - -TEST_F(TRuleTest,TestFSubstitute) { +BOOST_AUTO_TEST_CASE(TestFSubstitute) { TRule r1("[X] ||| ob [X,1] [X,2] sah . ||| whether [X,1] saw [X,2] . ||| 0.99"); TRule r2("[X] ||| ich ||| i ||| 1.0"); TRule r3("[X] ||| ihn ||| him ||| 1.0"); @@ -32,34 +27,29 @@ TEST_F(TRuleTest,TestFSubstitute) { assert(TD::GetString(res) == "ob ich ihn sah ."); } -TEST_F(TRuleTest,TestPhrasetableRule) { +BOOST_AUTO_TEST_CASE(TestPhrasetableRule) { TRulePtr t(TRule::CreateRulePhrasetable("gato ||| cat ||| PhraseModel_0=-23.2;Foo=1;Bar=12")); cerr << t->AsString() << endl; assert(t->scores_.size() == 3); }; -TEST_F(TRuleTest,TestMonoRule) { +BOOST_AUTO_TEST_CASE(TestMonoRule) { TRulePtr m(TRule::CreateRuleMonolingual("[LHS] ||| term1 [NT] term2 [NT2] [NT3]")); assert(m->Arity() == 3); cerr << m->AsString() << endl; TRulePtr m2(TRule::CreateRuleMonolingual("[LHS] ||| term1 [NT] term2 [NT2] [NT3] ||| Feature1=0.23")); assert(m2->Arity() == 3); cerr << m2->AsString() << endl; - EXPECT_FLOAT_EQ(m2->scores_.value(FD::Convert("Feature1")), 0.23); + BOOST_CHECK_CLOSE(m2->scores_.value(FD::Convert("Feature1")), 0.23, 1e-6); } -TEST_F(TRuleTest,TestRuleR) { +BOOST_AUTO_TEST_CASE(TestRuleR) { TRule t6; t6.ReadFromString("[X] ||| den [X,1] sah [X,2] . ||| [X,2] saw the [X,1] . ||| 0.12321 0.23232 0.121"); cerr << "TEXT: " << t6.AsString() << endl; - EXPECT_EQ(t6.Arity(), 2); - EXPECT_EQ(t6.e_[0], -1); - EXPECT_EQ(t6.e_[3], 0); -} - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + BOOST_CHECK_EQUAL(t6.Arity(), 2); + BOOST_CHECK_EQUAL(t6.e_[0], -1); + BOOST_CHECK_EQUAL(t6.e_[3], 0); } |