| 
									
										
										
										
											2011-10-14 02:41:56 +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 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * -------------------------------------------------------------------------- */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2011-10-14 11:23:14 +08:00
										 |  |  |  * @file testWrap.cpp | 
					
						
							|  |  |  |  * @brief Unit test for wrap.c | 
					
						
							|  |  |  |  * @author Frank Dellaert | 
					
						
							| 
									
										
										
										
											2011-10-14 02:41:56 +08:00
										 |  |  |  **/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-26 04:03:28 +08:00
										 |  |  | #include <wrap/utilities.h>
 | 
					
						
							|  |  |  | #include <wrap/Module.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <CppUnitLite/TestHarness.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <boost/assign/std/vector.hpp>
 | 
					
						
							|  |  |  | #include <boost/filesystem.hpp>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-09 04:51:05 +08:00
										 |  |  | #include <stdlib.h>
 | 
					
						
							| 
									
										
										
										
											2011-10-14 02:41:56 +08:00
										 |  |  | #include <iostream>
 | 
					
						
							|  |  |  | #include <fstream>
 | 
					
						
							|  |  |  | #include <sstream>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | using namespace std; | 
					
						
							| 
									
										
										
										
											2011-12-16 03:39:11 +08:00
										 |  |  | using namespace boost::assign; | 
					
						
							| 
									
										
										
										
											2011-12-03 00:43:15 +08:00
										 |  |  | using namespace wrap; | 
					
						
							| 
									
										
										
										
											2012-05-24 05:23:27 +08:00
										 |  |  | namespace fs = boost::filesystem; | 
					
						
							| 
									
										
										
										
											2011-12-07 11:05:37 +08:00
										 |  |  | static bool enable_verbose = false; | 
					
						
							| 
									
										
										
										
											2011-10-14 02:41:56 +08:00
										 |  |  | #ifdef TOPSRCDIR
 | 
					
						
							|  |  |  | static string topdir = TOPSRCDIR; | 
					
						
							|  |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2011-12-07 11:05:30 +08:00
										 |  |  | static string topdir = "TOPSRCDIR_NOT_CONFIGURED"; // If TOPSRCDIR is not defined, we error
 | 
					
						
							| 
									
										
										
										
											2011-10-14 02:41:56 +08:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-16 03:39:11 +08:00
										 |  |  | typedef vector<string> strvec; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-14 02:41:56 +08:00
										 |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | TEST( wrap, ArgumentList ) { | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   ArgumentList args; | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |   Argument arg1; arg1.type.name_ = "double"; arg1.name = "x"; | 
					
						
							|  |  |  |   Argument arg2; arg2.type.name_ = "double"; arg2.name = "y"; | 
					
						
							|  |  |  |   Argument arg3; arg3.type.name_ = "double"; arg3.name = "z"; | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   args.push_back(arg1); | 
					
						
							|  |  |  |   args.push_back(arg2); | 
					
						
							|  |  |  |   args.push_back(arg3); | 
					
						
							|  |  |  |   EXPECT(assert_equal("ddd", args.signature())); | 
					
						
							|  |  |  |   EXPECT(assert_equal("double,double,double", args.types())); | 
					
						
							|  |  |  |   EXPECT(assert_equal("x,y,z", args.names())); | 
					
						
							| 
									
										
										
										
											2011-10-14 02:41:56 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2013-08-07 02:04:40 +08:00
										 |  |  | TEST( wrap, check_exception ) { | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   THROWS_EXCEPTION(Module("/notarealpath", "geometry",enable_verbose)); | 
					
						
							|  |  |  |   CHECK_EXCEPTION(Module("/alsonotarealpath", "geometry",enable_verbose), CantOpenFile); | 
					
						
							| 
									
										
										
										
											2011-12-08 01:55:38 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-15 00:04:45 +08:00
										 |  |  | //  // TODO: matlab_code does not throw this anymore, so check constructor
 | 
					
						
							|  |  |  | //  fs::remove_all("actual_deps"); // clean out previous generated code
 | 
					
						
							|  |  |  | //  string path = topdir + "/wrap/tests";
 | 
					
						
							|  |  |  | //  Module module(path.c_str(), "testDependencies",enable_verbose);
 | 
					
						
							|  |  |  | //  CHECK_EXCEPTION(module.matlab_code("actual_deps"), DependencyMissing);
 | 
					
						
							| 
									
										
										
										
											2011-10-14 02:41:56 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:19 +08:00
										 |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2014-11-13 06:22:59 +08:00
										 |  |  | TEST( wrap, Small ) { | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:19 +08:00
										 |  |  |   string moduleName("gtsam"); | 
					
						
							|  |  |  |   Module module(moduleName, true); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   string markup( | 
					
						
							|  |  |  |       string("class Point2 {                \n") + | 
					
						
							|  |  |  |       string(" double x() const;            \n") +   // Method 1
 | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:20 +08:00
										 |  |  |       string(" Matrix returnMatrix() const;   \n") + // Method 2
 | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:19 +08:00
										 |  |  |       string(" Point2 returnPoint2() const; \n") +   // Method 3
 | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:20 +08:00
										 |  |  |       string(" static Vector returnVector(); \n") +  // Static Method 1
 | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:19 +08:00
										 |  |  |       string("};\n")); | 
					
						
							|  |  |  |   module.parseMarkup(markup); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // check return types
 | 
					
						
							|  |  |  |   LONGS_EQUAL(1, module.classes.size()); | 
					
						
							|  |  |  |   Class cls = module.classes.front(); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |   EXPECT(assert_equal("Point2", cls.name())); | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:19 +08:00
										 |  |  |   EXPECT(!cls.isVirtual); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |   EXPECT(cls.namespaces().empty()); | 
					
						
							| 
									
										
										
										
											2014-11-13 06:22:59 +08:00
										 |  |  |   LONGS_EQUAL(3, cls.nrMethods()); | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:20 +08:00
										 |  |  |   LONGS_EQUAL(1, cls.static_methods.size()); | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:19 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // Method 1
 | 
					
						
							| 
									
										
										
										
											2014-11-13 06:22:59 +08:00
										 |  |  |   Method m1 = cls.method("x"); | 
					
						
							| 
									
										
										
										
											2014-11-14 05:43:29 +08:00
										 |  |  |   EXPECT(assert_equal("x", m1.name())); | 
					
						
							| 
									
										
										
										
											2014-11-14 06:21:05 +08:00
										 |  |  |   EXPECT(m1.isConst()); | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  |   LONGS_EQUAL(1, m1.nrOverloads()); | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:19 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  |   ReturnValue rv1 = m1.returnValue(0); | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:19 +08:00
										 |  |  |   EXPECT(!rv1.isPair); | 
					
						
							| 
									
										
										
										
											2014-11-12 21:37:08 +08:00
										 |  |  |   EXPECT(!rv1.type1.isPtr); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |   EXPECT(assert_equal("double", rv1.type1.name())); | 
					
						
							| 
									
										
										
										
											2014-11-12 21:37:08 +08:00
										 |  |  |   EXPECT_LONGS_EQUAL(ReturnType::BASIS, rv1.type1.category); | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:19 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // Method 2
 | 
					
						
							| 
									
										
										
										
											2014-11-13 06:22:59 +08:00
										 |  |  |   Method m2 = cls.method("returnMatrix"); | 
					
						
							| 
									
										
										
										
											2014-11-14 05:43:29 +08:00
										 |  |  |   EXPECT(assert_equal("returnMatrix", m2.name())); | 
					
						
							| 
									
										
										
										
											2014-11-14 06:21:05 +08:00
										 |  |  |   EXPECT(m2.isConst()); | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  |   LONGS_EQUAL(1, m2.nrOverloads()); | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:19 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  |   ReturnValue rv2 = m2.returnValue(0); | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:19 +08:00
										 |  |  |   EXPECT(!rv2.isPair); | 
					
						
							| 
									
										
										
										
											2014-11-12 21:37:08 +08:00
										 |  |  |   EXPECT(!rv2.type1.isPtr); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |   EXPECT(assert_equal("Matrix", rv2.type1.name())); | 
					
						
							| 
									
										
										
										
											2014-11-12 21:37:08 +08:00
										 |  |  |   EXPECT_LONGS_EQUAL(ReturnType::EIGEN, rv2.type1.category); | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:19 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // Method 3
 | 
					
						
							| 
									
										
										
										
											2014-11-13 06:22:59 +08:00
										 |  |  |   Method m3 = cls.method("returnPoint2"); | 
					
						
							| 
									
										
										
										
											2014-11-14 05:43:29 +08:00
										 |  |  |   EXPECT(assert_equal("returnPoint2", m3.name())); | 
					
						
							| 
									
										
										
										
											2014-11-14 06:21:05 +08:00
										 |  |  |   EXPECT(m3.isConst()); | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  |   LONGS_EQUAL(1, m3.nrOverloads()); | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:19 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  |   ReturnValue rv3 = m3.returnValue(0); | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:19 +08:00
										 |  |  |   EXPECT(!rv3.isPair); | 
					
						
							| 
									
										
										
										
											2014-11-12 21:37:08 +08:00
										 |  |  |   EXPECT(!rv3.type1.isPtr); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |   EXPECT(assert_equal("Point2", rv3.type1.name())); | 
					
						
							| 
									
										
										
										
											2014-11-12 21:37:08 +08:00
										 |  |  |   EXPECT_LONGS_EQUAL(ReturnType::CLASS, rv3.type1.category); | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:19 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:20 +08:00
										 |  |  |   // Static Method 1
 | 
					
						
							|  |  |  |   // static Vector returnVector();
 | 
					
						
							|  |  |  |   StaticMethod sm1 = cls.static_methods.at("returnVector"); | 
					
						
							| 
									
										
										
										
											2014-11-14 05:43:29 +08:00
										 |  |  |   EXPECT(assert_equal("returnVector", sm1.name())); | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  |   LONGS_EQUAL(1, sm1.nrOverloads()); | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  |   ReturnValue rv4 = sm1.returnValue(0); | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:20 +08:00
										 |  |  |   EXPECT(!rv4.isPair); | 
					
						
							| 
									
										
										
										
											2014-11-12 21:37:08 +08:00
										 |  |  |   EXPECT(!rv4.type1.isPtr); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |   EXPECT(assert_equal("Vector", rv4.type1.name())); | 
					
						
							| 
									
										
										
										
											2014-11-12 21:37:08 +08:00
										 |  |  |   EXPECT_LONGS_EQUAL(ReturnType::EIGEN, rv4.type1.category); | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:19 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-14 02:41:56 +08:00
										 |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2014-11-13 06:22:59 +08:00
										 |  |  | TEST( wrap, Geometry ) { | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   string markup_header_path = topdir + "/wrap/tests"; | 
					
						
							|  |  |  |   Module module(markup_header_path.c_str(), "geometry",enable_verbose); | 
					
						
							| 
									
										
										
										
											2016-02-08 12:33:48 +08:00
										 |  |  |   EXPECT_LONGS_EQUAL(9, module.classes.size()); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // forward declarations
 | 
					
						
							|  |  |  |   LONGS_EQUAL(2, module.forward_declarations.size()); | 
					
						
							|  |  |  |   EXPECT(assert_equal("VectorNotEigen", module.forward_declarations[0].name)); | 
					
						
							|  |  |  |   EXPECT(assert_equal("ns::OtherClass", module.forward_declarations[1].name)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // includes
 | 
					
						
							|  |  |  |   strvec exp_includes; exp_includes += "folder/path/to/Test.h"; | 
					
						
							|  |  |  |   EXPECT(assert_equal(exp_includes, module.includes)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-08 12:33:48 +08:00
										 |  |  |   LONGS_EQUAL(9, module.classes.size()); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-12 21:37:08 +08:00
										 |  |  |   // Key for ReturnType::return_category
 | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:18 +08:00
										 |  |  | //  CLASS = 1,
 | 
					
						
							|  |  |  | //  EIGEN = 2,
 | 
					
						
							|  |  |  | //  BASIS = 3,
 | 
					
						
							|  |  |  | //  VOID  = 4,
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   { | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:16 +08:00
										 |  |  |     // check first class
 | 
					
						
							|  |  |  |     //  class Point2 {
 | 
					
						
							|  |  |  |     //   Point2();
 | 
					
						
							|  |  |  |     //   Point2(double x, double y);
 | 
					
						
							|  |  |  |     //   double x() const;
 | 
					
						
							|  |  |  |     //   double y() const;
 | 
					
						
							|  |  |  |     //   int dim() const;
 | 
					
						
							|  |  |  |     //   char returnChar() const;
 | 
					
						
							|  |  |  |     //   void argChar(char a) const;
 | 
					
						
							|  |  |  |     //   void argUChar(unsigned char a) const;
 | 
					
						
							|  |  |  |     //   VectorNotEigen vectorConfusion();
 | 
					
						
							|  |  |  |     //  };
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |     Class cls = module.classes.at(0); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(assert_equal("Point2", cls.name())); | 
					
						
							| 
									
										
										
										
											2014-11-14 04:34:59 +08:00
										 |  |  |     EXPECT_LONGS_EQUAL(2, cls.constructor.nrOverloads()); | 
					
						
							| 
									
										
										
										
											2014-11-30 04:43:48 +08:00
										 |  |  |     EXPECT_LONGS_EQUAL(8, cls.nrMethods()); | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:16 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       //   char returnChar() const;
 | 
					
						
							| 
									
										
										
										
											2014-11-13 06:22:59 +08:00
										 |  |  |       CHECK(cls.exists("returnChar")); | 
					
						
							|  |  |  |       Method m1 = cls.method("returnChar"); | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  |       LONGS_EQUAL(1, m1.nrOverloads()); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |       EXPECT(assert_equal("char", m1.returnValue(0).type1.name())); | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  |       EXPECT_LONGS_EQUAL(ReturnType::BASIS, m1.returnValue(0).type1.category); | 
					
						
							|  |  |  |       EXPECT(!m1.returnValue(0).isPair); | 
					
						
							| 
									
										
										
										
											2014-11-14 05:43:29 +08:00
										 |  |  |       EXPECT(assert_equal("returnChar", m1.name())); | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  |       LONGS_EQUAL(1, m1.nrOverloads()); | 
					
						
							|  |  |  |       EXPECT_LONGS_EQUAL(0, m1.argumentList(0).size()); | 
					
						
							| 
									
										
										
										
											2014-11-14 06:21:05 +08:00
										 |  |  |       EXPECT(m1.isConst()); | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:16 +08:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       //   VectorNotEigen vectorConfusion();
 | 
					
						
							| 
									
										
										
										
											2014-11-13 06:22:59 +08:00
										 |  |  |       CHECK(cls.exists("vectorConfusion")); | 
					
						
							|  |  |  |       Method m1 = cls.method("vectorConfusion"); | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  |       LONGS_EQUAL(1, m1.nrOverloads()); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |       EXPECT(assert_equal("VectorNotEigen", m1.returnValue(0).type1.name())); | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  |       EXPECT_LONGS_EQUAL(ReturnType::CLASS, m1.returnValue(0).type1.category); | 
					
						
							|  |  |  |       EXPECT(!m1.returnValue(0).isPair); | 
					
						
							| 
									
										
										
										
											2014-11-14 05:43:29 +08:00
										 |  |  |       EXPECT(assert_equal("vectorConfusion", m1.name())); | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  |       LONGS_EQUAL(1, m1.nrOverloads()); | 
					
						
							|  |  |  |       EXPECT_LONGS_EQUAL(0, m1.argumentList(0).size()); | 
					
						
							| 
									
										
										
										
											2014-11-14 06:21:05 +08:00
										 |  |  |       EXPECT(!m1.isConst()); | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:16 +08:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |     EXPECT_LONGS_EQUAL(0, cls.static_methods.size()); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT_LONGS_EQUAL(1, cls.namespaces().size()); | 
					
						
							| 
									
										
										
										
											2013-06-20 01:50:05 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-11 20:43:25 +08:00
										 |  |  | #ifndef WRAP_DISABLE_SERIALIZE
 | 
					
						
							| 
									
										
										
										
											2013-06-20 01:50:05 +08:00
										 |  |  |     // check serialization flag
 | 
					
						
							|  |  |  |     EXPECT(cls.isSerializable); | 
					
						
							|  |  |  |     EXPECT(!cls.hasSerialization); | 
					
						
							| 
									
										
										
										
											2014-11-11 20:43:25 +08:00
										 |  |  | #endif
 | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // check second class, Point3
 | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     Class cls = module.classes.at(1); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(assert_equal("Point3", cls.name())); | 
					
						
							| 
									
										
										
										
											2014-11-14 04:34:59 +08:00
										 |  |  |     EXPECT_LONGS_EQUAL(1, cls.constructor.nrOverloads()); | 
					
						
							| 
									
										
										
										
											2014-11-13 06:22:59 +08:00
										 |  |  |     EXPECT_LONGS_EQUAL(1, cls.nrMethods()); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |     EXPECT_LONGS_EQUAL(2, cls.static_methods.size()); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT_LONGS_EQUAL(1, cls.namespaces().size()); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // first constructor takes 3 doubles
 | 
					
						
							| 
									
										
										
										
											2014-11-14 04:34:59 +08:00
										 |  |  |     ArgumentList c1 = cls.constructor.argumentList(0); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |     EXPECT_LONGS_EQUAL(3, c1.size()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // check first double argument
 | 
					
						
							|  |  |  |     Argument a1 = c1.front(); | 
					
						
							|  |  |  |     EXPECT(!a1.is_const); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(assert_equal("double", a1.type.name_)); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |     EXPECT(!a1.is_ref); | 
					
						
							|  |  |  |     EXPECT(assert_equal("x", a1.name)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // check method
 | 
					
						
							| 
									
										
										
										
											2014-11-13 06:22:59 +08:00
										 |  |  |     CHECK(cls.exists("norm")); | 
					
						
							|  |  |  |     Method m1 = cls.method("norm"); | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  |     LONGS_EQUAL(1, m1.nrOverloads()); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(assert_equal("double", m1.returnValue(0).type1.name())); | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  |     EXPECT_LONGS_EQUAL(ReturnType::BASIS, m1.returnValue(0).type1.category); | 
					
						
							| 
									
										
										
										
											2014-11-14 05:43:29 +08:00
										 |  |  |     EXPECT(assert_equal("norm", m1.name())); | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  |     LONGS_EQUAL(1, m1.nrOverloads()); | 
					
						
							|  |  |  |     EXPECT_LONGS_EQUAL(0, m1.argumentList(0).size()); | 
					
						
							| 
									
										
										
										
											2014-11-14 06:21:05 +08:00
										 |  |  |     EXPECT(m1.isConst()); | 
					
						
							| 
									
										
										
										
											2013-06-20 01:49:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-11 20:43:25 +08:00
										 |  |  | #ifndef WRAP_DISABLE_SERIALIZE
 | 
					
						
							| 
									
										
										
										
											2013-06-20 01:49:55 +08:00
										 |  |  |     // check serialization flag
 | 
					
						
							|  |  |  |     EXPECT(cls.isSerializable); | 
					
						
							| 
									
										
										
										
											2013-06-20 01:50:05 +08:00
										 |  |  |     EXPECT(cls.hasSerialization); | 
					
						
							| 
									
										
										
										
											2014-11-11 20:43:25 +08:00
										 |  |  | #endif
 | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // Test class is the third one
 | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     Class testCls = module.classes.at(2); | 
					
						
							| 
									
										
										
										
											2014-11-14 04:34:59 +08:00
										 |  |  |     EXPECT_LONGS_EQUAL( 2, testCls.constructor.nrOverloads()); | 
					
						
							| 
									
										
										
										
											2014-11-13 06:22:59 +08:00
										 |  |  |     EXPECT_LONGS_EQUAL(19, testCls.nrMethods()); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |     EXPECT_LONGS_EQUAL( 0, testCls.static_methods.size()); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT_LONGS_EQUAL( 0, testCls.namespaces().size()); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // function to parse: pair<Vector,Matrix> return_pair (Vector v, Matrix A) const;
 | 
					
						
							| 
									
										
										
										
											2014-11-13 06:22:59 +08:00
										 |  |  |     CHECK(testCls.exists("return_pair")); | 
					
						
							|  |  |  |     Method m2 = testCls.method("return_pair"); | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  |     LONGS_EQUAL(1, m2.nrOverloads()); | 
					
						
							|  |  |  |     EXPECT(m2.returnValue(0).isPair); | 
					
						
							|  |  |  |     EXPECT_LONGS_EQUAL(ReturnType::EIGEN, m2.returnValue(0).type1.category); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(assert_equal("Vector", m2.returnValue(0).type1.name())); | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  |     EXPECT_LONGS_EQUAL(ReturnType::EIGEN, m2.returnValue(0).type2.category); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(assert_equal("Matrix", m2.returnValue(0).type2.name())); | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:22 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // checking pointer args and return values
 | 
					
						
							|  |  |  | //    pair<Test*,Test*> return_ptrs (Test* p1, Test* p2) const;
 | 
					
						
							| 
									
										
										
										
											2014-11-13 06:22:59 +08:00
										 |  |  |     CHECK(testCls.exists("return_ptrs")); | 
					
						
							|  |  |  |     Method m3 = testCls.method("return_ptrs"); | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  |     LONGS_EQUAL(1, m3.nrOverloads()); | 
					
						
							|  |  |  |     ArgumentList args = m3.argumentList(0); | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:22 +08:00
										 |  |  |     LONGS_EQUAL(2, args.size()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Argument arg1 = args.at(0); | 
					
						
							|  |  |  |     EXPECT(arg1.is_ptr); | 
					
						
							|  |  |  |     EXPECT(!arg1.is_const); | 
					
						
							|  |  |  |     EXPECT(!arg1.is_ref); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(assert_equal("Test", arg1.type.name_)); | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:22 +08:00
										 |  |  |     EXPECT(assert_equal("p1", arg1.name)); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(arg1.type.namespaces_.empty()); | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:22 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     Argument arg2 = args.at(1); | 
					
						
							|  |  |  |     EXPECT(arg2.is_ptr); | 
					
						
							|  |  |  |     EXPECT(!arg2.is_const); | 
					
						
							|  |  |  |     EXPECT(!arg2.is_ref); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(assert_equal("Test", arg2.type.name_)); | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:22 +08:00
										 |  |  |     EXPECT(assert_equal("p2", arg2.name)); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(arg2.type.namespaces_.empty()); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // evaluate global functions
 | 
					
						
							| 
									
										
										
										
											2014-05-26 04:28:59 +08:00
										 |  |  |   //  Vector aGlobalFunction();
 | 
					
						
							|  |  |  |   LONGS_EQUAL(2, module.global_functions.size()); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   CHECK(module.global_functions.find("aGlobalFunction") != module.global_functions.end()); | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     GlobalFunction gfunc = module.global_functions.at("aGlobalFunction"); | 
					
						
							| 
									
										
										
										
											2014-11-14 05:43:29 +08:00
										 |  |  |     EXPECT(assert_equal("aGlobalFunction", gfunc.name())); | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  |     LONGS_EQUAL(1, gfunc.nrOverloads()); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(assert_equal("Vector", gfunc.returnValue(0).type1.name())); | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  |     EXPECT_LONGS_EQUAL(1, gfunc.nrOverloads()); | 
					
						
							| 
									
										
										
										
											2014-11-12 09:49:23 +08:00
										 |  |  |     LONGS_EQUAL(1, gfunc.overloads.size()); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(gfunc.overloads.front().namespaces().empty()); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2011-10-14 02:41:56 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2011-12-09 04:51:07 +08:00
										 |  |  | TEST( wrap, parse_namespaces ) { | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   string header_path = topdir + "/wrap/tests"; | 
					
						
							|  |  |  |   Module module(header_path.c_str(), "testNamespaces",enable_verbose); | 
					
						
							|  |  |  |   EXPECT_LONGS_EQUAL(6, module.classes.size()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     strvec module_exp_includes; | 
					
						
							|  |  |  |     module_exp_includes += "path/to/ns1.h"; | 
					
						
							|  |  |  |     module_exp_includes += "path/to/ns1/ClassB.h"; | 
					
						
							|  |  |  |     module_exp_includes += "path/to/ns2.h"; | 
					
						
							|  |  |  |     module_exp_includes += "path/to/ns2/ClassA.h"; | 
					
						
							|  |  |  |     module_exp_includes += "path/to/ns3.h"; | 
					
						
							|  |  |  |     EXPECT(assert_equal(module_exp_includes, module.includes)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     Class cls = module.classes.at(0); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(assert_equal("ClassA", cls.name())); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |     strvec exp_namespaces; exp_namespaces += "ns1"; | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(assert_equal(exp_namespaces, cls.namespaces())); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     Class cls = module.classes.at(1); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(assert_equal("ClassB", cls.name())); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |     strvec exp_namespaces; exp_namespaces += "ns1"; | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(assert_equal(exp_namespaces, cls.namespaces())); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     Class cls = module.classes.at(2); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(assert_equal("ClassA", cls.name())); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |     strvec exp_namespaces; exp_namespaces += "ns2"; | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(assert_equal(exp_namespaces, cls.namespaces())); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     Class cls = module.classes.at(3); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(assert_equal("ClassB", cls.name())); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |     strvec exp_namespaces; exp_namespaces += "ns2", "ns3"; | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(assert_equal(exp_namespaces, cls.namespaces())); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     Class cls = module.classes.at(4); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(assert_equal("ClassC", cls.name())); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |     strvec exp_namespaces; exp_namespaces += "ns2"; | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(assert_equal(exp_namespaces, cls.namespaces())); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     Class cls = module.classes.at(5); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(assert_equal("ClassD", cls.name())); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |     strvec exp_namespaces; | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(assert_equal(exp_namespaces, cls.namespaces())); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // evaluate global functions
 | 
					
						
							|  |  |  | //  Vector ns1::aGlobalFunction();
 | 
					
						
							|  |  |  | //  Vector ns2::aGlobalFunction();
 | 
					
						
							| 
									
										
										
										
											2014-05-26 04:37:43 +08:00
										 |  |  |   LONGS_EQUAL(2, module.global_functions.size()); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   CHECK(module.global_functions.find("aGlobalFunction") != module.global_functions.end()); | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     GlobalFunction gfunc = module.global_functions.at("aGlobalFunction"); | 
					
						
							| 
									
										
										
										
											2014-11-14 05:43:29 +08:00
										 |  |  |     EXPECT(assert_equal("aGlobalFunction", gfunc.name())); | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  |     LONGS_EQUAL(2, gfunc.nrOverloads()); | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(assert_equal("Vector", gfunc.returnValue(0).type1.name())); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // check namespaces
 | 
					
						
							| 
									
										
										
										
											2014-11-12 09:49:23 +08:00
										 |  |  |     LONGS_EQUAL(2, gfunc.overloads.size()); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |     strvec exp_namespaces1; exp_namespaces1 += "ns1"; | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(assert_equal(exp_namespaces1, gfunc.overloads.at(0).namespaces())); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     strvec exp_namespaces2; exp_namespaces2 += "ns2"; | 
					
						
							| 
									
										
										
										
											2014-12-01 03:12:03 +08:00
										 |  |  |     EXPECT(assert_equal(exp_namespaces2, gfunc.overloads.at(1).namespaces())); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2011-12-09 04:51:13 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | TEST( wrap, matlab_code_namespaces ) { | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   string header_path = topdir + "/wrap/tests"; | 
					
						
							|  |  |  |   Module module(header_path.c_str(), "testNamespaces",enable_verbose); | 
					
						
							|  |  |  |   EXPECT_LONGS_EQUAL(6, module.classes.size()); | 
					
						
							|  |  |  |   string path = topdir + "/wrap"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // clean out previous generated code
 | 
					
						
							|  |  |  |   fs::remove_all("actual_namespaces"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // emit MATLAB code
 | 
					
						
							|  |  |  |   string exp_path = path + "/tests/expected_namespaces/"; | 
					
						
							|  |  |  |   string act_path = "actual_namespaces/"; | 
					
						
							| 
									
										
										
										
											2014-11-15 00:04:45 +08:00
										 |  |  |   module.matlab_code("actual_namespaces"); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-26 04:37:43 +08:00
										 |  |  |   EXPECT(files_equal(exp_path + "ClassD.m", act_path + "ClassD.m" )); | 
					
						
							|  |  |  |   EXPECT(files_equal(exp_path + "+ns1/ClassA.m", act_path + "+ns1/ClassA.m" )); | 
					
						
							|  |  |  |   EXPECT(files_equal(exp_path + "+ns1/ClassB.m", act_path + "+ns1/ClassB.m" )); | 
					
						
							|  |  |  |   EXPECT(files_equal(exp_path + "+ns2/ClassA.m", act_path + "+ns2/ClassA.m" )); | 
					
						
							|  |  |  |   EXPECT(files_equal(exp_path + "+ns2/ClassC.m", act_path + "+ns2/ClassC.m" )); | 
					
						
							|  |  |  |   EXPECT( | 
					
						
							|  |  |  |       files_equal(exp_path + "+ns2/overloadedGlobalFunction.m", exp_path + "+ns2/overloadedGlobalFunction.m" )); | 
					
						
							|  |  |  |   EXPECT( | 
					
						
							|  |  |  |       files_equal(exp_path + "+ns2/+ns3/ClassB.m", act_path + "+ns2/+ns3/ClassB.m" )); | 
					
						
							|  |  |  |   EXPECT( | 
					
						
							|  |  |  |       files_equal(exp_path + "testNamespaces_wrapper.cpp", act_path + "testNamespaces_wrapper.cpp" )); | 
					
						
							| 
									
										
										
										
											2011-12-09 04:51:07 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2012-07-18 02:30:02 +08:00
										 |  |  | TEST( wrap, matlab_code_geometry ) { | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   // Parse into class object
 | 
					
						
							|  |  |  |   string header_path = topdir + "/wrap/tests"; | 
					
						
							|  |  |  |   Module module(header_path,"geometry",enable_verbose); | 
					
						
							|  |  |  |   string path = topdir + "/wrap"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // clean out previous generated code
 | 
					
						
							|  |  |  |   fs::remove_all("actual"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // emit MATLAB code
 | 
					
						
							|  |  |  |   // make_geometry will not compile, use make testwrap to generate real make
 | 
					
						
							| 
									
										
										
										
											2014-11-15 00:04:45 +08:00
										 |  |  |   module.matlab_code("actual"); | 
					
						
							| 
									
										
										
										
											2014-11-11 20:43:25 +08:00
										 |  |  | #ifndef WRAP_DISABLE_SERIALIZE
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   string epath = path + "/tests/expected/"; | 
					
						
							| 
									
										
										
										
											2014-11-11 20:43:25 +08:00
										 |  |  | #else
 | 
					
						
							|  |  |  |   string epath = path + "/tests/expected2/"; | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   string apath = "actual/"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   EXPECT(files_equal(epath + "geometry_wrapper.cpp" , apath + "geometry_wrapper.cpp" )); | 
					
						
							| 
									
										
										
										
											2016-02-08 12:34:16 +08:00
										 |  |  |   EXPECT(files_equal(epath + "+gtsam/Point2.m"      , apath + "+gtsam/Point2.m"      )); | 
					
						
							|  |  |  |   EXPECT(files_equal(epath + "+gtsam/Point3.m"      , apath + "+gtsam/Point3.m"      )); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   EXPECT(files_equal(epath + "Test.m"               , apath + "Test.m"               )); | 
					
						
							| 
									
										
										
										
											2014-11-12 05:38:50 +08:00
										 |  |  |   EXPECT(files_equal(epath + "MyBase.m"             , apath + "MyBase.m"             )); | 
					
						
							| 
									
										
										
										
											2016-02-08 12:34:16 +08:00
										 |  |  |   EXPECT(files_equal(epath + "MyVector3.m"          , apath + "MyVector3.m"          )); | 
					
						
							|  |  |  |   EXPECT(files_equal(epath + "MyVector12.m"         , apath + "MyVector12.m"         )); | 
					
						
							| 
									
										
										
										
											2014-11-12 05:38:50 +08:00
										 |  |  |   EXPECT(files_equal(epath + "MyTemplatePoint2.m"   , apath + "MyTemplatePoint2.m"   )); | 
					
						
							| 
									
										
										
										
											2014-12-01 21:47:09 +08:00
										 |  |  |   EXPECT(files_equal(epath + "MyTemplateMatrix.m"   , apath + "MyTemplateMatrix.m"   )); | 
					
						
							| 
									
										
										
										
											2016-02-08 12:34:16 +08:00
										 |  |  |   EXPECT(files_equal(epath + "MyFactorPosePoint2.m" , apath + "MyFactorPosePoint2.m" )); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   EXPECT(files_equal(epath + "aGlobalFunction.m"    , apath + "aGlobalFunction.m"    )); | 
					
						
							| 
									
										
										
										
											2016-02-08 12:34:16 +08:00
										 |  |  |   EXPECT(files_equal(epath + "overloadedGlobalFunction.m", apath + "overloadedGlobalFunction.m")); | 
					
						
							| 
									
										
										
										
											2011-10-14 02:41:56 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-15 00:47:25 +08:00
										 |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | TEST( wrap, python_code_geometry ) { | 
					
						
							|  |  |  |   // Parse into class object
 | 
					
						
							|  |  |  |   string header_path = topdir + "/wrap/tests"; | 
					
						
							|  |  |  |   Module module(header_path,"geometry",enable_verbose); | 
					
						
							|  |  |  |   string path = topdir + "/wrap"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // clean out previous generated code
 | 
					
						
							|  |  |  |   fs::remove_all("actual-python"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // emit MATLAB code
 | 
					
						
							|  |  |  |   // make_geometry will not compile, use make testwrap to generate real make
 | 
					
						
							|  |  |  |   module.python_wrapper("actual-python"); | 
					
						
							|  |  |  |   string epath = path + "/tests/expected-python/"; | 
					
						
							|  |  |  |   string apath = "actual-python/"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   EXPECT(files_equal(epath + "geometry_python.cpp", apath + "geometry_python.cpp" )); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-14 02:41:56 +08:00
										 |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | int main() { TestResult tr; return TestRegistry::runAllTests(tr); } | 
					
						
							|  |  |  | /* ************************************************************************* */ |