aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Oesch <lukasoesch20@gmail.com>2026-03-28 17:37:17 +0100
committerLukas Oesch <lukasoesch20@gmail.com>2026-03-28 17:37:17 +0100
commitddfa0cd69ec06b2ccaae36cb8dd676a324742b9c (patch)
tree5b45378ca9321d4a3eafc5b44f677c8d9726b776
parent09300635a916b67c027f8b6c1823db944f578669 (diff)
downloadteachos-ddfa0cd69ec06b2ccaae36cb8dd676a324742b9c.tar.xz
teachos-ddfa0cd69ec06b2ccaae36cb8dd676a324742b9c.zip
Revert "string tests"
This reverts commit 1f0d290bc303ac8f039963c4eb6421536d36827c.
-rw-r--r--libs/kstd/tests/src/string.cpp84
1 files changed, 35 insertions, 49 deletions
diff --git a/libs/kstd/tests/src/string.cpp b/libs/kstd/tests/src/string.cpp
index a94f0f6..43e9a6b 100644
--- a/libs/kstd/tests/src/string.cpp
+++ b/libs/kstd/tests/src/string.cpp
@@ -386,74 +386,60 @@ SCENARIO("String iteration", "[string]")
REQUIRE(str.back() == 'b');
}
}
+ }
+
+ GIVEN("A const string")
+ {
+ auto const str = kstd::string{"Blub"};
- GIVEN("A non-empty string")
+ WHEN("iterating over the characters of the string as string_view using a range-based for loop")
{
- auto str = kstd::string{"Hello"};
+ kstd::string result;
+
+ for (auto ch : str.view())
+ {
+ result.push_back(ch);
+ }
- WHEN("using const end()")
+ THEN("the iterated characters are the same as the characters in the string")
{
- auto it = str.end(); // calls const end()
- THEN("it points past the last character")
- {
- REQUIRE(*std::prev(it) == 'o');
- REQUIRE(std::distance(str.begin(), it) == str.size());
- }
+ REQUIRE(result == str.view());
}
}
- GIVEN("A const string")
+ WHEN("using front and back to access the first and last characters of the string")
{
- auto const str = kstd::string{"Blub"};
-
- WHEN("iterating over the characters of the string as string_view using a range-based for loop")
+ THEN("front returns the first character of the string")
{
- kstd::string result;
-
- for (auto ch : str.view())
- {
- result.push_back(ch);
- }
-
- THEN("the iterated characters are the same as the characters in the string")
- {
- REQUIRE(result == str.view());
- }
+ REQUIRE(str.front() == 'B');
}
- WHEN("using front and back to access the first and last characters of the string")
+ THEN("back returns the last character of the string")
{
- THEN("front returns the first character of the string")
- {
- REQUIRE(str.front() == 'B');
- }
-
- THEN("back returns the last character of the string")
- {
- REQUIRE(str.back() == 'b');
- }
+ REQUIRE(str.back() == 'b');
}
}
+ }
+
+ GIVEN("An empty string")
+ {
+ auto str = kstd::string{};
- GIVEN("An empty string")
+ WHEN("iterating over the characters of an empty string")
{
- auto str = kstd::string{};
+ kstd::string result;
- WHEN("iterating over the characters of an empty string")
+ for (auto ch : str.view())
{
- kstd::string result;
-
- for (auto ch : str.view())
- {
- result.push_back(ch);
- }
+ result.push_back(ch);
+ }
- THEN("no characters are iterated and the result is an empty string")
- {
- REQUIRE(result.empty());
- REQUIRE(result.size() == 0);
- REQUIRE(result.view() == std::string_view{});
- }
+ THEN("no characters are iterated and the result is an empty string")
+ {
+ REQUIRE(result.empty());
+ REQUIRE(result.size() == 0);
+ REQUIRE(result.view() == std::string_view{});
}
}
}
+}