-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add string::Indent. - Remove some old code from string.h Use C++17's library header <filesystem> for this kind of filename manipulations. - Freshen up: tolower, toupper and capitalize.
- Loading branch information
1 parent
dd99fe3
commit 0cd25cb
Showing
4 changed files
with
92 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) 2023 Pierre DEJOUE | ||
// This code is distributed under the terms of the MIT License | ||
#include <catch_amalgamated.hpp> | ||
|
||
#include <stdutils/string.h> | ||
|
||
#include <sstream> | ||
#include <string> | ||
|
||
TEST_CASE("strings tolower, toupper and capitalize", "[stdutils::string]") | ||
{ | ||
CHECK(stdutils::string::tolower("All Those MOMENTS") == "all those moments"); | ||
CHECK(stdutils::string::toupper("will be lost in time") == "WILL BE LOST IN TIME"); | ||
CHECK(stdutils::string::capitalize("like tears in rain.") == "Like tears in rain."); | ||
} | ||
|
||
TEST_CASE("Indentation", "[stdutils::string]") | ||
{ | ||
const stdutils::string::Indent indent(4); // My indentation is 4 spaces | ||
{ | ||
std::stringstream out; | ||
out << indent; // Output 1 indentation | ||
CHECK(out.str().size() == 4); | ||
} | ||
{ | ||
std::stringstream out; | ||
out << indent(2); // Output 2 indentations | ||
CHECK(out.str().size() == 8); | ||
} | ||
{ | ||
std::stringstream out; | ||
out << indent(0); // Output zero indentation | ||
CHECK(out.str().empty()); | ||
} | ||
} |