1
0
mirror of https://github.com/fwbuilder/fwbuilder synced 2026-03-24 20:27:22 +01:00
This commit is contained in:
Roman Bovsunivskiy 2009-12-16 11:41:47 +00:00
parent 287c34dc19
commit 4f0af1de84
5 changed files with 108 additions and 1 deletions

View File

@ -0,0 +1,35 @@
# -------------------------------------------------
# Project created by QtCreator 2009-12-16T13:20:15
# -------------------------------------------------
include(../../../../qmake.inc)
QMAKE_CXX = g++
QT += gui network
INCLUDEPATH += ../../.ui ../../../compiler_lib/
TARGET = FWBTreeTest
#CONFIG += console
#CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp \
FWBTreeTest.cpp \
../../FWBTree.cpp
HEADERS += FWBTreeTest.h ../../FWBTree.h
CONFIG -= release
CONFIG += debug
OBJECTS_DIR = .
QMAKE_CXXFLAGS += -g -fprofile-arcs -ftest-coverage -O0 $$CPPUNIT_CFLAGS
QMAKE_CLEAN = *.gc??
LIBS += $$LIBS_FWCOMPILER $$LIBS_FWBUILDER $$CPPUNIT_LIBS
LIBS += -lgcov # -lcppunit
run.commands = ./${TARGET} && gcov -o . ../../FWBTree.cpp >/dev/null 2>/dev/null
run.depends = all
QMAKE_EXTRA_TARGETS += run

View File

@ -0,0 +1,31 @@
#include <QDebug>
#include "FWBTreeTest.h"
#include "fwbuilder/FWObjectDatabase.h"
#include "fwbuilder/Library.h"
#include "fwbuilder/Firewall.h"
using namespace libfwbuilder;
using namespace std;
void FWBTreeTest::isSystem()
{
FWBTree fwbtree;
FWObjectDatabase db;
CPPUNIT_ASSERT(fwbtree.isSystem(&db) == true);
Library *lib = db.createLibrary(4);
CPPUNIT_ASSERT(fwbtree.isSystem(lib) == true);
lib = db.createLibrary(7);
CPPUNIT_ASSERT(fwbtree.isSystem(lib) == true);
lib = db.createLibrary(1);
CPPUNIT_ASSERT(fwbtree.isSystem(lib) == false);
lib = Library::cast(fwbtree.createNewLibrary(&db));
FWObject *slot = fwbtree.getStandardSlotForObject(lib, Firewall::TYPENAME);
CPPUNIT_ASSERT(fwbtree.isSystem(slot) == true);
Firewall fw;
CPPUNIT_ASSERT(fwbtree.isSystem(&fw) == false);
}

View File

@ -0,0 +1,25 @@
#ifndef FWBTREETEST_H
#define FWBTREETEST_H
#include "FWBTree.h"
#include <cppunit/TestCase.h>
#include <cppunit/TestSuite.h>
#include <cppunit/TestCaller.h>
class FWBTreeTest : public CppUnit::TestCase
{
public:
void isSystem();
static CppUnit::Test *suite()
{
CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite( "FWBTree" );
suiteOfTests->addTest( new CppUnit::TestCaller<FWBTreeTest>( "isSystem",
&FWBTreeTest::isSystem ) );
return suiteOfTests;
}
};
#endif // FWBTREETEST_H

View File

@ -0,0 +1,16 @@
#include <cppunit/ui/text/TestRunner.h>
#include <cppunit/CompilerOutputter.h>
#include "FWBTreeTest.h"
int fwbdebug;
int main(int argc, char *argv[])
{
CppUnit::TextUi::TestRunner runner;
runner.addTest( FWBTreeTest::suite() );
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
std::cerr ) );
runner.run();
return 0;
}

View File

@ -57,7 +57,7 @@ public:
static CppUnit::Test *suite()
{
CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite( "FWObjectDatabase" );
CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite( "UsageResolver" );
suiteOfTests->addTest( new CppUnit::TestCaller<UsageResolverTest>(
"findWhereObjectIsUsed",
&UsageResolverTest::findWhereObjectIsUsed ) );