diff options
author | Chris Dyer <cdyer@cs.cmu.edu> | 2012-05-02 02:30:52 -0400 |
---|---|---|
committer | Chris Dyer <cdyer@cs.cmu.edu> | 2012-05-02 02:30:52 -0400 |
commit | 1c32f3e2831aefdf50fd226d3e1b314c804afc3b (patch) | |
tree | 69c07b672f279f69c12525fde02fa2675e63ea6f /dpmert | |
parent | 721ff772038c117da8746836533609eda7737443 (diff) |
remove dependency on gtest, remove all-static
Diffstat (limited to 'dpmert')
-rw-r--r-- | dpmert/Makefile.am | 10 | ||||
-rw-r--r-- | dpmert/lo_test.cc | 32 |
2 files changed, 16 insertions, 26 deletions
diff --git a/dpmert/Makefile.am b/dpmert/Makefile.am index 2676fb50..00768271 100644 --- a/dpmert/Makefile.am +++ b/dpmert/Makefile.am @@ -5,17 +5,15 @@ bin_PROGRAMS = \ sentserver \ sentclient -if HAVE_GTEST noinst_PROGRAMS = \ lo_test TESTS = lo_test -endif sentserver_SOURCES = sentserver.c -sentserver_LDFLAGS = -all-static -pthread +sentserver_LDFLAGS = -pthread sentclient_SOURCES = sentclient.c -sentclient_LDFLAGS = -all-static -pthread +sentclient_LDFLAGS = -pthread mr_dpmert_generate_mapper_input_SOURCES = mr_dpmert_generate_mapper_input.cc line_optimizer.cc mr_dpmert_generate_mapper_input_LDADD = $(top_srcdir)/decoder/libcdec.a $(top_srcdir)/mteval/libmteval.a $(top_srcdir)/utils/libutils.a -lz @@ -30,6 +28,6 @@ mr_dpmert_reduce_SOURCES = error_surface.cc ces.cc mr_dpmert_reduce.cc line_opti mr_dpmert_reduce_LDADD = $(top_srcdir)/decoder/libcdec.a $(top_srcdir)/mteval/libmteval.a $(top_srcdir)/utils/libutils.a -lz lo_test_SOURCES = lo_test.cc ces.cc mert_geometry.cc error_surface.cc line_optimizer.cc -lo_test_LDADD = $(GTEST_LDFLAGS) $(GTEST_LIBS) $(top_srcdir)/decoder/libcdec.a $(top_srcdir)/mteval/libmteval.a $(top_srcdir)/utils/libutils.a -lz +lo_test_LDADD = $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) $(top_srcdir)/decoder/libcdec.a $(top_srcdir)/mteval/libmteval.a $(top_srcdir)/utils/libutils.a -lz -AM_CPPFLAGS = -W -Wall -Wno-sign-compare $(GTEST_CPPFLAGS) -I$(top_srcdir)/utils -I$(top_srcdir)/decoder -I$(top_srcdir)/mteval +AM_CPPFLAGS = -DBOOST_TEST_DYN_LINK -W -Wall -Wno-sign-compare $(GTEST_CPPFLAGS) -I$(top_srcdir)/utils -I$(top_srcdir)/decoder -I$(top_srcdir)/mteval diff --git a/dpmert/lo_test.cc b/dpmert/lo_test.cc index 5d90aabb..d47a95b5 100644 --- a/dpmert/lo_test.cc +++ b/dpmert/lo_test.cc @@ -1,9 +1,12 @@ +#define BOOST_TEST_MODULE LineOptimizerTest +#include <boost/test/unit_test.hpp> +#include <boost/test/floating_point_comparison.hpp> + #include <cmath> #include <iostream> #include <fstream> #include <boost/shared_ptr.hpp> -#include <gtest/gtest.h> #include "ns.h" #include "ns_docscorer.h" @@ -20,12 +23,6 @@ using namespace std; -class OptTest : public testing::Test { - protected: - virtual void SetUp() { } - virtual void TearDown() { } -}; - const char* ref11 = "australia reopens embassy in manila"; const char* ref12 = "( afp , manila , january 2 ) australia reopened its embassy in the philippines today , which was shut down about seven weeks ago due to what was described as a specific threat of a terrorist attack ."; const char* ref21 = "australia reopened manila embassy"; @@ -35,14 +32,14 @@ const char* ref32 = "( afp report from manila , january 2 ) australia reopened i const char* ref41 = "australia to re - open its embassy to manila"; const char* ref42 = "( afp , manila , thursday ) australia reopens its embassy to manila , which was closed for the so - called \" clear \" threat of terrorist attack 7 weeks ago ."; -TEST_F(OptTest, TestCheckNaN) { +BOOST_AUTO_TEST_CASE( TestCheckNaN) { double x = 0; double y = 0; double z = x / y; - EXPECT_EQ(true, isnan(z)); + BOOST_CHECK_EQUAL(true, isnan(z)); } -TEST_F(OptTest,TestConvexHull) { +BOOST_AUTO_TEST_CASE(TestConvexHull) { boost::shared_ptr<MERTPoint> a1(new MERTPoint(-1, 0)); boost::shared_ptr<MERTPoint> b1(new MERTPoint(1, 0)); boost::shared_ptr<MERTPoint> a2(new MERTPoint(-1, 1)); @@ -55,10 +52,10 @@ TEST_F(OptTest,TestConvexHull) { ConvexHull c = a; c *= b; cerr << a << " (*) " << b << " = " << c << endl; - EXPECT_EQ(3, c.size()); + BOOST_CHECK_EQUAL(3, c.size()); } -TEST_F(OptTest,TestConvexHullInside) { +BOOST_AUTO_TEST_CASE(TestConvexHullInside) { const string json = "{\"rules\":[1,\"[X] ||| a\",2,\"[X] ||| A [1]\",3,\"[X] ||| c\",4,\"[X] ||| C [1]\",5,\"[X] ||| [1] B [2]\",6,\"[X] ||| [1] b [2]\",7,\"[X] ||| X [1]\",8,\"[X] ||| Z [1]\"],\"features\":[\"f1\",\"f2\",\"Feature_1\",\"Feature_0\",\"Model_0\",\"Model_1\",\"Model_2\",\"Model_3\",\"Model_4\",\"Model_5\",\"Model_6\",\"Model_7\"],\"edges\":[{\"tail\":[],\"feats\":[],\"rule\":1}],\"node\":{\"in_edges\":[0]},\"edges\":[{\"tail\":[0],\"feats\":[0,-0.8,1,-0.1],\"rule\":2}],\"node\":{\"in_edges\":[1]},\"edges\":[{\"tail\":[],\"feats\":[1,-1],\"rule\":3}],\"node\":{\"in_edges\":[2]},\"edges\":[{\"tail\":[2],\"feats\":[0,-0.2,1,-0.1],\"rule\":4}],\"node\":{\"in_edges\":[3]},\"edges\":[{\"tail\":[1,3],\"feats\":[0,-1.2,1,-0.2],\"rule\":5},{\"tail\":[1,3],\"feats\":[0,-0.5,1,-1.3],\"rule\":6}],\"node\":{\"in_edges\":[4,5]},\"edges\":[{\"tail\":[4],\"feats\":[0,-0.5,1,-0.8],\"rule\":7},{\"tail\":[4],\"feats\":[0,-0.7,1,-0.9],\"rule\":8}],\"node\":{\"in_edges\":[6,7]}}"; Hypergraph hg; istringstream instr(json); @@ -99,7 +96,7 @@ TEST_F(OptTest,TestConvexHullInside) { } } -TEST_F(OptTest, TestS1) { +BOOST_AUTO_TEST_CASE( TestS1) { int fPhraseModel_0 = FD::Convert("PhraseModel_0"); int fPhraseModel_1 = FD::Convert("PhraseModel_1"); int fPhraseModel_2 = FD::Convert("PhraseModel_2"); @@ -177,7 +174,7 @@ TEST_F(OptTest, TestS1) { double m = LineOptimizer::LineOptimize(metric,es, LineOptimizer::MAXIMIZE_SCORE, &score); clock_t t_opt=clock(); cerr << "line optimizer returned: " << m << " (SCORE=" << score << ")\n"; - EXPECT_FLOAT_EQ(0.48719698, score); + BOOST_CHECK_CLOSE(0.48719698, score, 1e-5); SparseVector<double> res = axis; res *= m; res += wts; @@ -193,7 +190,7 @@ TEST_F(OptTest, TestS1) { cerr << TD::GetString(t2) << endl; } -TEST_F(OptTest,TestZeroOrigin) { +BOOST_AUTO_TEST_CASE(TestZeroOrigin) { const string json = "{\"rules\":[1,\"[X7] ||| blA ||| without ||| LHSProb=3.92173 LexE2F=2.90799 LexF2E=1.85003 GenerativeProb=10.5381 RulePenalty=1 XFE=2.77259 XEF=0.441833 LabelledEF=2.63906 LabelledFE=4.96981 LogRuleCount=0.693147\",2,\"[X7] ||| blA ||| except ||| LHSProb=4.92173 LexE2F=3.90799 LexF2E=1.85003 GenerativeProb=11.5381 RulePenalty=1 XFE=2.77259 XEF=1.44183 LabelledEF=2.63906 LabelledFE=4.96981 LogRuleCount=1.69315\",3,\"[S] ||| [X7,1] ||| [1] ||| GlueTop=1\",4,\"[X28] ||| EnwAn ||| title ||| LHSProb=3.96802 LexE2F=2.22462 LexF2E=1.83258 GenerativeProb=10.0863 RulePenalty=1 XFE=0 XEF=1.20397 LabelledEF=1.20397 LabelledFE=-1.98341e-08 LogRuleCount=1.09861\",5,\"[X0] ||| EnwAn ||| funny ||| LHSProb=3.98479 LexE2F=1.79176 LexF2E=3.21888 GenerativeProb=11.1681 RulePenalty=1 XFE=0 XEF=2.30259 LabelledEF=2.30259 LabelledFE=0 LogRuleCount=0 SingletonRule=1\",6,\"[X8] ||| [X7,1] EnwAn ||| entitled [1] ||| LHSProb=3.82533 LexE2F=3.21888 LexF2E=2.52573 GenerativeProb=11.3276 RulePenalty=1 XFE=1.20397 XEF=1.20397 LabelledEF=2.30259 LabelledFE=2.30259 LogRuleCount=0 SingletonRule=1\",7,\"[S] ||| [S,1] [X28,2] ||| [1] [2] ||| Glue=1\",8,\"[S] ||| [S,1] [X0,2] ||| [1] [2] ||| Glue=1\",9,\"[S] ||| [X8,1] ||| [1] ||| GlueTop=1\",10,\"[Goal] ||| [S,1] ||| [1]\"],\"features\":[\"PassThrough\",\"Glue\",\"GlueTop\",\"LanguageModel\",\"WordPenalty\",\"LHSProb\",\"LexE2F\",\"LexF2E\",\"GenerativeProb\",\"RulePenalty\",\"XFE\",\"XEF\",\"LabelledEF\",\"LabelledFE\",\"LogRuleCount\",\"SingletonRule\"],\"edges\":[{\"tail\":[],\"spans\":[0,1,-1,-1],\"feats\":[5,3.92173,6,2.90799,7,1.85003,8,10.5381,9,1,10,2.77259,11,0.441833,12,2.63906,13,4.96981,14,0.693147],\"rule\":1},{\"tail\":[],\"spans\":[0,1,-1,-1],\"feats\":[5,4.92173,6,3.90799,7,1.85003,8,11.5381,9,1,10,2.77259,11,1.44183,12,2.63906,13,4.96981,14,1.69315],\"rule\":2}],\"node\":{\"in_edges\":[0,1],\"cat\":\"X7\"},\"edges\":[{\"tail\":[0],\"spans\":[0,1,-1,-1],\"feats\":[2,1],\"rule\":3}],\"node\":{\"in_edges\":[2],\"cat\":\"S\"},\"edges\":[{\"tail\":[],\"spans\":[1,2,-1,-1],\"feats\":[5,3.96802,6,2.22462,7,1.83258,8,10.0863,9,1,11,1.20397,12,1.20397,13,-1.98341e-08,14,1.09861],\"rule\":4}],\"node\":{\"in_edges\":[3],\"cat\":\"X28\"},\"edges\":[{\"tail\":[],\"spans\":[1,2,-1,-1],\"feats\":[5,3.98479,6,1.79176,7,3.21888,8,11.1681,9,1,11,2.30259,12,2.30259,15,1],\"rule\":5}],\"node\":{\"in_edges\":[4],\"cat\":\"X0\"},\"edges\":[{\"tail\":[0],\"spans\":[0,2,-1,-1],\"feats\":[5,3.82533,6,3.21888,7,2.52573,8,11.3276,9,1,10,1.20397,11,1.20397,12,2.30259,13,2.30259,15,1],\"rule\":6}],\"node\":{\"in_edges\":[5],\"cat\":\"X8\"},\"edges\":[{\"tail\":[1,2],\"spans\":[0,2,-1,-1],\"feats\":[1,1],\"rule\":7},{\"tail\":[1,3],\"spans\":[0,2,-1,-1],\"feats\":[1,1],\"rule\":8},{\"tail\":[4],\"spans\":[0,2,-1,-1],\"feats\":[2,1],\"rule\":9}],\"node\":{\"in_edges\":[6,7,8],\"cat\":\"S\"},\"edges\":[{\"tail\":[5],\"spans\":[0,2,-1,-1],\"feats\":[],\"rule\":10}],\"node\":{\"in_edges\":[9],\"cat\":\"Goal\"}}"; Hypergraph hg; istringstream instr(json); @@ -228,8 +225,3 @@ TEST_F(OptTest,TestZeroOrigin) { ComputeErrorSurface(*scorer1, envs[0], &es[0], metric, hg); } -int main(int argc, char **argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} - |