Skip to content

Commit

Permalink
iox-eclipse-iceoryx#1032 Remove 'EXPECTS_ENSURES_FAILED' and adjust t…
Browse files Browse the repository at this point in the history
…ests
  • Loading branch information
elBoberido committed Feb 5, 2024
1 parent 5ab18d0 commit 9e2e619
Show file tree
Hide file tree
Showing 31 changed files with 467 additions and 655 deletions.
18 changes: 6 additions & 12 deletions iceoryx_binding_c/test/moduletests/test_chunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,43 +173,37 @@ TEST_F(Chunk_test, GettingUserHeaderFromConstChunkHeaderWorks)
TEST_F(Chunk_test, GettingChunkHeaderToUserPayloadFromNullptrFails)
{
::testing::Test::RecordProperty("TEST_ID", "2ebe5462-c8f4-4572-b396-ae66f223de2b");
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { iox_chunk_header_from_user_payload(nullptr); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE([&] { iox_chunk_header_from_user_payload(nullptr); }, iox::er::ENFORCE_VIOLATION);
}

TEST_F(Chunk_test, GettingChunkHeaderToUserPayloadConstFromNullptrFails)
{
::testing::Test::RecordProperty("TEST_ID", "c0b27790-66eb-4f43-8f30-ec242508d7fd");
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { iox_chunk_header_to_user_payload_const(nullptr); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE([&] { iox_chunk_header_to_user_payload_const(nullptr); }, iox::er::ENFORCE_VIOLATION);
}

TEST_F(Chunk_test, GettingChunkHeaderToUserHeaderFromNullptrFails)
{
::testing::Test::RecordProperty("TEST_ID", "375dae26-76ba-40b2-9c33-768aa33d135f");
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { iox_chunk_header_to_user_header(nullptr); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE([&] { iox_chunk_header_to_user_header(nullptr); }, iox::er::ENFORCE_VIOLATION);
}

TEST_F(Chunk_test, GettingChunkHeaderToUserHeaderConstFromNullptrFails)
{
::testing::Test::RecordProperty("TEST_ID", "96b7691e-d0bf-4cb4-bf4b-39784dc70e92");
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { iox_chunk_header_to_user_header_const(nullptr); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE([&] { iox_chunk_header_to_user_header_const(nullptr); }, iox::er::ENFORCE_VIOLATION);
}

TEST_F(Chunk_test, GettingChunkHeaderFromUserPayloadFromNullptrFails)
{
::testing::Test::RecordProperty("TEST_ID", "5ced7508-2ee6-4e2b-bf66-e60d8b4d968c");
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { iox_chunk_header_from_user_payload(nullptr); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE([&] { iox_chunk_header_from_user_payload(nullptr); }, iox::er::ENFORCE_VIOLATION);
}

TEST_F(Chunk_test, GettingChunkHeaderFromUserPayloadConstFromNullptrFails)
{
::testing::Test::RecordProperty("TEST_ID", "8814d1c4-a5a9-4fa7-9520-507ca8745242");
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { iox_chunk_header_from_user_payload_const(nullptr); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE([&] { iox_chunk_header_from_user_payload_const(nullptr); }, iox::er::ENFORCE_VIOLATION);
}

} // namespace
79 changes: 30 additions & 49 deletions iceoryx_binding_c/test/moduletests/test_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,15 @@ TEST_F(iox_client_test, InitializedOptionsAreInitialized)
TEST_F(iox_client_test, InitializedOptionsWithNullptrFails)
{
::testing::Test::RecordProperty("TEST_ID", "3ae62644-5fb2-45cf-af99-b4daba43d044");
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { iox_client_options_init(nullptr); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE([&] { iox_client_options_init(nullptr); }, iox::er::ENFORCE_VIOLATION);
}

TEST_F(iox_client_test, CheckInitializedOptionsWithNullptrFails)
{
::testing::Test::RecordProperty("TEST_ID", "9a3b7845-170f-4b7f-a0a4-f5b43d96059f");
iox_client_options_t initializedOptions;
iox_client_options_init(&initializedOptions);
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { iox_client_options_is_initialized(nullptr); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE([&] { iox_client_options_is_initialized(nullptr); }, iox::er::ENFORCE_VIOLATION);
}

TEST_F(iox_client_test, InitializingClientWithNullptrFails)
Expand All @@ -177,27 +175,24 @@ TEST_F(iox_client_test, InitializingClientWithNullptrFails)
options.responseQueueFullPolicy = QueueFullPolicy_BLOCK_PRODUCER;
options.serverTooSlowPolicy = ConsumerTooSlowPolicy_WAIT_FOR_CONSUMER;

IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { iox_client_init(nullptr, SERVICE, INSTANCE, EVENT, &options); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { iox_client_init(&sutStorage, nullptr, INSTANCE, EVENT, &options); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { iox_client_init(&sutStorage, SERVICE, nullptr, EVENT, &options); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>(
[&] { iox_client_init(&sutStorage, SERVICE, INSTANCE, nullptr, &options); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE([&] { iox_client_init(nullptr, SERVICE, INSTANCE, EVENT, &options); },
iox::er::ENFORCE_VIOLATION);
IOX_EXPECT_FATAL_FAILURE([&] { iox_client_init(&sutStorage, nullptr, INSTANCE, EVENT, &options); },
iox::er::ENFORCE_VIOLATION);
IOX_EXPECT_FATAL_FAILURE([&] { iox_client_init(&sutStorage, SERVICE, nullptr, EVENT, &options); },
iox::er::ENFORCE_VIOLATION);
IOX_EXPECT_FATAL_FAILURE([&] { iox_client_init(&sutStorage, SERVICE, INSTANCE, nullptr, &options); },
iox::er::ENFORCE_VIOLATION);
iox_client_options_t emptyOpts;
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>(
[&] { iox_client_init(&sutStorage, SERVICE, INSTANCE, EVENT, &emptyOpts); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE([&] { iox_client_init(&sutStorage, SERVICE, INSTANCE, EVENT, &emptyOpts); },
iox::er::ENFORCE_VIOLATION);
}

TEST_F(iox_client_test, DeinitClientWithNullptrFails)
{
::testing::Test::RecordProperty("TEST_ID", "2f055b75-3cdd-4a55-b292-86b1ffb7a32d");

IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { iox_client_deinit(nullptr); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE([&] { iox_client_deinit(nullptr); }, iox::er::ENFORCE_VIOLATION);
}

TEST_F(iox_client_test, LoanAlignedChunkWithNullptrFails)
Expand All @@ -207,11 +202,10 @@ TEST_F(iox_client_test, LoanAlignedChunkWithNullptrFails)
iox_client_t sut = iox_client_init(&sutStorage, SERVICE, INSTANCE, EVENT, nullptr);
constexpr uint64_t ALIGNMENT = 128;
void* payload = nullptr;
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>(
[&] { iox_client_loan_aligned_request(nullptr, &payload, 32, ALIGNMENT); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { iox_client_loan_aligned_request(sut, nullptr, 32, ALIGNMENT); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE([&] { iox_client_loan_aligned_request(nullptr, &payload, 32, ALIGNMENT); },
iox::er::ENFORCE_VIOLATION);
IOX_EXPECT_FATAL_FAILURE([&] { iox_client_loan_aligned_request(sut, nullptr, 32, ALIGNMENT); },
iox::er::ENFORCE_VIOLATION);
iox_client_deinit(sut);
}

Expand All @@ -224,11 +218,9 @@ TEST_F(iox_client_test, ReleaseClientWithNullptrFails)
void* payload = nullptr;
EXPECT_THAT(iox_client_loan_request(sut, &payload, 32), Eq(AllocationResult_SUCCESS));

IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { iox_client_release_request(nullptr, payload); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE([&] { iox_client_release_request(nullptr, payload); }, iox::er::ENFORCE_VIOLATION);

IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { iox_client_release_request(sut, nullptr); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE([&] { iox_client_release_request(sut, nullptr); }, iox::er::ENFORCE_VIOLATION);
iox_client_deinit(sut);
}

Expand All @@ -243,33 +235,29 @@ TEST_F(iox_client_test, SendWithNullptrFails)
EXPECT_THAT(iox_client_loan_request(sut, &payload, sizeof(int64_t)), Eq(AllocationResult_SUCCESS));
*static_cast<int64_t*>(payload) = 8912389;

IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { iox_client_send(nullptr, payload); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE([&] { iox_client_send(nullptr, payload); }, iox::er::ENFORCE_VIOLATION);
iox_client_deinit(sut);
}

TEST_F(iox_client_test, ClientConnectWithNullptrFails)
{
::testing::Test::RecordProperty("TEST_ID", "f778de64-e153-4fb7-9535-9bd288979cc9");

IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { iox_client_connect(nullptr); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE([&] { iox_client_connect(nullptr); }, iox::er::ENFORCE_VIOLATION);
}

TEST_F(iox_client_test, ClientDisconnectWithNullptrFails)
{
::testing::Test::RecordProperty("TEST_ID", "69e69ebc-f8bd-4d70-9eee-de593acc5019");

IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { iox_client_disconnect(nullptr); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE([&] { iox_client_disconnect(nullptr); }, iox::er::ENFORCE_VIOLATION);
}

TEST_F(iox_client_test, ClientGetConnectStateWithNullptrFails)
{
::testing::Test::RecordProperty("TEST_ID", "cdf21827-47c8-49d8-bf07-b375dab74a70");

IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { iox_client_get_connection_state(nullptr); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE([&] { iox_client_get_connection_state(nullptr); }, iox::er::ENFORCE_VIOLATION);
}

TEST_F(iox_client_test, ClientTakeResponseWithNullptrFails)
Expand All @@ -282,10 +270,8 @@ TEST_F(iox_client_test, ClientTakeResponseWithNullptrFails)
const void* payload = nullptr;

EXPECT_THAT(iox_client_take_response(sut, &payload), Eq(ChunkReceiveResult_SUCCESS));
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { iox_client_take_response(nullptr, &payload); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { iox_client_take_response(sut, nullptr); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE([&] { iox_client_take_response(nullptr, &payload); }, iox::er::ENFORCE_VIOLATION);
IOX_EXPECT_FATAL_FAILURE([&] { iox_client_take_response(sut, nullptr); }, iox::er::ENFORCE_VIOLATION);
iox_client_deinit(sut);
}

Expand All @@ -301,10 +287,8 @@ TEST_F(iox_client_test, ClientReleasingResponseWithNullptrFails)
iox_client_take_response(sut, &payload);
EXPECT_THAT(memoryManager.getMemPoolInfo(0).m_usedChunks, Eq(1U));

IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { iox_client_release_response(nullptr, payload); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { iox_client_release_response(sut, nullptr); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE([&] { iox_client_release_response(nullptr, payload); }, iox::er::ENFORCE_VIOLATION);
IOX_EXPECT_FATAL_FAILURE([&] { iox_client_release_response(sut, nullptr); }, iox::er::ENFORCE_VIOLATION);

iox_client_release_response(sut, payload);
iox_client_deinit(sut);
Expand All @@ -313,22 +297,19 @@ TEST_F(iox_client_test, ClientReleasingResponseWithNullptrFails)
TEST_F(iox_client_test, ReleasingQueuedResponsesWithNullptrFails)
{
::testing::Test::RecordProperty("TEST_ID", "0d36d962-96af-4b82-a19c-4d4dc34f8c37");
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { iox_client_release_queued_responses(nullptr); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE([&] { iox_client_release_queued_responses(nullptr); }, iox::er::ENFORCE_VIOLATION);
}

TEST_F(iox_client_test, CheckClientHasResponseWithNullptrFails)
{
::testing::Test::RecordProperty("TEST_ID", "e2b81347-ce89-4d24-bd18-1cbdd716940e");
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { iox_client_has_responses(nullptr); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE([&] { iox_client_has_responses(nullptr); }, iox::er::ENFORCE_VIOLATION);
}

TEST_F(iox_client_test, CheckClientHasMissedResponseWithNullptrFails)
{
::testing::Test::RecordProperty("TEST_ID", "516b27af-5f78-4988-9886-726c414b6b31");
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { iox_client_has_missed_responses(nullptr); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
IOX_EXPECT_FATAL_FAILURE([&] { iox_client_has_missed_responses(nullptr); }, iox::er::ENFORCE_VIOLATION);
}

TEST_F(iox_client_test, InitializedOptionsAreToCPPDefaults)
Expand Down
Loading

0 comments on commit 9e2e619

Please sign in to comment.