From e8ce02d63f096147fc54824f0a45c23e3a3ced25 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Tue, 21 Apr 2026 14:44:01 +0200 Subject: libs: prepare for clang-tidy --- libs/kstd/tests/src/format.cpp | 2 -- libs/kstd/tests/src/observer_ptr.cpp | 3 ++- libs/kstd/tests/src/string.cpp | 8 ++++---- libs/kstd/tests/src/vector.cpp | 18 +++++++++--------- 4 files changed, 15 insertions(+), 16 deletions(-) (limited to 'libs/kstd/tests') diff --git a/libs/kstd/tests/src/format.cpp b/libs/kstd/tests/src/format.cpp index 73c8102..624779a 100644 --- a/libs/kstd/tests/src/format.cpp +++ b/libs/kstd/tests/src/format.cpp @@ -1,6 +1,4 @@ -#include #include -#include #include diff --git a/libs/kstd/tests/src/observer_ptr.cpp b/libs/kstd/tests/src/observer_ptr.cpp index 006ebde..0c94892 100644 --- a/libs/kstd/tests/src/observer_ptr.cpp +++ b/libs/kstd/tests/src/observer_ptr.cpp @@ -3,6 +3,7 @@ #include +#include #include #include #include @@ -313,7 +314,7 @@ SCENARIO("Observer pointer comparisons", "[observer_ptr]") { GIVEN("Observer pointers to elements of an array") { - int arr[] = {1, 2}; + auto arr = std::array{1, 2}; auto ptr1 = kstd::observer_ptr{&arr[0]}; auto ptr2 = kstd::observer_ptr{&arr[1]}; diff --git a/libs/kstd/tests/src/string.cpp b/libs/kstd/tests/src/string.cpp index 43e9a6b..53d7c9a 100644 --- a/libs/kstd/tests/src/string.cpp +++ b/libs/kstd/tests/src/string.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include SCENARIO("String initialization and construction", "[string]") @@ -59,7 +59,7 @@ SCENARIO("String initialization and construction", "[string]") THEN("the string is not empty and has the same size as the C-style string") { REQUIRE(!str.empty()); - REQUIRE(str.size() == strlen(c_str)); + REQUIRE(str.size() == std::strlen(c_str)); } THEN("the string contains the same characters as the C-style string") @@ -266,8 +266,8 @@ SCENARIO("String conversion and comparison", "[string]") { GIVEN("An unsigned integer") { - auto value1 = 12345u; - auto value2 = 0u; + constexpr auto value1 = 12345u; + constexpr auto value2 = 0u; WHEN("converting the unsigned integer to a string") { diff --git a/libs/kstd/tests/src/vector.cpp b/libs/kstd/tests/src/vector.cpp index 5faaaff..b826820 100644 --- a/libs/kstd/tests/src/vector.cpp +++ b/libs/kstd/tests/src/vector.cpp @@ -492,27 +492,27 @@ SCENARIO("Vector modifiers", "[vector]") WHEN("inserting an element") { - auto it = v.insert(v.cbegin(), 42); + auto it = v.insert(v.cbegin(), 40); THEN("the size and capacity increase and the element is inserted") { REQUIRE(v.size() == 1); REQUIRE(v.capacity() >= 1); - REQUIRE(v[0] == 42); + REQUIRE(v[0] == 40); REQUIRE(it == v.begin()); } } WHEN("inserting an lvalue element") { - auto const value = 42; + auto const value = 40; auto it = v.insert(v.cbegin(), value); THEN("the size and capacity increase and the element is inserted") { REQUIRE(v.size() == 1); REQUIRE(v.capacity() >= 1); - REQUIRE(v[0] == 42); + REQUIRE(v[0] == 40); REQUIRE(it == v.begin()); } } @@ -927,7 +927,7 @@ SCENARIO("Vector with non-default-constructible types", "[vector]") WHEN("using emplace_back") { auto v = kstd::vector{}; - v.emplace_back(42); + v.emplace_back(40); THEN("the element is added and the size and capacity increase") { @@ -965,7 +965,7 @@ SCENARIO("Vector modifier move semantics", "[vector]") GIVEN("An empty vector and a move tracker element") { auto v = kstd::vector{}; - auto tracker = kstd::tests::special_member_tracker{42}; + auto tracker = kstd::tests::special_member_tracker{40}; WHEN("push_back is called with the move tracker") { @@ -976,7 +976,7 @@ SCENARIO("Vector modifier move semantics", "[vector]") REQUIRE(v.size() == 1); REQUIRE(v.back().move_constructed_count == 1); REQUIRE(v.back().copy_constructed_count == 0); - REQUIRE(v.back().value == 42); + REQUIRE(v.back().value == 40); } THEN("the original tracker is left in a valid but unspecified state") @@ -992,14 +992,14 @@ SCENARIO("Vector modifier move semantics", "[vector]") WHEN("emplace_back is called with constructor arguments") { - v.emplace_back(42); + v.emplace_back(40); THEN("the element is constructed directly, without moves or copies") { REQUIRE(v.size() == 1); REQUIRE(v.back().move_constructed_count == 0); REQUIRE(v.back().copy_constructed_count == 0); - REQUIRE(v.back().value == 42); + REQUIRE(v.back().value == 40); } } } -- cgit v1.2.3