test virtual, cleaned up other test
parent
aaba18c61d
commit
9f2e6562c2
|
@ -160,7 +160,6 @@ TEST( Class, Grammar ) {
|
|||
EXPECT_LONGS_EQUAL(ReturnType::EIGEN, rv4.type1.category);
|
||||
}
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
TEST( Class, TemplateSubstition ) {
|
||||
|
||||
|
@ -171,10 +170,10 @@ TEST( Class, TemplateSubstition ) {
|
|||
Template t;
|
||||
ClassGrammar g(cls, t);
|
||||
|
||||
string markup(
|
||||
string("template<T = {void, double, Matrix, Point3}> class Point2 { \n")
|
||||
+ string(" T myMethod(const T& t) const; \n")
|
||||
+ string("};"));
|
||||
string markup(string("template<T = {void, double, Matrix, Point3}>"
|
||||
"class Point2 {"
|
||||
" T myMethod(const T& t) const;"
|
||||
"};"));
|
||||
|
||||
EXPECT(parse(markup.c_str(), g, space_p).full);
|
||||
|
||||
|
@ -190,58 +189,74 @@ TEST( Class, TemplateSubstition ) {
|
|||
EXPECT(assert_equal("T", rv2.type1.name()));
|
||||
EXPECT_LONGS_EQUAL(ReturnType::CLASS, rv2.type1.category);
|
||||
|
||||
// Generate some expected values for qualified types
|
||||
Qualified q_void("void", Qualified::VOID);
|
||||
Qualified q_double("double", Qualified::BASIS);
|
||||
Qualified q_Matrix("Matrix", Qualified::EIGEN);
|
||||
Qualified q_Point3("Point3", Qualified::CLASS);
|
||||
|
||||
EXPECT_LONGS_EQUAL(4, t.nrValues());
|
||||
EXPECT(t.argName()=="T");
|
||||
EXPECT(t[0]==Qualified("void",Qualified::VOID));
|
||||
EXPECT(t[1]==Qualified("double",Qualified::BASIS));
|
||||
EXPECT(t[2]==Qualified("Matrix",Qualified::EIGEN));
|
||||
EXPECT(t[3]==Qualified("Point3",Qualified::CLASS));
|
||||
EXPECT(t[0]==q_void);
|
||||
EXPECT(t[1]==q_double);
|
||||
EXPECT(t[2]==q_Matrix);
|
||||
EXPECT(t[3]==q_Point3);
|
||||
|
||||
vector<Class> classes = cls.expandTemplate(t.argName(),
|
||||
t.argValues());
|
||||
vector<Class> classes = cls.expandTemplate(t.argName(), t.argValues());
|
||||
|
||||
// check the number of new classes is four
|
||||
EXPECT_LONGS_EQUAL(4, classes.size());
|
||||
|
||||
|
||||
// check return types
|
||||
EXPECT(classes[0].method("myMethod").returnValue(0).type1 == Qualified("void",Qualified::VOID));
|
||||
EXPECT(classes[1].method("myMethod").returnValue(0).type1 == Qualified("double",Qualified::BASIS));
|
||||
EXPECT(classes[2].method("myMethod").returnValue(0).type1 == Qualified("Matrix",Qualified::EIGEN));
|
||||
EXPECT(classes[3].method("myMethod").returnValue(0).type1 == Qualified("Point3",Qualified::CLASS));
|
||||
EXPECT( classes[0].method("myMethod").returnValue(0).type1 == q_void);
|
||||
EXPECT( classes[1].method("myMethod").returnValue(0).type1 == q_double);
|
||||
EXPECT( classes[2].method("myMethod").returnValue(0).type1 == q_Matrix);
|
||||
EXPECT( classes[3].method("myMethod").returnValue(0).type1 == q_Point3);
|
||||
|
||||
// check the argument types
|
||||
EXPECT(classes[0].method("myMethod").argumentList(0)[0].type == Qualified("void",Qualified::VOID));
|
||||
EXPECT(classes[1].method("myMethod").argumentList(0)[0].type == Qualified("double",Qualified::BASIS));
|
||||
EXPECT(classes[2].method("myMethod").argumentList(0)[0].type == Qualified("Matrix",Qualified::EIGEN));
|
||||
EXPECT(classes[3].method("myMethod").argumentList(0)[0].type == Qualified("Point3",Qualified::CLASS));
|
||||
EXPECT( classes[0].method("myMethod").argumentList(0)[0].type == q_void);
|
||||
EXPECT( classes[1].method("myMethod").argumentList(0)[0].type == q_double);
|
||||
EXPECT( classes[2].method("myMethod").argumentList(0)[0].type == q_Matrix);
|
||||
EXPECT( classes[3].method("myMethod").argumentList(0)[0].type == q_Point3);
|
||||
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
TEST(Class, Template) {
|
||||
|
||||
using classic::space_p;
|
||||
|
||||
using classic::space_p;
|
||||
// Create type grammar that will place result in cls
|
||||
Class cls;
|
||||
Template t;
|
||||
ClassGrammar g(cls, t);
|
||||
|
||||
// Create type grammar that will place result in cls
|
||||
Class cls;
|
||||
Template t;
|
||||
ClassGrammar g(cls, t);
|
||||
string markup(
|
||||
string(
|
||||
"template<T = {Vector, Matrix}>"
|
||||
" virtual class PriorFactor : gtsam::NoiseModelFactor {"
|
||||
" PriorFactor(size_t key, const T& prior, const gtsam::noiseModel::Base* noiseModel); "
|
||||
" T prior() const; "
|
||||
" void serialize() const; "
|
||||
"};"));
|
||||
|
||||
string markup(
|
||||
string("template<T = {Vector, Matrix}>"
|
||||
" virtual class PriorFactor : gtsam::NoiseModelFactor {"
|
||||
" PriorFactor(size_t key, const T& prior, const gtsam::noiseModel::Base* noiseModel); "
|
||||
" T prior() const; "
|
||||
" void serialize() const; "
|
||||
"};" ));
|
||||
|
||||
EXPECT(parse(markup.c_str(), g, space_p).full);
|
||||
EXPECT(parse(markup.c_str(), g, space_p).full);
|
||||
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
//******************************************************************************
|
||||
TEST( Class, Virtualness ) {
|
||||
using classic::space_p;
|
||||
Class cls;
|
||||
Template t;
|
||||
ClassGrammar g(cls, t);
|
||||
string markup("virtual class Point3 {};");
|
||||
EXPECT(parse(markup.c_str(), g, space_p).full);
|
||||
EXPECT(cls.isVirtual);
|
||||
}
|
||||
//******************************************************************************
|
||||
int main() {
|
||||
TestResult tr;
|
||||
return TestRegistry::runAllTests(tr);
|
||||
}
|
||||
/* ************************************************************************* */
|
||||
//******************************************************************************
|
||||
|
|
Loading…
Reference in New Issue