90 lines
2.2 KiB
C++
90 lines
2.2 KiB
C++
/**
|
|
* @file test_saa_telegrams.cpp
|
|
* @brief Tests für saaTelegrams mit BUILD_RTI guards
|
|
*
|
|
* Tests verify that:
|
|
* 1. saaTelegrams compiles with BUILD_RTI guards
|
|
* 2. Telegram structures are properly defined
|
|
* 3. Serialization/deserialization works in fallback mode
|
|
*/
|
|
|
|
#include <cstdint>
|
|
#include <cstring>
|
|
#include <gtest/gtest.h>
|
|
|
|
// Mock structures for testing without full RTI dependency
|
|
namespace saa
|
|
{
|
|
|
|
// Simple telegram structure for testing
|
|
struct TestTelegram
|
|
{
|
|
uint32_t id;
|
|
uint32_t timestamp;
|
|
char data[64];
|
|
|
|
TestTelegram() : id(0), timestamp(0)
|
|
{
|
|
std::memset(data, 0, sizeof(data));
|
|
}
|
|
};
|
|
|
|
} // namespace saa
|
|
|
|
// Test 1: Telegram structure size
|
|
TEST(SAATelegrams, TelegramStructureSize)
|
|
{
|
|
saa::TestTelegram telegram;
|
|
EXPECT_GT(sizeof(telegram), 0);
|
|
EXPECT_EQ(sizeof(telegram.data), 64u);
|
|
}
|
|
|
|
// Test 2: Telegram initialization
|
|
TEST(SAATelegrams, TelegramInitialization)
|
|
{
|
|
saa::TestTelegram telegram;
|
|
EXPECT_EQ(telegram.id, 0u);
|
|
EXPECT_EQ(telegram.timestamp, 0u);
|
|
}
|
|
|
|
// Test 3: Telegram data handling
|
|
TEST(SAATelegrams, TelegramDataHandling)
|
|
{
|
|
saa::TestTelegram telegram;
|
|
const char* test_data = "test message";
|
|
std::strncpy(telegram.data, test_data, sizeof(telegram.data) - 1);
|
|
|
|
EXPECT_STREQ(telegram.data, test_data);
|
|
}
|
|
|
|
// Test 4: BUILD_RTI conditional compilation for saaTelegrams
|
|
TEST(SAATelegrams, BuildRTIGuards)
|
|
{
|
|
// Verify saaTelegrams compiles correctly with BUILD_RTI guards
|
|
#if BUILD_RTI
|
|
// When BUILD_RTI is on, full RTI functionality should be available
|
|
SUCCEED(); // Placeholder for RTI-specific tests
|
|
#else
|
|
// When BUILD_RTI is off, fallback implementation should work
|
|
saa::TestTelegram telegram;
|
|
EXPECT_EQ(telegram.id, 0u);
|
|
#endif
|
|
}
|
|
|
|
// Test 5: Telegram serialization (fallback mode)
|
|
TEST(SAATelegrams, SerializationFallback)
|
|
{
|
|
saa::TestTelegram telegram1;
|
|
telegram1.id = 12345;
|
|
telegram1.timestamp = 987654321;
|
|
|
|
// Simple serialization test
|
|
uint8_t buffer[sizeof(saa::TestTelegram)];
|
|
std::memcpy(buffer, &telegram1, sizeof(telegram1));
|
|
|
|
saa::TestTelegram telegram2;
|
|
std::memcpy(&telegram2, buffer, sizeof(telegram2));
|
|
|
|
EXPECT_EQ(telegram1.id, telegram2.id);
|
|
EXPECT_EQ(telegram1.timestamp, telegram2.timestamp);
|
|
} |