Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
ECSS Services
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AcubeSat-OBC
ECSS Services
Commits
0ea4a01c
Commit
0ea4a01c
authored
6 years ago
by
thodkatz
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for ST[01]
parent
4d101054
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CMakeLists.txt
+4
-2
4 additions, 2 deletions
CMakeLists.txt
test/Services/RequestVerificationService.cpp
+113
-0
113 additions, 0 deletions
test/Services/RequestVerificationService.cpp
with
117 additions
and
2 deletions
CMakeLists.txt
+
4
−
2
View file @
0ea4a01c
...
...
@@ -19,7 +19,9 @@ add_executable(ecss_services src/main.cpp src/Message.cpp src/Service.cpp
IF
(
EXISTS
"
${
PROJECT_SOURCE_DIR
}
/lib/Catch2/CMakeLists.txt"
)
add_subdirectory
(
lib/Catch2
)
add_executable
(
tests src/Message.cpp src/Services/TestService.cpp test/tests.cpp
test/Message.cpp test/TestPlatform.cpp test/Services/TestService.cpp
)
add_executable
(
tests src/Message.cpp src/Services/TestService.cpp
src/Services/RequestVerificationService.cpp test/tests.cpp
test/Message.cpp test/TestPlatform.cpp test/Services/TestService.cpp
test/Services/RequestVerificationService.cpp
)
target_link_libraries
(
tests Catch2::Catch2
)
ENDIF
()
This diff is collapsed.
Click to expand it.
test/Services/RequestVerificationService.cpp
0 → 100644
+
113
−
0
View file @
0ea4a01c
#include
<catch2/catch.hpp>
#include
<Services/RequestVerificationService.hpp>
#include
<Message.hpp>
#include
"ServiceTests.hpp"
TEST_CASE
(
"TM[1,1]"
,
"[service][st01]"
)
{
RequestVerificationService
reqVerifService
;
reqVerifService
.
successAcceptanceVerification
(
Message
::
TC
,
true
,
2
,
2
,
10
);
REQUIRE
(
ServiceTests
::
hasOneMessage
());
Message
response
=
ServiceTests
::
get
(
0
);
// Checks for the class-members of the object response
CHECK
(
response
.
serviceType
==
1
);
CHECK
(
response
.
messageType
==
1
);
CHECK
(
response
.
packetType
==
0
);
// packet type(TM = 0, TC = 1)
CHECK
(
response
.
applicationId
==
0
);
REQUIRE
(
response
.
dataSize
==
4
);
// dataSize is the number of bytes of data array
// Check for the value that is stored in data array(member-class of object response)
CHECK
(
response
.
readEnumerated
(
3
)
==
2
);
// packet version number
CHECK
(
response
.
readEnumerated
(
1
)
==
1
);
// packet type
CHECK
(
response
.
readBits
(
1
)
==
true
);
// secondary header flag
CHECK
(
response
.
readEnumerated
(
11
)
==
2
);
// application process ID
CHECK
(
response
.
readEnumerated
(
2
)
==
2
);
// sequence flags
CHECK
(
response
.
readBits
(
14
)
==
10
);
// packet sequence count
}
TEST_CASE
(
"TM[1,2]"
,
"[service][st01]"
)
{
RequestVerificationService
reqVerifService
;
reqVerifService
.
failAcceptanceVerification
(
Message
::
TC
,
true
,
2
,
2
,
10
,
5
);
REQUIRE
(
ServiceTests
::
hasOneMessage
());
Message
response
=
ServiceTests
::
get
(
0
);
// Checks for the class-members of the object response
CHECK
(
response
.
serviceType
==
1
);
CHECK
(
response
.
messageType
==
2
);
CHECK
(
response
.
packetType
==
0
);
// packet type(TM = 0, TC = 1)
CHECK
(
response
.
applicationId
==
0
);
REQUIRE
(
response
.
dataSize
==
6
);
// dataSize is the number of bytes of data array
// Check for the value that is stored in data array(member-class of object response)
CHECK
(
response
.
readEnumerated
(
3
)
==
2
);
// packet version number
CHECK
(
response
.
readEnumerated
(
1
)
==
1
);
// packet type
CHECK
(
response
.
readBits
(
1
)
==
true
);
// secondary header flag
CHECK
(
response
.
readEnumerated
(
11
)
==
2
);
// application process ID
CHECK
(
response
.
readEnumerated
(
2
)
==
2
);
// sequence flags
CHECK
(
response
.
readBits
(
14
)
==
10
);
// packet sequence count
CHECK
(
response
.
readEnum16
()
==
5
);
// error code
}
TEST_CASE
(
"TM[1,7]"
,
"[service][st01]"
)
{
RequestVerificationService
reqVerifService
;
reqVerifService
.
successExecutionVerification
(
Message
::
TC
,
true
,
2
,
2
,
10
);
REQUIRE
(
ServiceTests
::
hasOneMessage
());
Message
response
=
ServiceTests
::
get
(
0
);
// Checks for the class-members of the object response
CHECK
(
response
.
serviceType
==
1
);
CHECK
(
response
.
messageType
==
7
);
CHECK
(
response
.
packetType
==
0
);
// packet type(TM = 0, TC = 1)
CHECK
(
response
.
applicationId
==
0
);
REQUIRE
(
response
.
dataSize
==
4
);
// dataSize is the number of bytes of data array
// Check for the value that is stored in data array(member-class of object response)
CHECK
(
response
.
readEnumerated
(
3
)
==
2
);
// packet version number
CHECK
(
response
.
readEnumerated
(
1
)
==
1
);
// packet type
CHECK
(
response
.
readBits
(
1
)
==
true
);
// secondary header flag
CHECK
(
response
.
readEnumerated
(
11
)
==
2
);
// application process ID
CHECK
(
response
.
readEnumerated
(
2
)
==
2
);
// sequence flags
CHECK
(
response
.
readBits
(
14
)
==
10
);
// packet sequence count
}
TEST_CASE
(
"TM[1,8]"
,
"[service][st01]"
)
{
RequestVerificationService
reqVerifService
;
reqVerifService
.
failExecutionVerification
(
Message
::
TC
,
true
,
2
,
2
,
10
,
6
);
REQUIRE
(
ServiceTests
::
hasOneMessage
());
Message
response
=
ServiceTests
::
get
(
0
);
// Checks for the class-members of the object response
CHECK
(
response
.
serviceType
==
1
);
CHECK
(
response
.
messageType
==
8
);
CHECK
(
response
.
packetType
==
0
);
// packet type(TM = 0, TC = 1)
CHECK
(
response
.
applicationId
==
0
);
REQUIRE
(
response
.
dataSize
==
6
);
// dataSize is the number of bytes of data array
// Check for the value that is stored in data array(member-class of object response)
CHECK
(
response
.
readEnumerated
(
3
)
==
2
);
// packet version number
CHECK
(
response
.
readEnumerated
(
1
)
==
1
);
// packet type
CHECK
(
response
.
readBits
(
1
)
==
true
);
// secondary header flag
CHECK
(
response
.
readEnumerated
(
11
)
==
2
);
// application process ID
CHECK
(
response
.
readEnumerated
(
2
)
==
2
);
// sequence flags
CHECK
(
response
.
readBits
(
14
)
==
10
);
// packet sequence count
CHECK
(
response
.
readEnum16
()
==
6
);
// error code
}
TEST_CASE
(
"TM[1,10]"
,
"[service][st01]"
)
{
RequestVerificationService
reqVerifService
;
reqVerifService
.
failRoutingVerification
(
Message
::
TC
,
true
,
2
,
2
,
10
,
7
);
REQUIRE
(
ServiceTests
::
hasOneMessage
());
Message
response
=
ServiceTests
::
get
(
0
);
// Checks for the class-members of the object response
CHECK
(
response
.
serviceType
==
1
);
CHECK
(
response
.
messageType
==
10
);
CHECK
(
response
.
packetType
==
0
);
// packet type(TM = 0, TC = 1)
CHECK
(
response
.
applicationId
==
0
);
REQUIRE
(
response
.
dataSize
==
6
);
// dataSize is the number of bytes of data array
// Check for the value that is stored in data array(member-class of object response)
CHECK
(
response
.
readEnumerated
(
3
)
==
2
);
// packet version number
CHECK
(
response
.
readEnumerated
(
1
)
==
1
);
// packet type
CHECK
(
response
.
readBits
(
1
)
==
true
);
// secondary header flag
CHECK
(
response
.
readEnumerated
(
11
)
==
2
);
// application process ID
CHECK
(
response
.
readEnumerated
(
2
)
==
2
);
// sequence flags
CHECK
(
response
.
readBits
(
14
)
==
10
);
// packet sequence count
CHECK
(
response
.
readEnum16
()
==
7
);
// error code
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment