Add test for case loading
This commit is contained in:
		
							parent
							
								
									640f12b3c7
								
							
						
					
					
						commit
						b1090d6e27
					
				@ -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)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										18
									
								
								test/test_caseloading.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								test/test_caseloading.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
			
		||||
#include <catch2/catch.hpp>
 | 
			
		||||
 | 
			
		||||
#include <QStringList>
 | 
			
		||||
 | 
			
		||||
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);
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user