Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
JuPedSim
JPSeditor
Commits
5a3bd473
Commit
5a3bd473
authored
Feb 15, 2019
by
guido basten
Browse files
Added the first unit tests for jpsdatamanager and the tests.pro
parent
de71ab24
Pipeline
#17082
failed with stages
in 12 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
jpseditor.pro
View file @
5a3bd473
...
...
@@ -4,3 +4,4 @@ CONFIG+=ordered
SUBDIRS
=
\
src
\
tests
\
tests/TestMain.cpp
0 → 100644
View file @
5a3bd473
#define CATCH_CONFIG_MAIN
#include
<catch2/catch.hpp>
tests/datamanager_tests.cpp
0 → 100644
View file @
5a3bd473
#include
<catch2/catch.hpp>
#include
"../src/datamanager.h"
#include
"../src/jpsLineItem.h"
#include
"../src/jpsregion.h"
#include
"../src/jpslandmark.h"
jpsRegion
create_testregion
(
int
&
id
);
TEST_CASE
(
"get functions"
)
{
jpsDatamanager
*
testobject
=
new
jpsDatamanager
;
SECTION
(
"get roomlist"
)
{
QList
<
jpsRoom
*>
testroomlist
;
//test the length of the roomlist with get_roomlist
testroomlist
=
testobject
->
get_roomlist
();
REQUIRE
(
testroomlist
.
length
()
==
0
);
//add a room with new_room and check the length again
testobject
->
new_room
();
testroomlist
=
testobject
->
get_roomlist
();
REQUIRE
(
testroomlist
.
length
()
==
1
);
testobject
->
new_room
();
testroomlist
=
testobject
->
get_roomlist
();
REQUIRE
(
testroomlist
.
length
()
==
2
);
}
SECTION
(
"get crossingList"
)
{
//test the length of the crossingList with get_crossingList
REQUIRE
(
testobject
->
get_crossingList
().
length
()
==
0
);
// add a crossingpiont (door) to the list
QGraphicsLineItem
*
testline
=
new
QGraphicsLineItem
(
qreal
(
0
),
qreal
(
0
),
qreal
(
2
),
qreal
(
0
));
jpsLineItem
*
testLineItem_1
=
new
jpsLineItem
(
testline
);
testLineItem_1
->
set_Door
();
testobject
->
new_crossing
(
testLineItem_1
);
REQUIRE
(
testobject
->
get_crossingList
().
length
()
==
1
);
testline
->
setLine
(
qreal
(
2
),
qreal
(
2
),
qreal
(
4
),
qreal
(
2
));
jpsLineItem
*
testLineItem_2
=
new
jpsLineItem
(
testline
);
testLineItem_2
->
set_Door
();
testobject
->
new_crossing
(
testLineItem_2
);
REQUIRE
(
testobject
->
get_crossingList
().
length
()
==
2
);
}
SECTION
(
"get obstacellist"
)
{
//test the length of the obstaclelist with get_obstacleist
REQUIRE
(
testobject
->
get_obstaclelist
().
length
()
==
0
);
//add a obstacle and test the length again
testobject
->
new_obstacle
();
REQUIRE
(
testobject
->
get_obstaclelist
().
length
()
==
1
);
testobject
->
new_obstacle
();
REQUIRE
(
testobject
->
get_obstaclelist
().
length
()
==
2
);
}
SECTION
(
"get exitlist"
)
{
//test the length of the exitlist with get_exitlist
REQUIRE
(
testobject
->
get_exitList
().
length
()
==
0
);
//add a exit and test the length again
QGraphicsLineItem
*
testline
=
new
QGraphicsLineItem
(
qreal
(
0
),
qreal
(
0
),
qreal
(
2
),
qreal
(
0
));
jpsLineItem
*
testLineItem_1
=
new
jpsLineItem
(
testline
);
testobject
->
new_exit
(
testLineItem_1
);
REQUIRE
(
testobject
->
get_exitList
().
length
()
==
1
);
testline
->
setLine
(
qreal
(
2
),
qreal
(
2
),
qreal
(
4
),
qreal
(
2
));
jpsLineItem
*
testLineItem_2
=
new
jpsLineItem
(
testline
);
testobject
->
new_exit
(
testLineItem_2
);
REQUIRE
(
testobject
->
get_exitList
().
length
()
==
2
);
}
SECTION
(
"get all connections"
)
{
//test the length of the connection list with GetAllConnections
REQUIRE
(
testobject
->
GetAllConnections
().
length
()
==
0
);
//add a connection and test the length again
jpsConnection
*
testconnection_1
=
new
jpsConnection
;
testobject
->
NewConnection
(
testconnection_1
);
REQUIRE
(
testobject
->
GetAllConnections
().
length
()
==
1
);
jpsConnection
*
testconnection_2
=
new
jpsConnection
;
testobject
->
NewConnection
(
testconnection_2
);
REQUIRE
(
testobject
->
GetAllConnections
().
length
()
==
2
);
}
SECTION
(
"get regions and get regions counter"
)
{
int
testid
=
1
;
REQUIRE
(
testobject
->
GetRegionCounter
()
==
0
);
REQUIRE
(
testobject
->
GetRegions
().
length
()
==
testobject
->
GetRegionCounter
());
jpsRegion
testregion_1
=
create_testregion
(
testid
);
testid
++
;
testobject
->
NewRegion
(
&
testregion_1
);
REQUIRE
(
testobject
->
GetRegionCounter
()
==
1
);
REQUIRE
(
testobject
->
GetRegions
().
length
()
==
testobject
->
GetRegionCounter
());
jpsRegion
testregion_2
=
create_testregion
(
testid
);
testobject
->
NewRegion
(
&
testregion_2
);
REQUIRE
(
testobject
->
GetRegionCounter
()
==
2
);
REQUIRE
(
testobject
->
GetRegions
().
length
()
==
testobject
->
GetRegionCounter
());
}
SECTION
(
"get landmarks"
)
{
//test the lenght if the landmark list with get_landmarks
REQUIRE
(
testobject
->
get_landmarks
().
length
()
==
0
);
//create and and add a landmark to the list. Then test it again
jpsLandmark
*
testlandmark_1
=
new
jpsLandmark
;
testobject
->
new_landmark
(
testlandmark_1
);
REQUIRE
(
testobject
->
get_landmarks
().
length
()
==
1
);
jpsLandmark
*
testlandmark_2
=
new
jpsLandmark
;
testobject
->
new_landmark
(
testlandmark_2
);
REQUIRE
(
testobject
->
get_landmarks
().
length
()
==
2
);
// delete testlandmark_1;
// delete testlandmark_2;
}
}
jpsRegion
create_testregion
(
int
&
id
)
{
const
QString
testcaption
=
"testcaption"
;
const
QString
testtype
=
"Regnion"
;
const
QPointF
testpoint
(
0
,
0
);
const
qreal
testqreal
=
0
;
jpsRegion
testregion
=
jpsRegion
(
id
,
testcaption
,
testpoint
,
testqreal
,
testqreal
);
return
testregion
;
}
tests/tests.pro
0 → 100644
View file @
5a3bd473
QT
+=
core
gui
greaterThan
(
QT_MAJOR_VERSION
,
4
)
:
QT
+=
widgets
TARGET
=
JPSeditorUnitTests
TEMPLATE
=
app
CONFIG
+=
console
CONFIG
+=
c
++
11
FORMS
+=
\
..
/
src
/
forms
/
mainwindow
.
ui
\
..
/
src
/
forms
/
roomwidget
.
ui
\
..
/
src
/
forms
/
widgetlandmark
.
ui
\
..
/
src
/
forms
/
widgetsettings
.
ui
\
..
/
src
/
forms
/
inifilewidget
.
ui
\
..
/
src
/
forms
/
settingdialog
.
ui
SOURCES
+=
TestMain
.
cpp
\
datamanager_tests
.
cpp
\
..
/
src
/
mainWindow
.
cpp
\
..
/
src
/
GraphicView
.
cpp
\
..
/
src
/
roomwidget
.
cpp
\
..
/
src
/
rooms
.
cpp
\
..
/
src
/
datamanager
.
cpp
\
..
/
src
/
jpscrossing
.
cpp
\
..
/
src
/
jpsLineItem
.
cpp
\
..
/
src
/
jpsexit
.
cpp
\
..
/
src
/
jpsobstacle
.
cpp
\
..
/
src
/
jpslandmark
.
cpp
\
..
/
src
/
dxflib
/
src
/
dl_writer_ascii
.
cpp
\
..
/
src
/
dxflib
/
src
/
dl_dxf
.
cpp
\
..
/
src
/
widgetlandmark
.
cpp
\
..
/
src
/
graphicscene
.
cpp
\
..
/
src
/
widgetsettings
.
cpp
\
..
/
src
/
jpsconnection
.
cpp
\
..
/
src
/
UndoFramework
/
actionstack
.
cpp
\
..
/
src
/
UndoFramework
/
action
.
cpp
\
..
/
src
/
UndoFramework
/
lineaction
.
cpp
\
..
/
src
/
jpsregion
.
cpp
\
..
/
src
/
AutomaticRoomIdentification
/
roomdefinition
.
cpp
\
..
/
src
/
AutomaticRoomIdentification
/
roomidentification
.
cpp
\
..
/
src
/
settingdialog
.
cpp
\
..
/
src
/
tinyxml
/
tinystr
.
cpp
\
..
/
src
/
tinyxml
/
tinyxml
.
cpp
\
..
/
src
/
tinyxml
/
tinyxmlerror
.
cpp
\
..
/
src
/
tinyxml
/
tinyxmlparser
.
cpp
\
..
/
src
/
inifilewidget
.
cpp
\
HEADERS
+=
\
..
/
src
/
mainWindow
.
h
\
..
/
src
/
GraphicView
.
h
\
..
/
src
/
roomwidget
.
h
\
..
/
src
/
rooms
.
h
\
..
/
src
/
datamanager
.
h
\
..
/
src
/
jpscrossing
.
h
\
..
/
src
/
jpsLineItem
.
h
\
..
/
src
/
jpsexit
.
h
\
..
/
src
/
jpsobstacle
.
h
\
..
/
src
/
jpslandmark
.
h
\
..
/
src
/
dxflib
/
src
/
dl_writer_ascii
.
h
\
..
/
src
/
dxflib
/
src
/
dl_writer
.
h
\
..
/
src
/
dxflib
/
src
/
dl_global
.
h
\
..
/
src
/
dxflib
/
src
/
dl_extrusion
.
h
\
..
/
src
/
dxflib
/
src
/
dl_exception
.
h
\
..
/
src
/
dxflib
/
src
/
dl_entities
.
h
\
..
/
src
/
dxflib
/
src
/
dl_dxf
.
h
\
..
/
src
/
dxflib
/
src
/
dl_creationinterface
.
h
\
..
/
src
/
dxflib
/
src
/
dl_creationadapter
.
h
\
..
/
src
/
dxflib
/
src
/
dl_codes
.
h
\
..
/
src
/
dxflib
/
src
/
dl_attributes
.
h
\
..
/
src
/
widgetlandmark
.
h
\
..
/
src
/
graphicscene
.
h
\
..
/
src
/
widgetsettings
.
h
\
..
/
src
/
jpsconnection
.
h
\
..
/
src
/
UndoFramework
/
actionstack
.
h
\
..
/
src
/
UndoFramework
/
action
.
h
\
..
/
src
/
UndoFramework
/
lineaction
.
h
\
..
/
src
/
jpsregion
.
h
\
..
/
src
/
AutomaticRoomIdentification
/
roomID
.
h
\
..
/
src
/
AutomaticRoomIdentification
/
roomdefinition
.
h
\
..
/
src
/
AutomaticRoomIdentification
/
roomidentification
.
h
\
..
/
src
/
dtrace
.
h
\
..
/
src
/
settingdialog
.
h
\
..
/
src
/
tinyxml
/
tinystr
.
h
\
..
/
src
/
tinyxml
/
tinyxml
.
h
\
..
/
src
/
inifilewidget
.
h
\
INCLUDEPATH
+=
\
..
/
build
\
..
/
examples
\
..
/
src
\
..
/
examples
/
1
_tutorial
\
..
/
examples
/
2
_mixedusage
\
..
/
examples
/
3
_bottleneck
\
DESTDIR
=
$$
PWD
/..
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment