From 7dbe9389cbb933a15169d27a1995f2f4f6d424ab Mon Sep 17 00:00:00 2001 From: dellaert Date: Mon, 1 Dec 2014 10:38:24 +0100 Subject: [PATCH] Fixed ArgumentListGrammar --- wrap/Argument.h | 3 ++- wrap/tests/testArgument.cpp | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/wrap/Argument.h b/wrap/Argument.h index 367d494c9..98a8ab7b1 100644 --- a/wrap/Argument.h +++ b/wrap/Argument.h @@ -173,7 +173,8 @@ struct ArgumentListGrammar: public classic::grammar { wrap::ArgumentList& result_; ///< successful parse will be placed in here - Argument arg, arg0; + const Argument arg0; // used to reset arg + mutable Argument arg; // temporary argument for use during parsing ArgumentGrammar argument_g; /// Construct type grammar and specify where result is placed diff --git a/wrap/tests/testArgument.cpp b/wrap/tests/testArgument.cpp index 31269c652..d99f9e4b3 100644 --- a/wrap/tests/testArgument.cpp +++ b/wrap/tests/testArgument.cpp @@ -95,16 +95,32 @@ TEST( ArgumentList, grammar ) { actual.clear(); EXPECT(parse("(char a)", g, space_p).full); + EXPECT_LONGS_EQUAL(1, actual.size()); + actual.clear(); EXPECT(parse("(unsigned char a)", g, space_p).full); + EXPECT_LONGS_EQUAL(1, actual.size()); + actual.clear(); EXPECT(parse("(Vector v, Matrix m)", g, space_p).full); + EXPECT_LONGS_EQUAL(2, actual.size()); + EXPECT(actual[0]==Argument(Qualified("Vector",Qualified::EIGEN),"v")); + EXPECT(actual[1]==Argument(Qualified("Matrix",Qualified::EIGEN),"m")); + actual.clear(); EXPECT(parse("(Point2 p)", g, space_p).full); + EXPECT_LONGS_EQUAL(1, actual.size()); + actual.clear(); EXPECT(parse("(Point2 p1, Point3 p2)", g, space_p).full); + EXPECT_LONGS_EQUAL(2, actual.size()); + EXPECT(actual[0]==Argument(Qualified("Point2"),"p1")); + EXPECT(actual[1]==Argument(Qualified("Point3"),"p2")); + actual.clear(); EXPECT(parse("(gtsam::Point2 p3)", g, space_p).full); + EXPECT_LONGS_EQUAL(1, actual.size()); + actual.clear(); } /* ************************************************************************* */