From a115c6255bb0f03a759f38c4e80ac8b41ad8880e Mon Sep 17 00:00:00 2001 From: Aleksandr Kuzin Date: Tue, 19 Nov 2024 13:55:01 +0100 Subject: [PATCH] unit tests --- asam_cmp_data_sink/tests/test_capture_fb.cpp | 14 ++++++++++++++ asam_cmp_data_sink/tests/test_data_sink_fb.cpp | 15 +++++++++++++++ asam_cmp_data_sink/tests/test_interface_fb.cpp | 15 +++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/asam_cmp_data_sink/tests/test_capture_fb.cpp b/asam_cmp_data_sink/tests/test_capture_fb.cpp index e8ba6b6..705351c 100644 --- a/asam_cmp_data_sink/tests/test_capture_fb.cpp +++ b/asam_cmp_data_sink/tests/test_capture_fb.cpp @@ -39,6 +39,20 @@ TEST_F(CaptureFbTest, FunctionBlockType) ASSERT_EQ(type.getDescription(), "ASAM CMP Capture"); } +TEST_F(CaptureFbTest, AvailableFunctionBlockTypes) +{ + auto availableTypes = captureFb.getAvailableFunctionBlockTypes(); + ASSERT_EQ(availableTypes.getCount(), 1); + ASSERT_TRUE(availableTypes.hasKey("AsamCmpInterface")); + ASSERT_EQ(availableTypes.get("AsamCmpInterface"), asam_cmp_common_lib::InterfaceCommonFb::CreateType()); +} + +TEST_F(CaptureFbTest, OnAddFunctionBlocks) +{ + EXPECT_NO_THROW(captureFb.addFunctionBlock("AsamCmpInterface")); + EXPECT_THROW(captureFb.addFunctionBlock("AsamCmpStream"), daq::NotFoundException); +} + TEST_F(CaptureFbTest, CaptureModuleProperties) { ASSERT_TRUE(captureFb.hasProperty("DeviceId")); diff --git a/asam_cmp_data_sink/tests/test_data_sink_fb.cpp b/asam_cmp_data_sink/tests/test_data_sink_fb.cpp index cc07a10..5265265 100644 --- a/asam_cmp_data_sink/tests/test_data_sink_fb.cpp +++ b/asam_cmp_data_sink/tests/test_data_sink_fb.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -81,6 +82,20 @@ TEST_F(DataSinkFbTest, FunctionBlockType) ASSERT_EQ(type.getDescription(), "ASAM CMP Data Sink"); } +TEST_F(DataSinkFbTest, AvailableFunctionBlockTypes) +{ + auto availableTypes = funcBlock.getAvailableFunctionBlockTypes(); + ASSERT_EQ(availableTypes.getCount(), 1); + ASSERT_TRUE(availableTypes.hasKey("AsamCmpCapture")); + ASSERT_EQ(availableTypes.get("AsamCmpCapture"), CaptureFb::CreateType()); +} + +TEST_F(DataSinkFbTest, OnAddFunctionBlocks) +{ + EXPECT_NO_THROW(funcBlock.addFunctionBlock("AsamCmpCapture")); + EXPECT_THROW(funcBlock.addFunctionBlock("AsamCmpStream"), daq::NotFoundException); +} + TEST_F(DataSinkFbTest, AddCaptureModuleFromStatusReadOnly) { auto proc = daq::Procedure([]() {}); diff --git a/asam_cmp_data_sink/tests/test_interface_fb.cpp b/asam_cmp_data_sink/tests/test_interface_fb.cpp index 05d9242..f1eeea9 100644 --- a/asam_cmp_data_sink/tests/test_interface_fb.cpp +++ b/asam_cmp_data_sink/tests/test_interface_fb.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -45,6 +46,20 @@ TEST_F(InterfaceFbTest, FunctionBlockType) ASSERT_EQ(type.getDescription(), "ASAM CMP Interface"); } +TEST_F(InterfaceFbTest, AvailableFunctionBlockTypes) +{ + auto availableTypes = interfaceFb.getAvailableFunctionBlockTypes(); + ASSERT_EQ(availableTypes.getCount(), 1); + ASSERT_TRUE(availableTypes.hasKey("AsamCmpStream")); + ASSERT_EQ(availableTypes.get("AsamCmpStream"), modules::asam_cmp_data_sink_module::StreamFb::CreateType()); +} + +TEST_F(InterfaceFbTest, OnAddFunctionBlocks) +{ + EXPECT_NO_THROW(interfaceFb.addFunctionBlock("AsamCmpStream")); + EXPECT_THROW(interfaceFb.addFunctionBlock("AsamCmpCapture"), daq::NotFoundException); +} + TEST_F(InterfaceFbTest, CaptureModuleProperties) { ASSERT_TRUE(interfaceFb.hasProperty("InterfaceId"));