diff --git a/src/unittest_logging.cpp b/src/unittest_logging.cpp index 072a81b1..4cf823c0 100644 --- a/src/unittest_logging.cpp +++ b/src/unittest_logging.cpp @@ -1,4 +1,4 @@ -/* Copyright 2019, 2023 National Research Foundation (SARAO) +/* Copyright 2019, 2023-2024 National Research Foundation (SARAO) * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free @@ -170,7 +170,7 @@ BOOST_AUTO_TEST_CASE(throw_errno_zero) BOOST_FIXTURE_TEST_CASE(default_logger, capture_stderr) { spead2::log_info("A test message"); - BOOST_CHECK_EQUAL(out.str(), "spead2: info: A test message\n"); + BOOST_TEST(out.str() == "spead2: info: A test message\n"); } BOOST_AUTO_TEST_SUITE_END() // logging diff --git a/src/unittest_memory_allocator.cpp b/src/unittest_memory_allocator.cpp index 8fa64605..9c971920 100644 --- a/src/unittest_memory_allocator.cpp +++ b/src/unittest_memory_allocator.cpp @@ -1,4 +1,4 @@ -/* Copyright 2016, 2019, 2021, 2023 National Research Foundation (SARAO) +/* Copyright 2016, 2019, 2021, 2023-2024 National Research Foundation (SARAO) * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free @@ -94,7 +94,7 @@ BOOST_AUTO_TEST_CASE(legacy) BOOST_TEST(allocator->deleted.empty()); std::uint8_t *raw = ptr.get(); ptr.reset(); - BOOST_TEST(allocator->deleted.size() == 1); + BOOST_TEST(allocator->deleted.size() == 1U); BOOST_TEST(allocator->deleted[0].first == raw); BOOST_TEST(allocator->deleted[0].second == nullptr); @@ -102,7 +102,7 @@ BOOST_AUTO_TEST_CASE(legacy) ptr = allocator->allocate(234, &raw); raw = ptr.get(); ptr.reset(); - BOOST_TEST(allocator->deleted.size() == 2); + BOOST_TEST(allocator->deleted.size() == 2U); BOOST_TEST(allocator->deleted[1].first == raw); BOOST_TEST(allocator->deleted[1].second == &raw); } diff --git a/src/unittest_memory_pool.cpp b/src/unittest_memory_pool.cpp index f324b1a6..c8c9fd9b 100644 --- a/src/unittest_memory_pool.cpp +++ b/src/unittest_memory_pool.cpp @@ -1,4 +1,4 @@ -/* Copyright 2016, 2017, 2019, 2021, 2023 National Research Foundation (SARAO) +/* Copyright 2016, 2017, 2019, 2021, 2023-2024 National Research Foundation (SARAO) * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free @@ -81,7 +81,7 @@ class mock_allocator : public spead2::memory_allocator void operator()(std::uint8_t *ptr) const { - BOOST_CHECK_EQUAL(ptr + 1, next_ptr); + BOOST_TEST(ptr + 1 == next_ptr); allocator->records.push_back(record{false, 0, ptr}); allocator->saved.emplace_back(ptr); } @@ -164,23 +164,23 @@ BOOST_AUTO_TEST_CASE(memory_pool_pass_deleter) p5.reset(); // Check results - BOOST_REQUIRE_EQUAL(allocator->records.size(), 8); - BOOST_CHECK_EQUAL(allocator->records[0].allocate, true); - BOOST_CHECK_EQUAL(allocator->records[0].size, 2048); - BOOST_CHECK_EQUAL(allocator->records[1].allocate, true); - BOOST_CHECK_EQUAL(allocator->records[1].size, 2048); - BOOST_CHECK_EQUAL(allocator->records[2].allocate, true); - BOOST_CHECK_EQUAL(allocator->records[2].size, 2048); - BOOST_CHECK_EQUAL(allocator->records[3].allocate, false); - BOOST_CHECK_EQUAL(allocator->records[3].ptr, allocator->records[2].ptr); - BOOST_CHECK_EQUAL(allocator->records[4].allocate, true); - BOOST_CHECK_EQUAL(allocator->records[4].size, 2049); - BOOST_CHECK_EQUAL(allocator->records[5].allocate, false); - BOOST_CHECK_EQUAL(allocator->records[5].ptr, allocator->records[0].ptr); - BOOST_CHECK_EQUAL(allocator->records[6].allocate, false); - BOOST_CHECK_EQUAL(allocator->records[6].ptr, allocator->records[1].ptr); - BOOST_CHECK_EQUAL(allocator->records[7].allocate, false); - BOOST_CHECK_EQUAL(allocator->records[7].ptr, allocator->records[4].ptr); + BOOST_TEST_REQUIRE(allocator->records.size() == 8U); + BOOST_TEST(allocator->records[0].allocate); + BOOST_TEST(allocator->records[0].size == 2048U); + BOOST_TEST(allocator->records[1].allocate); + BOOST_TEST(allocator->records[1].size == 2048U); + BOOST_TEST(allocator->records[2].allocate); + BOOST_TEST(allocator->records[2].size == 2048U); + BOOST_TEST(!allocator->records[3].allocate); + BOOST_TEST(allocator->records[3].ptr == allocator->records[2].ptr); + BOOST_TEST(allocator->records[4].allocate); + BOOST_TEST(allocator->records[4].size == 2049U); + BOOST_TEST(!allocator->records[5].allocate); + BOOST_TEST(allocator->records[5].ptr == allocator->records[0].ptr); + BOOST_TEST(!allocator->records[6].allocate); + BOOST_TEST(allocator->records[6].ptr == allocator->records[1].ptr); + BOOST_TEST(!allocator->records[7].allocate); + BOOST_TEST(allocator->records[7].ptr == allocator->records[4].ptr); } // Check that a warning is issued when the memory pool becomes empty, if and @@ -188,19 +188,19 @@ BOOST_AUTO_TEST_CASE(memory_pool_pass_deleter) BOOST_FIXTURE_TEST_CASE(memory_pool_warn_on_empty, logger_fixture) { auto pool = std::make_shared(1024, 2048, 1, 1); - BOOST_CHECK_EQUAL(pool->get_warn_on_empty(), true); + BOOST_TEST(pool->get_warn_on_empty() == true); auto ptr1 = pool->allocate(1024, nullptr); // Wasn't empty, should be no messages - BOOST_CHECK_EQUAL(messages[spead2::log_level::warning].size(), 0); + BOOST_TEST(messages[spead2::log_level::warning].size() == 0U); auto ptr2 = pool->allocate(1024, nullptr); // Now was empty, should be a warning - BOOST_CHECK_EQUAL(messages[spead2::log_level::warning].size(), 1); + BOOST_TEST(messages[spead2::log_level::warning].size() == 1U); pool->set_warn_on_empty(false); - BOOST_CHECK_EQUAL(pool->get_warn_on_empty(), false); + BOOST_TEST(pool->get_warn_on_empty() == false); auto ptr3 = pool->allocate(1024, nullptr); // Empty again, but should be no new warning - BOOST_CHECK_EQUAL(messages[spead2::log_level::warning].size(), 1); + BOOST_TEST(messages[spead2::log_level::warning].size() == 1U); } BOOST_AUTO_TEST_SUITE_END() // memory_pool diff --git a/src/unittest_raw_packet.cpp b/src/unittest_raw_packet.cpp index df593529..b94293ce 100644 --- a/src/unittest_raw_packet.cpp +++ b/src/unittest_raw_packet.cpp @@ -1,4 +1,4 @@ -/* Copyright 2019, 2023 National Research Foundation (SARAO) +/* Copyright 2019, 2023-2024 National Research Foundation (SARAO) * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free @@ -111,18 +111,18 @@ BOOST_AUTO_TEST_CASE(packet_buffer_construct) std::uint8_t data[2]; packet_buffer a; packet_buffer b(data, 2); - BOOST_CHECK_EQUAL(a.data(), (std::uint8_t *) nullptr); - BOOST_CHECK_EQUAL(a.size(), 0); - BOOST_CHECK_EQUAL(b.data(), data); - BOOST_CHECK_EQUAL(b.size(), 2); + BOOST_TEST(a.data() == (std::uint8_t *) nullptr); + BOOST_TEST(a.size() == 0U); + BOOST_TEST(b.data() == data); + BOOST_TEST(b.size() == 2U); } BOOST_AUTO_TEST_CASE(parse_ethernet_frame) { ethernet_frame frame(data.data(), data.size()); - BOOST_CHECK(frame.source_mac() == source_mac); - BOOST_CHECK(frame.destination_mac() == destination_mac); - BOOST_CHECK_EQUAL(frame.ethertype(), ipv4_packet::ethertype); + BOOST_TEST(frame.source_mac() == source_mac); + BOOST_TEST(frame.destination_mac() == destination_mac); + BOOST_TEST(frame.ethertype() == ipv4_packet::ethertype); } // Just to get full test coverage @@ -136,17 +136,17 @@ BOOST_AUTO_TEST_CASE(parse_ipv4) ethernet_frame frame(data.data(), data.size()); ipv4_packet ipv4 = frame.payload_ipv4(); - BOOST_CHECK_EQUAL(ipv4.version_ihl(), 0x45); // version 4, header length 20 - BOOST_CHECK_EQUAL(ipv4.version(), 4); - BOOST_CHECK_EQUAL(ipv4.dscp_ecn(), 0); - BOOST_CHECK_EQUAL(ipv4.total_length(), 40); - BOOST_CHECK_EQUAL(ipv4.identification(), ipv4_identification); - BOOST_CHECK_EQUAL(ipv4.flags_frag_off(), ipv4_packet::flag_do_not_fragment); - BOOST_CHECK_EQUAL(ipv4.ttl(), 1); - BOOST_CHECK_EQUAL(ipv4.protocol(), udp_packet::protocol); - BOOST_CHECK_EQUAL(ipv4.checksum(), ipv4_checksum); - BOOST_CHECK_EQUAL(ipv4.source_address(), source_address); - BOOST_CHECK_EQUAL(ipv4.destination_address(), destination_address); + BOOST_TEST(ipv4.version_ihl() == 0x45); // version 4, header length 20 + BOOST_TEST(ipv4.version() == 4); + BOOST_TEST(ipv4.dscp_ecn() == 0); + BOOST_TEST(ipv4.total_length() == 40); + BOOST_TEST(ipv4.identification() == ipv4_identification); + BOOST_TEST(ipv4.flags_frag_off() == ipv4_packet::flag_do_not_fragment); + BOOST_TEST(ipv4.ttl() == 1); + BOOST_TEST(ipv4.protocol() == udp_packet::protocol); + BOOST_TEST(ipv4.checksum() == ipv4_checksum); + BOOST_TEST(ipv4.source_address() == source_address); + BOOST_TEST(ipv4.destination_address() == destination_address); } BOOST_AUTO_TEST_CASE(parse_udp) @@ -155,11 +155,11 @@ BOOST_AUTO_TEST_CASE(parse_udp) ipv4_packet ipv4 = frame.payload_ipv4(); udp_packet udp = ipv4.payload_udp(); - BOOST_CHECK_EQUAL(udp.source_port(), source_port); - BOOST_CHECK_EQUAL(udp.destination_port(), destination_port); - BOOST_CHECK_EQUAL(udp.length(), 20); - BOOST_CHECK_EQUAL(udp.checksum(), udp_checksum); - BOOST_CHECK_EQUAL(buffer_to_string(udp.payload()), sample_payload); + BOOST_TEST(udp.source_port() == source_port); + BOOST_TEST(udp.destination_port() == destination_port); + BOOST_TEST(udp.length() == 20); + BOOST_TEST(udp.checksum() == udp_checksum); + BOOST_TEST(buffer_to_string(udp.payload()) == sample_payload); } BOOST_AUTO_TEST_CASE(ethernet_too_small) @@ -213,13 +213,13 @@ BOOST_AUTO_TEST_CASE(udp_bad_length) BOOST_AUTO_TEST_CASE(udp_from_ethernet) { boost::asio::mutable_buffer payload = spead2::udp_from_ethernet(data.data(), data.size()); - BOOST_CHECK_EQUAL(buffer_to_string(payload), sample_payload); + BOOST_TEST(buffer_to_string(payload) == sample_payload); } BOOST_AUTO_TEST_CASE(udp_from_linux_sll) { boost::asio::mutable_buffer payload = spead2::udp_from_linux_sll(sll_data.data(), sll_data.size()); - BOOST_CHECK_EQUAL(buffer_to_string(payload), sample_payload); + BOOST_TEST(buffer_to_string(payload) == sample_payload); } BOOST_AUTO_TEST_CASE(udp_from_ethernet_not_ipv4) diff --git a/src/unittest_recv_custom_memcpy.cpp b/src/unittest_recv_custom_memcpy.cpp index 7d9d9086..1eafa2bf 100644 --- a/src/unittest_recv_custom_memcpy.cpp +++ b/src/unittest_recv_custom_memcpy.cpp @@ -1,4 +1,4 @@ -/* Copyright 2019-2020, 2023 National Research Foundation (SARAO) +/* Copyright 2019-2020, 2023-2024 National Research Foundation (SARAO) * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free @@ -89,12 +89,12 @@ BOOST_AUTO_TEST_CASE(test_reverse) { if (item.id == 0x1000) { - BOOST_CHECK(!found); + BOOST_TEST(!found); BOOST_CHECK_EQUAL_COLLECTIONS(data.rbegin(), data.rend(), item.ptr, item.ptr + item.length); found = true; } } - BOOST_CHECK(found); + BOOST_TEST(found); } BOOST_AUTO_TEST_SUITE_END() // custom_memcpy diff --git a/src/unittest_recv_live_heap.cpp b/src/unittest_recv_live_heap.cpp index daf15eb5..fcd05da7 100644 --- a/src/unittest_recv_live_heap.cpp +++ b/src/unittest_recv_live_heap.cpp @@ -1,4 +1,4 @@ -/* Copyright 2016, 2018, 2023 National Research Foundation (SARAO) +/* Copyright 2016, 2018, 2023-2024 National Research Foundation (SARAO) * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free @@ -110,55 +110,55 @@ BOOST_AUTO_TEST_CASE(payload_ranges) using spead2::recv::live_heap; live_heap heap(dummy_packet(1), 0); - BOOST_CHECK(heap.add_payload_range(100, 200)); + BOOST_TEST(heap.add_payload_range(100, 200)); std::pair expected1[] = {{100, 200}}; BOOST_CHECK_EQUAL_COLLECTIONS(heap.payload_ranges.begin(), heap.payload_ranges.end(), std::begin(expected1), std::end(expected1)); // Range prior to all previous values - BOOST_CHECK(heap.add_payload_range(30, 40)); + BOOST_TEST(heap.add_payload_range(30, 40)); std::pair expected2[] = {{30, 40}, {100, 200}}; BOOST_CHECK_EQUAL_COLLECTIONS(heap.payload_ranges.begin(), heap.payload_ranges.end(), std::begin(expected2), std::end(expected2)); // Range after all existing values - BOOST_CHECK(heap.add_payload_range(300, 350)); + BOOST_TEST(heap.add_payload_range(300, 350)); std::pair expected3[] = {{30, 40}, {100, 200}, {300, 350}}; BOOST_CHECK_EQUAL_COLLECTIONS(heap.payload_ranges.begin(), heap.payload_ranges.end(), std::begin(expected3), std::end(expected3)); // Insert at start, merge right - BOOST_CHECK(heap.add_payload_range(25, 30)); + BOOST_TEST(heap.add_payload_range(25, 30)); std::pair expected4[] = {{25, 40}, {100, 200}, {300, 350}}; BOOST_CHECK_EQUAL_COLLECTIONS(heap.payload_ranges.begin(), heap.payload_ranges.end(), std::begin(expected4), std::end(expected4)); // Insert at end, merge left - BOOST_CHECK(heap.add_payload_range(350, 360)); + BOOST_TEST(heap.add_payload_range(350, 360)); std::pair expected5[] = {{25, 40}, {100, 200}, {300, 360}}; BOOST_CHECK_EQUAL_COLLECTIONS(heap.payload_ranges.begin(), heap.payload_ranges.end(), std::begin(expected5), std::end(expected5)); // Insert in middle, merge left - BOOST_CHECK(heap.add_payload_range(40, 50)); + BOOST_TEST(heap.add_payload_range(40, 50)); std::pair expected6[] = {{25, 50}, {100, 200}, {300, 360}}; BOOST_CHECK_EQUAL_COLLECTIONS(heap.payload_ranges.begin(), heap.payload_ranges.end(), std::begin(expected6), std::end(expected6)); // Insert in middle, merge right - BOOST_CHECK(heap.add_payload_range(80, 100)); + BOOST_TEST(heap.add_payload_range(80, 100)); std::pair expected7[] = {{25, 50}, {80, 200}, {300, 360}}; BOOST_CHECK_EQUAL_COLLECTIONS(heap.payload_ranges.begin(), heap.payload_ranges.end(), std::begin(expected7), std::end(expected7)); // Insert in middle, no merge - BOOST_CHECK(heap.add_payload_range(60, 70)); + BOOST_TEST(heap.add_payload_range(60, 70)); std::pair expected8[] = {{25, 50}, {60, 70}, {80, 200}, {300, 360}}; BOOST_CHECK_EQUAL_COLLECTIONS(heap.payload_ranges.begin(), heap.payload_ranges.end(), std::begin(expected8), std::end(expected8)); // Insert in middle, merge both sides - BOOST_CHECK(heap.add_payload_range(50, 60)); + BOOST_TEST(heap.add_payload_range(50, 60)); std::pair expected9[] = {{25, 70}, {80, 200}, {300, 360}}; BOOST_CHECK_EQUAL_COLLECTIONS(heap.payload_ranges.begin(), heap.payload_ranges.end(), std::begin(expected9), std::end(expected9)); // Duplicates of various sorts - BOOST_CHECK(!heap.add_payload_range(40, 50)); - BOOST_CHECK(!heap.add_payload_range(25, 30)); - BOOST_CHECK(!heap.add_payload_range(90, 200)); - BOOST_CHECK(!heap.add_payload_range(300, 360)); + BOOST_TEST(!heap.add_payload_range(40, 50)); + BOOST_TEST(!heap.add_payload_range(25, 30)); + BOOST_TEST(!heap.add_payload_range(90, 200)); + BOOST_TEST(!heap.add_payload_range(300, 360)); } BOOST_AUTO_TEST_SUITE_END() // live_heap diff --git a/src/unittest_recv_stream_stats.cpp b/src/unittest_recv_stream_stats.cpp index 085375a1..48118ecc 100644 --- a/src/unittest_recv_stream_stats.cpp +++ b/src/unittest_recv_stream_stats.cpp @@ -1,4 +1,4 @@ -/* Copyright 2021, 2023 National Research Foundation (SARAO) +/* Copyright 2021, 2023-2024 National Research Foundation (SARAO) * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free @@ -112,32 +112,32 @@ BOOST_AUTO_TEST_CASE(test_references) stats["single_packet_heaps"] = 7; stats["search_dist"] = 8; stats["worker_blocked"] = 9; - BOOST_TEST(stats.heaps == 1); - BOOST_TEST(stats.incomplete_heaps_evicted == 2); - BOOST_TEST(stats.incomplete_heaps_flushed == 3); - BOOST_TEST(stats.packets == 4); - BOOST_TEST(stats.batches == 5); - BOOST_TEST(stats.max_batch == 6); - BOOST_TEST(stats.single_packet_heaps == 7); - BOOST_TEST(stats.search_dist == 8); - BOOST_TEST(stats.worker_blocked == 9); + BOOST_TEST(stats.heaps == 1U); + BOOST_TEST(stats.incomplete_heaps_evicted == 2U); + BOOST_TEST(stats.incomplete_heaps_flushed == 3U); + BOOST_TEST(stats.packets == 4U); + BOOST_TEST(stats.batches == 5U); + BOOST_TEST(stats.max_batch == 6U); + BOOST_TEST(stats.single_packet_heaps == 7U); + BOOST_TEST(stats.search_dist == 8U); + BOOST_TEST(stats.worker_blocked == 9U); }; BOOST_AUTO_TEST_CASE(test_index) { spead2::recv::stream_stats stats; stats["heaps"] = 123; - BOOST_TEST(stats["heaps"] == 123); - BOOST_TEST(stats.at("heaps") == 123); - BOOST_TEST(stats[spead2::recv::stream_stat_indices::heaps] == 123); + BOOST_TEST(stats["heaps"] == 123U); + BOOST_TEST(stats.at("heaps") == 123U); + BOOST_TEST(stats[spead2::recv::stream_stat_indices::heaps] == 123U); BOOST_CHECK_THROW(stats["missing"], std::out_of_range); BOOST_CHECK_THROW(stats.at("missing"), std::out_of_range); BOOST_CHECK_THROW(stats.at(100000), std::out_of_range); const spead2::recv::stream_stats &stats_const = stats; - BOOST_TEST(stats_const["heaps"] == 123); - BOOST_TEST(stats_const.at("heaps") == 123); - BOOST_TEST(stats_const[spead2::recv::stream_stat_indices::heaps] == 123); + BOOST_TEST(stats_const["heaps"] == 123U); + BOOST_TEST(stats_const.at("heaps") == 123U); + BOOST_TEST(stats_const[spead2::recv::stream_stat_indices::heaps] == 123U); BOOST_CHECK_THROW(stats_const["missing"], std::out_of_range); BOOST_CHECK_THROW(stats_const.at("missing"), std::out_of_range); BOOST_CHECK_THROW(stats_const.at(100000), std::out_of_range); @@ -150,24 +150,24 @@ BOOST_AUTO_TEST_CASE(test_find) auto it = stats.find("heaps"); BOOST_REQUIRE(it != stats.end()); BOOST_TEST(it->first == "heaps"); - BOOST_TEST(it->second == 123); + BOOST_TEST(it->second == 123U); it = stats.find("missing"); - BOOST_CHECK(it == stats.end()); + BOOST_TEST((it == stats.end())); const spead2::recv::stream_stats &stats_const = stats; auto it_const = stats_const.find("heaps"); BOOST_REQUIRE(it_const != stats_const.end()); BOOST_TEST(it_const->first == "heaps"); - BOOST_TEST(it_const->second == 123); + BOOST_TEST(it_const->second == 123U); it_const = stats_const.find("missing"); - BOOST_CHECK(it_const == stats_const.end()); + BOOST_TEST((it_const == stats_const.end())); } BOOST_AUTO_TEST_CASE(test_count) { spead2::recv::stream_stats stats; - BOOST_TEST(stats.count("heaps") == 1); - BOOST_TEST(stats.count("missing") == 0); + BOOST_TEST(stats.count("heaps") == 1U); + BOOST_TEST(stats.count("missing") == 0U); } BOOST_AUTO_TEST_CASE(test_copy) @@ -177,7 +177,7 @@ BOOST_AUTO_TEST_CASE(test_copy) spead2::recv::stream_stats stats2(stats1); BOOST_TEST(&stats2.packets == &stats2["packets"]); stats1.packets = 20; - BOOST_TEST(stats2.packets == 10); + BOOST_TEST(stats2.packets == 10U); } BOOST_AUTO_TEST_CASE(test_copy_assign) @@ -185,7 +185,7 @@ BOOST_AUTO_TEST_CASE(test_copy_assign) spead2::recv::stream_stats stats1, stats2; stats1.packets = 10; stats2 = stats1; - BOOST_TEST(stats2.packets == 10); + BOOST_TEST(stats2.packets == 10U); BOOST_TEST(&stats2.packets == &stats2["packets"]); } @@ -195,7 +195,7 @@ BOOST_AUTO_TEST_CASE(test_move) stats1.packets = 10; spead2::recv::stream_stats stats2(std::move(stats1)); BOOST_TEST(&stats2.packets == &stats2["packets"]); - BOOST_TEST(stats2.packets == 10); + BOOST_TEST(stats2.packets == 10U); } BOOST_AUTO_TEST_CASE(test_move_assign) @@ -203,7 +203,7 @@ BOOST_AUTO_TEST_CASE(test_move_assign) spead2::recv::stream_stats stats1, stats2; stats1.packets = 10; stats2 = std::move(stats1); - BOOST_TEST(stats2.packets == 10); + BOOST_TEST(stats2.packets == 10U); BOOST_TEST(&stats2.packets == &stats2["packets"]); } diff --git a/src/unittest_semaphore.cpp b/src/unittest_semaphore.cpp index 2934b83a..cdae1755 100644 --- a/src/unittest_semaphore.cpp +++ b/src/unittest_semaphore.cpp @@ -1,4 +1,4 @@ -/* Copyright 2019, 2023 National Research Foundation (SARAO) +/* Copyright 2019, 2023-2024 National Research Foundation (SARAO) * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free @@ -92,16 +92,16 @@ static int semaphore_get_value(T &sem) int result; while ((result = semaphore_try_get(sem)) == 0) value++; - BOOST_CHECK_EQUAL(result, -1); + BOOST_TEST(result == -1); return value; } BOOST_AUTO_TEST_CASE_TEMPLATE(single_thread, T, semaphore_types) { T sem(2); - BOOST_CHECK_EQUAL(semaphore_get_value(sem), 2); + BOOST_TEST(semaphore_get_value(sem) == 2); sem.put(); - BOOST_CHECK_EQUAL(semaphore_get_value(sem), 1); + BOOST_TEST(semaphore_get_value(sem) == 1); } BOOST_AUTO_TEST_CASE_TEMPLATE(multi_thread, T, semaphore_types) @@ -130,7 +130,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(multi_thread, T, semaphore_types) sum += x[i]; } future.get(); - BOOST_CHECK_EQUAL(sum, N * (N - 1) / 2); + BOOST_TEST(sum == N * (N - 1) / 2); } BOOST_AUTO_TEST_CASE_TEMPLATE(move_assign, T, semaphore_fd_types) @@ -139,8 +139,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(move_assign, T, semaphore_fd_types) int orig_fd = sem1.get_fd(); T sem2; sem2 = std::move(sem1); - BOOST_CHECK_EQUAL(sem2.get_fd(), orig_fd); - BOOST_CHECK_EQUAL(semaphore_get_value(sem2), 2); + BOOST_TEST(sem2.get_fd() == orig_fd); + BOOST_TEST(semaphore_get_value(sem2) == 2); } BOOST_AUTO_TEST_CASE_TEMPLATE(move_construct, T, semaphore_fd_types) @@ -148,8 +148,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(move_construct, T, semaphore_fd_types) T sem1(2); int orig_fd = sem1.get_fd(); T sem2(std::move(sem1)); - BOOST_CHECK_EQUAL(sem2.get_fd(), orig_fd); - BOOST_CHECK_EQUAL(semaphore_get_value(sem2), 2); + BOOST_TEST(sem2.get_fd() == orig_fd); + BOOST_TEST(semaphore_get_value(sem2) == 2); } BOOST_AUTO_TEST_CASE_TEMPLATE(poll_fd, T, semaphore_fd_types) @@ -160,10 +160,10 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(poll_fd, T, semaphore_fd_types) fds[0].fd = sem.get_fd(); fds[0].events = POLLIN; int result = poll_restart(fds, 1, 0); - BOOST_CHECK_EQUAL(result, 1); + BOOST_TEST(result == 1); semaphore_get(sem); result = poll_restart(fds, 1, 1); - BOOST_CHECK_EQUAL(result, 0); + BOOST_TEST(result == 0); } BOOST_AUTO_TEST_SUITE_END() // semaphore diff --git a/src/unittest_send_completion.cpp b/src/unittest_send_completion.cpp index 17112191..dd035b8c 100644 --- a/src/unittest_send_completion.cpp +++ b/src/unittest_send_completion.cpp @@ -73,8 +73,8 @@ BOOST_AUTO_TEST_CASE(async_send_heap_handler) std::promise promise; auto future = promise.get_future(); bool result = stream.async_send_heap(heap, promise_handler(promise)); - BOOST_CHECK_EQUAL(result, true); - BOOST_CHECK_EQUAL(future.get(), heap_size); + BOOST_TEST(result); + BOOST_TEST(future.get() == heap_size); } // Test async_send_heap with a generic token @@ -86,7 +86,7 @@ BOOST_AUTO_TEST_CASE(async_send_heap_token) spead2::send::heap heap; std::future future = stream.async_send_heap(heap, boost::asio::use_future); - BOOST_CHECK_EQUAL(future.get(), heap_size); + BOOST_TEST(future.get() == heap_size); } // Test async_send_heaps with a completion handler @@ -104,8 +104,8 @@ BOOST_AUTO_TEST_CASE(async_send_heaps_handler) promise_handler(promise), spead2::send::group_mode::SERIAL ); - BOOST_CHECK_EQUAL(result, true); - BOOST_CHECK_EQUAL(future.get(), heap_size * heaps.size()); + BOOST_TEST(result); + BOOST_TEST(future.get() == heap_size * heaps.size()); } // Test async_send_heaps with a completion token @@ -121,7 +121,7 @@ BOOST_AUTO_TEST_CASE(async_send_heaps_token) boost::asio::use_future, spead2::send::group_mode::SERIAL ); - BOOST_CHECK_EQUAL(future.get(), heap_size * heaps.size()); + BOOST_TEST(future.get() == heap_size * heaps.size()); } // Test async_send_heaps failure case with a completion handler @@ -139,7 +139,7 @@ BOOST_AUTO_TEST_CASE(async_send_heaps_failure_handler) promise_handler(promise), spead2::send::group_mode::SERIAL ); - BOOST_CHECK_EQUAL(result, false); + BOOST_TEST(!result); BOOST_CHECK_EXCEPTION(future.get(), boost::system::system_error, is_would_block); } @@ -164,7 +164,7 @@ BOOST_AUTO_TEST_CASE(async_send_heaps_failure_token) }, spead2::send::group_mode::SERIAL ); - BOOST_CHECK_EQUAL(result, false); + BOOST_TEST(!result); BOOST_CHECK_EXCEPTION(future.get(), boost::system::system_error, is_would_block); } diff --git a/src/unittest_send_heap.cpp b/src/unittest_send_heap.cpp index 10faf6ce..eb4663c3 100644 --- a/src/unittest_send_heap.cpp +++ b/src/unittest_send_heap.cpp @@ -1,4 +1,4 @@ -/* Copyright 2018, 2023 National Research Foundation (SARAO) +/* Copyright 2018, 2023-2024 National Research Foundation (SARAO) * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free @@ -42,16 +42,16 @@ BOOST_AUTO_TEST_CASE(get_item) item &item1 = h.get_item(handle1); const item &item2 = std::as_const(h).get_item(handle2); - BOOST_CHECK_EQUAL(item1.id, 0x1234); - BOOST_CHECK(item1.is_inline); - BOOST_CHECK_EQUAL(item1.data.immediate, 0xabc); + BOOST_TEST(item1.id == 0x1234); + BOOST_TEST(item1.is_inline); + BOOST_TEST(item1.data.immediate == 0xabc); item1.data.immediate = 0xabcd; // Check that updates are reflected - BOOST_CHECK_EQUAL(h.get_item(handle1).data.immediate, 0xabcd); + BOOST_TEST(h.get_item(handle1).data.immediate == 0xabcd); - BOOST_CHECK_EQUAL(item2.id, 0x2345); - BOOST_CHECK(!item2.is_inline); - BOOST_CHECK_EQUAL(item2.data.buffer.ptr, (const unsigned char *) &value2); + BOOST_TEST(item2.id == 0x2345); + BOOST_TEST(!item2.is_inline); + BOOST_TEST(item2.data.buffer.ptr == (const unsigned char *) &value2); } BOOST_AUTO_TEST_SUITE_END() // heap diff --git a/src/unittest_send_streambuf.cpp b/src/unittest_send_streambuf.cpp index cdc25d98..f9d9821d 100644 --- a/src/unittest_send_streambuf.cpp +++ b/src/unittest_send_streambuf.cpp @@ -1,4 +1,4 @@ -/* Copyright 2019-2020, 2023 National Research Foundation (SARAO) +/* Copyright 2019-2020, 2023-2024 National Research Foundation (SARAO) * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free @@ -66,8 +66,8 @@ BOOST_AUTO_TEST_CASE(send_fail) }; stream.async_send_heap(h, handler); auto [ec, bytes_transferred] = result_promise.get_future().get(); - BOOST_CHECK_EQUAL(ec, boost::asio::error::eof); - BOOST_CHECK_EQUAL(bytes_transferred, 20); + BOOST_TEST(ec == boost::asio::error::eof); + BOOST_TEST(bytes_transferred == 20U); } BOOST_AUTO_TEST_SUITE_END() // streambuf diff --git a/src/unittest_send_tcp.cpp b/src/unittest_send_tcp.cpp index cd308bdd..968bb08d 100644 --- a/src/unittest_send_tcp.cpp +++ b/src/unittest_send_tcp.cpp @@ -1,4 +1,4 @@ -/* Copyright 2020, 2023-2024 National Research Foundation (SARAO) +;/* Copyright 2020, 2023-2024 National Research Foundation (SARAO) * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free @@ -70,8 +70,8 @@ BOOST_AUTO_TEST_CASE(connect_fail) }; stream.async_send_heap(h, handler); stream.flush(); - BOOST_CHECK_EQUAL(connect_error, boost::asio::error::connection_refused); - BOOST_CHECK_EQUAL(heap_error, boost::asio::error::broken_pipe); + BOOST_TEST(connect_error == boost::asio::error::connection_refused); + BOOST_TEST(heap_error == boost::asio::error::broken_pipe); } BOOST_AUTO_TEST_SUITE_END() // tcp