[Uml-devel] branches/work/soc-umbrello/unittests
Andi Fischer
andi.fischer at hispeed.ch
Sun Feb 6 18:09:11 UTC 2011
SVN commit 1219166 by fischer:
More unit tests added. Not all unit tests are implemented.
M +45 -6 CMakeLists.txt
M +116 -0 TEST_basictypes.cpp
A TEST_classifier.cpp [License: GPL (v2/3)]
A TEST_cppwriter.cpp [License: GPL (v2/3)]
A TEST_pythonwriter.cpp [License: GPL (v2/3)]
--- branches/work/soc-umbrello/unittests/CMakeLists.txt #1219165:1219166
@@ -1,23 +1,59 @@
IF( KDE4_BUILD_TESTS )
set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
+ set( SRC_PATH ../umbrello )
include_directories(
+ ${LIBXML2_INCLUDE_DIR}
+ ${LIBXSLT_INCLUDE_DIR}
${CMAKE_SOURCE_DIR}
- ../umbrello
+ ${SRC_PATH}
+ ${SRC_PATH}/debug/
+ ${SRC_PATH}/dialogs/
+ ${SRC_PATH}/clipboard
+ ${SRC_PATH}/cmds
+ ${SRC_PATH}/codegenerators
+ ${SRC_PATH}/codegenerators/ada/
+ ${SRC_PATH}/codegenerators/as/
+ ${SRC_PATH}/codegenerators/cpp/
+ ${SRC_PATH}/codegenerators/csharp/
+ ${SRC_PATH}/codegenerators/d/
+ ${SRC_PATH}/codegenerators/idl/
+ ${SRC_PATH}/codegenerators/java/
+ ${SRC_PATH}/codegenerators/js/
+ ${SRC_PATH}/codegenerators/pascal/
+ ${SRC_PATH}/codegenerators/perl/
+ ${SRC_PATH}/codegenerators/php/
+ ${SRC_PATH}/codegenerators/python/
+ ${SRC_PATH}/codegenerators/ruby/
+ ${SRC_PATH}/codegenerators/sql/
+ ${SRC_PATH}/codegenerators/tcl/
+ ${SRC_PATH}/codegenerators/vala/
+ ${SRC_PATH}/codegenerators/xml/
+ ${SRC_PATH}/codegenwizard
+ ${SRC_PATH}/codeimport
+ ${SRC_PATH}/debug
+ ${SRC_PATH}/dialogs
+ ${SRC_PATH}/docgenerators
+ ${SRC_PATH}/refactoring
+ ${SRC_PATH}/widgets
${CMAKE_CURRENT_BINARY_DIR}
${KDE4_INCLUDES}
)
- set( umbrello_SRCS
- ../umbrello/basictypes.cpp
+ link_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}/../umbrello/umbrello
+ ${CMAKE_CURRENT_BINARY_DIR}/../umbrello/umbrello/CMakeFiles/umbrello-soc.dir
+ ${CMAKE_CURRENT_BINARY_DIR}/../umbrello/umbrello/CMakeFiles/umbrello-soc.dir/dialogs
+
)
MACRO(UNIT_TESTS)
FOREACH(_className ${ARGN})
- MESSAGE( STATUS "unit test = ${_className}" )
+ MESSAGE(STATUS "Unit test: ${_className}")
set(_testName TEST_${_className})
- kde4_add_unit_test(${_testName} TESTNAME umbrello-${_testName} NOGUI ${_testName}.cpp ${umbrello_SRCS})
+ kde4_add_unit_test(${_testName} TESTNAME umbrello-${_testName} NOGUI ${_testName}.cpp
+ ${SRC_PATH}/${_className}.cpp)
target_link_libraries(${_testName} ${QT_QTTEST_LIBRARY}
${KDE4_KFILE_LIBS} ${KDE4_KDE3SUPPORT_LIBS} ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${LIBUUID} )
ENDFOREACH(_className)
@@ -25,6 +61,9 @@
unit_tests(
basictypes
+# classifier
+# cppwriter
+# pythonwriter
)
-ENDIF( KDE4_BUILD_TESTS )
\ No newline at end of file
+ENDIF( KDE4_BUILD_TESTS )
--- branches/work/soc-umbrello/unittests/TEST_basictypes.cpp #1219165:1219166
@@ -1,3 +1,23 @@
+/*
+ Copyright 2011 Andi Fischer <andi.fischer at hispeed.ch>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of
+ the License or (at your option) version 3 or any later version
+ accepted by the membership of KDE e.V. (or its successor approved
+ by the membership of KDE e.V.), which shall act as a proxy
+ defined in Section 14 of version 3 of the license.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#include <QtTest>
#include <QtCore>
@@ -12,8 +32,14 @@
void test_ModelType_forLoop();
void test_Visibility_toString();
void test_Visibility_fromString();
+ void test_DiagramType_toString();
+ void test_DiagramType_fromString();
+ void test_DiagramType_forLoop();
+ void test_SignatureType_toString_fromString();
};
+//-----------------------------------------------------------------------------
+
void TEST_basictypes::test_ModelType_toString()
{
Uml::ModelType modelDefault;
@@ -68,6 +94,8 @@
QVERIFY(list[4] == Uml::ModelType::EntityRelationship);
}
+//-----------------------------------------------------------------------------
+
void TEST_basictypes::test_Visibility_toString()
{
Uml::Visibility visibilityDefault;
@@ -110,5 +138,93 @@
QVERIFY(visibility == Uml::Visibility::Public);
}
+//-----------------------------------------------------------------------------
+
+void TEST_basictypes::test_DiagramType_toString()
+{
+ Uml::DiagramType diagramDefault;
+ QCOMPARE(diagramDefault.toString(), QString("Undefined"));
+ Uml::DiagramType diagram0(Uml::DiagramType::Undefined);
+ QCOMPARE(diagram0.toString(), QString("Undefined"));
+ Uml::DiagramType diagram1(Uml::DiagramType::Class);
+ QCOMPARE(diagram1.toString(), QString("Class"));
+ Uml::DiagramType diagram2(Uml::DiagramType::UseCase);
+ QCOMPARE(diagram2.toString(), QString("UseCase"));
+ Uml::DiagramType diagram3(Uml::DiagramType::Sequence);
+ QCOMPARE(diagram3.toString(), QString("Sequence"));
+ Uml::DiagramType diagram4(Uml::DiagramType::Collaboration);
+ QCOMPARE(diagram4.toString(), QString("Collaboration"));
+ Uml::DiagramType diagram5(Uml::DiagramType::State);
+ QCOMPARE(diagram5.toString(), QString("State"));
+ Uml::DiagramType diagram6(Uml::DiagramType::Activity);
+ QCOMPARE(diagram6.toString(), QString("Activity"));
+ Uml::DiagramType diagram7(Uml::DiagramType::Component);
+ QCOMPARE(diagram7.toString(), QString("Component"));
+ Uml::DiagramType diagram8(Uml::DiagramType::Deployment);
+ QCOMPARE(diagram8.toString(), QString("Deployment"));
+ Uml::DiagramType diagram9(Uml::DiagramType::EntityRelationship);
+ QCOMPARE(diagram9.toString(), QString("EntityRelationship"));
+}
+
+void TEST_basictypes::test_DiagramType_fromString()
+{
+ Uml::DiagramType diagram;
+ diagram = Uml::DiagramType::fromString("Undefined");
+ QVERIFY(diagram == Uml::DiagramType::Undefined);
+ diagram = Uml::DiagramType::fromString("Class");
+ QVERIFY(diagram == Uml::DiagramType::Class);
+ diagram = Uml::DiagramType::fromString("UseCase");
+ QVERIFY(diagram == Uml::DiagramType::UseCase);
+ diagram = Uml::DiagramType::fromString("Sequence");
+ QVERIFY(diagram == Uml::DiagramType::Sequence);
+ diagram = Uml::DiagramType::fromString("Collaboration");
+ QVERIFY(diagram == Uml::DiagramType::Collaboration);
+ diagram = Uml::DiagramType::fromString("State");
+ QVERIFY(diagram == Uml::DiagramType::State);
+ diagram = Uml::DiagramType::fromString("Activity");
+ QVERIFY(diagram == Uml::DiagramType::Activity);
+ diagram = Uml::DiagramType::fromString("Component");
+ QVERIFY(diagram == Uml::DiagramType::Component);
+ diagram = Uml::DiagramType::fromString("Deployment");
+ QVERIFY(diagram == Uml::DiagramType::Deployment);
+ diagram = Uml::DiagramType::fromString("EntityRelationship");
+ QVERIFY(diagram == Uml::DiagramType::EntityRelationship);
+}
+
+void TEST_basictypes::test_DiagramType_forLoop()
+{
+ Uml::DiagramType list[Uml::DiagramType::N_DIAGRAMTYPES];
+ for (int i = 0; i < Uml::DiagramType::N_DIAGRAMTYPES; ++i) {
+ list[i] = Uml::DiagramType(Uml::DiagramType::Value(i));
+ }
+ for (int i = 0; i < Uml::DiagramType::N_DIAGRAMTYPES; ++i) {
+ QVERIFY(list[i] == Uml::DiagramType::Value(i));
+ }
+ QVERIFY(list[0] == Uml::DiagramType::Undefined);
+ QVERIFY(list[1] == Uml::DiagramType::Class);
+ QVERIFY(list[2] == Uml::DiagramType::UseCase);
+ QVERIFY(list[3] == Uml::DiagramType::Sequence);
+ QVERIFY(list[4] == Uml::DiagramType::Collaboration);
+ QVERIFY(list[5] == Uml::DiagramType::State);
+ QVERIFY(list[6] == Uml::DiagramType::Activity);
+ QVERIFY(list[7] == Uml::DiagramType::Component);
+ QVERIFY(list[8] == Uml::DiagramType::Deployment);
+ QVERIFY(list[9] == Uml::DiagramType::EntityRelationship);
+}
+
+//-----------------------------------------------------------------------------
+
+void TEST_basictypes::test_SignatureType_toString_fromString()
+{
+ QVERIFY(Uml::SignatureType::NoSig ==
+ Uml::SignatureType::fromString(Uml::SignatureType::toString(Uml::SignatureType::NoSig)));
+/*
+ Uml::SignatureType signatDefault;
+ QCOMPARE(signatDefault.toString(), QString("NoSig"));
+ Uml::SignatureType signat0(Uml::SignatureType::NoSig);
+ QCOMPARE(signat0.toString(), QString("NoSig"));
+*/
+}
+
QTEST_MAIN(TEST_basictypes)
#include "test_basictypes.moc"
More information about the umbrello-devel
mailing list