68 lines
1.4 KiB
C++
68 lines
1.4 KiB
C++
#include "item.hh"
|
|
#include "item_impl.hh"
|
|
#include "dbsession.hh"
|
|
#include "dbobjectvec.hh"
|
|
#include "dbobjecttree.hh"
|
|
#include "dbobjecttree_impl.hh"
|
|
#include "dbobjecttreeptr.hh"
|
|
#include "category.hh"
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <iostream>
|
|
|
|
using namespace inventory;
|
|
using namespace datamodel;
|
|
using namespace inventory::db;
|
|
|
|
std::string g_test_db_url;
|
|
|
|
template<class Object>
|
|
class TreeTest : public ::testing::Test {
|
|
protected:
|
|
class Visitor : public DBObjectTree<Object>::SubtreeVisitor {
|
|
public:
|
|
virtual void apply(DBObjectPtr<Object> item, int max_lvl, int lvl) {
|
|
indent(lvl);
|
|
if (!item->is_root())
|
|
std::cout << (std::string)(item->name) << std::endl;
|
|
}
|
|
|
|
protected:
|
|
void indent(int level) {
|
|
for (int i = 0; i < level; i++)
|
|
std::cout << "\t";
|
|
}
|
|
};
|
|
|
|
public:
|
|
typedef Object TestedDBObject;
|
|
|
|
TreeTest()
|
|
: m_session(g_test_db_url.c_str()) {}
|
|
|
|
virtual void setUp() {}
|
|
virtual void tearDown() {}
|
|
|
|
protected:
|
|
DBSession m_session;
|
|
};
|
|
|
|
typedef TreeTest<Item> ItemTest;
|
|
|
|
TEST_F(ItemTest, ItemTreeTest) {
|
|
Visitor visitor;
|
|
DBObjectTreePtr<TestedDBObject> tree(new DBObjectTree<TestedDBObject>);
|
|
tree->recurse_subtrees(m_session, visitor);
|
|
EXPECT_EQ(0, 0);
|
|
}
|
|
|
|
int main(int argc, char *argv[]) {
|
|
return 0;
|
|
|
|
::testing::InitGoogleTest(&argc, argv);
|
|
|
|
g_test_db_url = argv[1];
|
|
|
|
return RUN_ALL_TESTS();
|
|
}
|