Merge branch 'development' into mueller/serializeif-update
This commit is contained in:
@ -171,14 +171,19 @@ TEST_CASE("DataSetTest" , "[DataSetTest]") {
|
||||
/* We can do it like this because the buffer only has one byte for
|
||||
less than 8 variables */
|
||||
uint8_t* validityByte = buffer + sizeof(buffer) - 1;
|
||||
CHECK(bitutil::bitGet(validityByte, 0) == true);
|
||||
CHECK(bitutil::bitGet(validityByte, 1) == false);
|
||||
CHECK(bitutil::bitGet(validityByte, 2) == true);
|
||||
bool bitSet = false;
|
||||
bitutil::get(validityByte, 0, bitSet);
|
||||
|
||||
CHECK(bitSet == true);
|
||||
bitutil::get(validityByte, 1, bitSet);
|
||||
CHECK(bitSet == false);
|
||||
bitutil::get(validityByte, 2, bitSet);
|
||||
CHECK(bitSet == true);
|
||||
|
||||
/* Now we manipulate the validity buffer for the deserialization */
|
||||
bitutil::bitClear(validityByte, 0);
|
||||
bitutil::bitSet(validityByte, 1);
|
||||
bitutil::bitClear(validityByte, 2);
|
||||
bitutil::clear(validityByte, 0);
|
||||
bitutil::set(validityByte, 1);
|
||||
bitutil::clear(validityByte, 2);
|
||||
/* Zero out everything except validity buffer */
|
||||
std::memset(buffer, 0, sizeof(buffer) - 1);
|
||||
sizeToDeserialize = maxSize;
|
||||
@ -239,8 +244,11 @@ TEST_CASE("DataSetTest" , "[DataSetTest]") {
|
||||
std::memcpy(validityBuffer.data(), buffer + 9 + sizeof(uint16_t) * 3, 2);
|
||||
/* The first 9 variables should be valid */
|
||||
CHECK(validityBuffer[0] == 0xff);
|
||||
CHECK(bitutil::bitGet(validityBuffer.data() + 1, 0) == true);
|
||||
CHECK(bitutil::bitGet(validityBuffer.data() + 1, 1) == false);
|
||||
bool bitSet = false;
|
||||
bitutil::get(validityBuffer.data() + 1, 0, bitSet);
|
||||
CHECK(bitSet == true);
|
||||
bitutil::get(validityBuffer.data() + 1, 1, bitSet);
|
||||
CHECK(bitSet == false);
|
||||
|
||||
/* Now we invert the validity */
|
||||
validityBuffer[0] = 0;
|
||||
|
@ -1,3 +1,5 @@
|
||||
target_sources(${FSFW_TEST_TGT} PRIVATE
|
||||
testDleEncoder.cpp
|
||||
testOpDivider.cpp
|
||||
testBitutil.cpp
|
||||
)
|
||||
|
64
tests/src/fsfw_tests/unit/globalfunctions/testBitutil.cpp
Normal file
64
tests/src/fsfw_tests/unit/globalfunctions/testBitutil.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
#include "fsfw/globalfunctions/bitutility.h"
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
TEST_CASE("Bitutility" , "[Bitutility]") {
|
||||
uint8_t dummyByte = 0;
|
||||
bool bitSet = false;
|
||||
for(uint8_t pos = 0; pos < 8; pos++) {
|
||||
bitutil::set(&dummyByte, pos);
|
||||
REQUIRE(dummyByte == (1 << (7 - pos)));
|
||||
bitutil::get(&dummyByte, pos, bitSet);
|
||||
REQUIRE(bitSet == 1);
|
||||
dummyByte = 0;
|
||||
}
|
||||
|
||||
dummyByte = 0xff;
|
||||
for(uint8_t pos = 0; pos < 8; pos++) {
|
||||
bitutil::get(&dummyByte, pos, bitSet);
|
||||
REQUIRE(bitSet == 1);
|
||||
bitutil::clear(&dummyByte, pos);
|
||||
bitutil::get(&dummyByte, pos, bitSet);
|
||||
REQUIRE(bitSet == 0);
|
||||
dummyByte = 0xff;
|
||||
}
|
||||
|
||||
dummyByte = 0xf0;
|
||||
for(uint8_t pos = 0; pos < 8; pos++) {
|
||||
if(pos < 4) {
|
||||
bitutil::get(&dummyByte, pos, bitSet);
|
||||
REQUIRE(bitSet == 1);
|
||||
bitutil::toggle(&dummyByte, pos);
|
||||
bitutil::get(&dummyByte, pos, bitSet);
|
||||
REQUIRE(bitSet == 0);
|
||||
}
|
||||
else {
|
||||
bitutil::get(&dummyByte, pos, bitSet);
|
||||
REQUIRE(bitSet == false);
|
||||
bitutil::toggle(&dummyByte, pos);
|
||||
bitutil::get(&dummyByte, pos, bitSet);
|
||||
REQUIRE(bitSet == true);
|
||||
}
|
||||
}
|
||||
REQUIRE(dummyByte == 0x0f);
|
||||
|
||||
dummyByte = 0;
|
||||
bitutil::set(&dummyByte, 8);
|
||||
REQUIRE(dummyByte == 0);
|
||||
bitutil::set(&dummyByte, -1);
|
||||
REQUIRE(dummyByte == 0);
|
||||
dummyByte = 0xff;
|
||||
bitutil::clear(&dummyByte, 8);
|
||||
REQUIRE(dummyByte == 0xff);
|
||||
bitutil::clear(&dummyByte, -1);
|
||||
REQUIRE(dummyByte == 0xff);
|
||||
dummyByte = 0x00;
|
||||
bitutil::toggle(&dummyByte, 8);
|
||||
REQUIRE(dummyByte == 0x00);
|
||||
bitutil::toggle(&dummyByte, -1);
|
||||
REQUIRE(dummyByte == 0x00);
|
||||
|
||||
REQUIRE(bitutil::get(&dummyByte, 8, bitSet) == false);
|
||||
}
|
||||
|
||||
|
||||
|
64
tests/src/fsfw_tests/unit/globalfunctions/testOpDivider.cpp
Normal file
64
tests/src/fsfw_tests/unit/globalfunctions/testOpDivider.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
#include "fsfw/globalfunctions/PeriodicOperationDivider.h"
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
TEST_CASE("OpDivider" , "[OpDivider]") {
|
||||
auto opDivider = PeriodicOperationDivider(1);
|
||||
REQUIRE(opDivider.getDivider() == 1);
|
||||
REQUIRE(opDivider.getCounter() == 1);
|
||||
REQUIRE(opDivider.check() == true);
|
||||
REQUIRE(opDivider.checkAndIncrement() == true);
|
||||
REQUIRE(opDivider.getCounter() == 1);
|
||||
REQUIRE(opDivider.check() == true);
|
||||
REQUIRE(opDivider.checkAndIncrement() == true);
|
||||
REQUIRE(opDivider.checkAndIncrement() == true);
|
||||
|
||||
opDivider.setDivider(0);
|
||||
REQUIRE(opDivider.getCounter() == 1);
|
||||
REQUIRE(opDivider.checkAndIncrement() == true);
|
||||
REQUIRE(opDivider.getCounter() == 1);
|
||||
REQUIRE(opDivider.checkAndIncrement() == true);
|
||||
REQUIRE(opDivider.checkAndIncrement() == true);
|
||||
|
||||
opDivider.setDivider(2);
|
||||
opDivider.resetCounter();
|
||||
REQUIRE(opDivider.getDivider() == 2);
|
||||
REQUIRE(opDivider.getCounter() == 1);
|
||||
REQUIRE(opDivider.check() == false);
|
||||
REQUIRE(opDivider.checkAndIncrement() == false);
|
||||
REQUIRE(opDivider.getCounter() == 2);
|
||||
REQUIRE(opDivider.check() == true);
|
||||
REQUIRE(opDivider.checkAndIncrement() == true);
|
||||
REQUIRE(opDivider.getCounter() == 1);
|
||||
REQUIRE(opDivider.check() == false);
|
||||
REQUIRE(opDivider.checkAndIncrement() == false);
|
||||
REQUIRE(opDivider.getCounter() == 2);
|
||||
REQUIRE(opDivider.checkAndIncrement() == true);
|
||||
REQUIRE(opDivider.checkAndIncrement() == false);
|
||||
REQUIRE(opDivider.checkAndIncrement() == true);
|
||||
REQUIRE(opDivider.checkAndIncrement() == false);
|
||||
|
||||
opDivider.setDivider(3);
|
||||
opDivider.resetCounter();
|
||||
REQUIRE(opDivider.checkAndIncrement() == false);
|
||||
REQUIRE(opDivider.checkAndIncrement() == false);
|
||||
REQUIRE(opDivider.getCounter() == 3);
|
||||
REQUIRE(opDivider.checkAndIncrement() == true);
|
||||
REQUIRE(opDivider.getCounter() == 1);
|
||||
REQUIRE(opDivider.checkAndIncrement() == false);
|
||||
|
||||
auto opDividerNonResetting = PeriodicOperationDivider(2, false);
|
||||
REQUIRE(opDividerNonResetting.getCounter() == 1);
|
||||
REQUIRE(opDividerNonResetting.check() == false);
|
||||
REQUIRE(opDividerNonResetting.checkAndIncrement() == false);
|
||||
REQUIRE(opDividerNonResetting.getCounter() == 2);
|
||||
REQUIRE(opDividerNonResetting.check() == true);
|
||||
REQUIRE(opDividerNonResetting.checkAndIncrement() == true);
|
||||
REQUIRE(opDividerNonResetting.getCounter() == 3);
|
||||
REQUIRE(opDividerNonResetting.checkAndIncrement() == true);
|
||||
REQUIRE(opDividerNonResetting.getCounter() == 4);
|
||||
opDividerNonResetting.resetCounter();
|
||||
REQUIRE(opDividerNonResetting.getCounter() == 1);
|
||||
REQUIRE(opDividerNonResetting.check() == false);
|
||||
REQUIRE(opDividerNonResetting.checkAndIncrement() == false);
|
||||
REQUIRE(opDividerNonResetting.getCounter() == 2);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
target_sources(${FSFW_TEST_TGT} PRIVATE
|
||||
PusTmTest.cpp
|
||||
testCcsds.cpp
|
||||
)
|
||||
|
11
tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp
Normal file
11
tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "fsfw/tmtcpacket/SpacePacket.h"
|
||||
|
||||
TEST_CASE( "CCSDS Test" , "[ccsds]") {
|
||||
REQUIRE(spacepacket::getTcSpacePacketIdFromApid(0x22) == 0x1822);
|
||||
REQUIRE(spacepacket::getTmSpacePacketIdFromApid(0x22) == 0x0822);
|
||||
|
||||
REQUIRE(spacepacket::getTcSpacePacketIdFromApid(0x7ff) == 0x1fff);
|
||||
REQUIRE(spacepacket::getTmSpacePacketIdFromApid(0x7ff) == 0xfff);
|
||||
}
|
Reference in New Issue
Block a user