Skip to content
This repository was archived by the owner on May 1, 2026. It is now read-only.

Commit 8dc87d5

Browse files
committed
tests: add StringUtils test
1 parent 0a110ab commit 8dc87d5

4 files changed

Lines changed: 50 additions & 41 deletions

File tree

src/tests/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ IF(BUILD_TESTING)
22
FIND_PACKAGE(GTest REQUIRED)
33

44
ADD_EXECUTABLE(tests
5-
test_test.cpp
5+
utils/test_StringUtils.cpp
6+
test_main.cpp
67
)
8+
79
TARGET_LINK_LIBRARIES(tests PRIVATE
810
vACDM
911
GTest::gtest_main

src/tests/test_main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <gtest/gtest.h>
2+
3+
int main(int argc, char **argv) {
4+
::testing::InitGoogleTest(&argc, argv);
5+
return RUN_ALL_TESTS();
6+
}

src/tests/test_test.cpp

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include <gtest/gtest.h>
2+
3+
#include "utils/String.h"
4+
5+
using namespace vacdm::utils;
6+
7+
namespace utils::tests {
8+
TEST(StringUtilTest, Test_findIcao_base) {
9+
// Test case: only ICAO code
10+
EXPECT_EQ(String::findIcao("EDDK"), "EDDK");
11+
EXPECT_EQ(String::findIcao("EDDF"), "EDDF");
12+
13+
// Test case: ICAO code not in uppercase
14+
EXPECT_EQ(String::findIcao("eddk"), "");
15+
16+
// Test case: input is too short
17+
EXPECT_EQ(String::findIcao("JFK"), "");
18+
19+
// Test case: no ICAO code in input
20+
EXPECT_EQ(String::findIcao("This is a test"), "");
21+
22+
// Test case: empty string
23+
EXPECT_EQ(String::findIcao(""), "");
24+
25+
// Test case: spaces before and after words
26+
EXPECT_EQ(String::findIcao(" EDDK "), "EDDK");
27+
EXPECT_EQ(String::findIcao(" KLAX "), "KLAX");
28+
}
29+
30+
TEST(StringUtilTest, Test_findIcao_operators) {
31+
/* tests the findIcao function based on airport names defined inside individual vACDM operators EuroScope packages*/
32+
33+
// most only use ICAOs
34+
EXPECT_EQ(String::findIcao("EDDK"), "EDDK");
35+
EXPECT_EQ(String::findIcao("LPPT"), "LPPT");
36+
37+
// some additionally include names
38+
EXPECT_EQ(String::findIcao("EGLL London Heathrow"), "EGLL");
39+
EXPECT_EQ(String::findIcao("EGKK London Gatwick"), "EGKK");
40+
}
41+
} // namespace utils::tests

0 commit comments

Comments
 (0)