Added unit test for Fast* containers, added generic interface to convert from containers to KeySet

release/4.3a0
Alex Cunningham 2012-09-24 19:42:41 +00:00
parent df2a6bfdee
commit 6284312a5c
3 changed files with 42 additions and 0 deletions

View File

@ -1517,6 +1517,8 @@ class KeyList {
class KeySet {
KeySet();
KeySet(const gtsam::KeySet& other);
KeySet(const gtsam::KeyVector& other);
KeySet(const gtsam::KeyList& other);
// Testable
void print(string s) const;

View File

@ -61,6 +61,12 @@ public:
Base(first, last) {
}
/** Constructor from a iterable container, passes through to base class */
template<typename INPUTCONTAINER>
explicit FastSet(const INPUTCONTAINER& container) :
Base(container.begin(), container.end()) {
}
/** Copy constructor from another FastSet */
FastSet(const FastSet<VALUE>& x) :
Base(x) {

View File

@ -0,0 +1,34 @@
/**
* @file testFastContainers.cpp
*
* @brief Test for the Fast* containers that use boost pool allocators and interfaces
*
* @date Sep 24, 2012
* @author Alex Cunningham
*/
#include <CppUnitLite/TestHarness.h>
#include <boost/assign/std/vector.hpp>
#include <boost/assign/std/set.hpp>
#include <gtsam/base/FastSet.h>
#include <gtsam/base/FastVector.h>
using namespace boost::assign;
using namespace gtsam;
/* ************************************************************************* */
TEST( testFastContainers, KeySet ) {
FastVector<size_t> init_vector;
init_vector += 2, 3, 4, 5;
FastSet<size_t> actSet(init_vector);
FastSet<size_t> expSet; expSet += 2, 3, 4, 5;
EXPECT(actSet == expSet);
}
/* ************************************************************************* */
int main() { TestResult tr; return TestRegistry::runAllTests(tr); }
/* ************************************************************************* */