From b1090d6e271ae2b04854462c242ef2ce87d74822 Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Mon, 4 Jan 2021 20:08:27 -0600 Subject: [PATCH] Add test for case loading --- test/CMakeLists.txt | 2 +- test/test_caseloading.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 test/test_caseloading.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ea163c1..3dd51c7 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,6 @@ find_package(Qt5 COMPONENTS Core REQUIRED) find_package(Catch2 REQUIRED) -add_executable(test test_aopacket.cpp ../include/aopacket.h ../src/aopacket.cpp) +add_executable(test test_aopacket.cpp test_caseloading.cpp ../include/aopacket.h ../src/aopacket.cpp) target_include_directories(test PRIVATE ../include) target_link_libraries(test PRIVATE Qt5::Core Catch2::Catch2) diff --git a/test/test_caseloading.cpp b/test/test_caseloading.cpp new file mode 100644 index 0000000..5df2782 --- /dev/null +++ b/test/test_caseloading.cpp @@ -0,0 +1,18 @@ +#include + +#include + +TEST_CASE("Sort case evidence numerically", "[case]") { + // Parameters + QStringList case_evidence = {"1", "10", "11", "2", "3", "4", "5", "6", "7", "8", "9"}; + QStringList case_evidence_sorted = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"}; + + // Sort + std::sort(case_evidence.begin(), case_evidence.end(), + [] (const QString &a, const QString &b) { + return a.toInt() < b.toInt(); + }); + + // Test + REQUIRE(case_evidence == case_evidence_sorted); +}