gtsam/wrap/tests/testType.cpp

73 lines
2.1 KiB
C++
Raw Normal View History

2014-11-30 18:09:34 +08:00
/* ----------------------------------------------------------------------------
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
* Atlanta, Georgia 30332-0415
* All Rights Reserved
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
* See LICENSE for the license information
* -------------------------------------------------------------------------- */
/**
* @file testType.cpp
* @brief unit test for parsing a fully qualified type
* @author Frank Dellaert
* @date Nov 30, 2014
**/
#include <wrap/Qualified.h>
#include <CppUnitLite/TestHarness.h>
using namespace std;
using namespace wrap;
//******************************************************************************
TEST( spirit, grammar ) {
using classic::space_p;
2014-11-30 20:09:23 +08:00
// Create type grammar that will place result in actual
2014-11-30 18:09:34 +08:00
Qualified actual;
type_grammar type_g(actual);
2014-11-30 18:19:23 +08:00
// a class type with namespaces
EXPECT(parse("gtsam::internal::Point2", type_g, space_p).full);
EXPECT(actual.name=="Point2");
EXPECT_LONGS_EQUAL(2, actual.namespaces.size());
EXPECT(actual.namespaces[0]=="gtsam");
EXPECT(actual.namespaces[1]=="internal");
2014-11-30 20:09:23 +08:00
EXPECT(actual.category==Qualified::CLASS);
2014-11-30 18:19:23 +08:00
// a class type with no namespaces
EXPECT(parse("Point2", type_g, space_p).full);
EXPECT(actual.name=="Point2");
EXPECT(actual.namespaces.empty());
2014-11-30 20:09:23 +08:00
EXPECT(actual.category==Qualified::CLASS);
2014-11-30 18:09:34 +08:00
// an Eigen type
EXPECT(parse("Vector", type_g, space_p).full);
EXPECT(actual.name=="Vector");
2014-11-30 18:19:23 +08:00
EXPECT(actual.namespaces.empty());
2014-11-30 20:09:23 +08:00
EXPECT(actual.category==Qualified::EIGEN);
2014-11-30 18:19:23 +08:00
// a basic type
EXPECT(parse("double", type_g, space_p).full);
EXPECT(actual.name=="double");
EXPECT(actual.namespaces.empty());
2014-11-30 20:09:23 +08:00
EXPECT(actual.category==Qualified::BASIS);
2014-11-30 18:19:23 +08:00
// void
EXPECT(parse("void", type_g, space_p).full);
EXPECT(actual.name=="void");
EXPECT(actual.namespaces.empty());
2014-11-30 20:09:23 +08:00
EXPECT(actual.category==Qualified::VOID);
2014-11-30 18:09:34 +08:00
}
//******************************************************************************
int main() {
TestResult tr;
return TestRegistry::runAllTests(tr);
}
//******************************************************************************