Moved objects into namespace Leonetienne

This commit is contained in:
Leonetienne 2022-05-17 00:03:39 +02:00
parent 954629f6bc
commit 7d9193e3ee
No known key found for this signature in database
GPG Key ID: C33879CD92E9708C
20 changed files with 294 additions and 228 deletions

View File

@ -1,6 +1,8 @@
#include <iostream>
#include <StringTools/StringTools.h>
using namespace Leonetienne::StringTools;
int main()
{
std::vector<std::string> foo =

View File

@ -3,8 +3,10 @@
#include <string>
/* Handy utensils to manipulate characters */
namespace Leonetienne::StringTools {
/* Handy utensils to manipulate characters */
class CharTools {
public:
//! Checks whether or not `c` is a vowel. You can define custom vowel characters.
@ -32,4 +34,6 @@ public:
static char CopySign(char sign, char c);
};
}
#endif //STRINGTOOLS_CHARTOOLS_H

View File

@ -4,6 +4,9 @@
#include <string>
#include <vector>
namespace Leonetienne::StringTools {
/* Handy utensils to manipulate strings */
class StringTools
{
@ -40,4 +43,6 @@ private:
StringTools();
};
}
#endif //STRINGTOOLS_STRINGTOOLS_H

View File

@ -1,6 +1,8 @@
#include "StringTools/CharTools.h"
#include <algorithm>
namespace Leonetienne::StringTools {
bool CharTools::IsVowel(const char c, const std::string &vowels) {
const char lc = MakeLower(c);
@ -66,3 +68,6 @@ char CharTools::CopySign(char sign, char c) {
else
return MakeLower(c);
}
}

View File

@ -1,6 +1,8 @@
#include "StringTools/StringTools.h"
#include <sstream>
namespace Leonetienne::StringTools {
std::string StringTools::Replace(const std::string& str, const char find, const std::string& subst) {
std::stringstream ss;
@ -153,3 +155,6 @@ std::string StringTools::PadRight(const std::string& str, const char pad, const
return ss.str();
}
}

View File

@ -1,6 +1,9 @@
#include <StringTools/CharTools.h>
#include "Catch2.h"
using namespace Leonetienne::StringTools;
TEST_CASE(__FILE__"/JustChars", "[Char][CopySign]")
{
// Setup

View File

@ -1,6 +1,9 @@
#include <StringTools/CharTools.h>
#include "Catch2.h"
using namespace Leonetienne::StringTools;
// Tests character digit-ness by checking it against a map
TEST_CASE(__FILE__"/MapTest", "[Char][IsUpper]")
{

View File

@ -1,6 +1,9 @@
#include <StringTools/CharTools.h>
#include "Catch2.h"
using namespace Leonetienne::StringTools;
// Tests character letter-ness by checking it against a map
TEST_CASE(__FILE__"/MapTest", "[Char][IsLetter]")
{

View File

@ -1,6 +1,9 @@
#include <StringTools/CharTools.h>
#include "Catch2.h"
using namespace Leonetienne::StringTools;
// Tests character sign by checking it against a map
TEST_CASE(__FILE__"/MapTest", "[Char][IsLower]")
{

View File

@ -2,6 +2,9 @@
#include <iostream>
#include "Catch2.h"
using namespace Leonetienne::StringTools;
// Tests character sign by checking it against a map
TEST_CASE(__FILE__"/MapTest", "[Char][IsUpper]")
{

View File

@ -1,6 +1,9 @@
#include <StringTools/CharTools.h>
#include "Catch2.h"
using namespace Leonetienne::StringTools;
// Tests character vowel-ness by checking it against a map
TEST_CASE(__FILE__"/MapTest", "[Char][IsVowel]")
{

View File

@ -1,6 +1,9 @@
#include <StringTools/CharTools.h>
#include "Catch2.h"
using namespace Leonetienne::StringTools;
TEST_CASE(__FILE__"/LowerToUpper_NoSymbols", "[Char][MakeLower]")
{
// Setup

View File

@ -1,6 +1,9 @@
#include <StringTools/CharTools.h>
#include "Catch2.h"
using namespace Leonetienne::StringTools;
TEST_CASE(__FILE__"/LowerToUpper_NoSymbols", "[Char][MakeUpper]")
{
// Setup

View File

@ -1,6 +1,9 @@
#include <StringTools/StringTools.h>
#include "Catch2.h"
using namespace Leonetienne::StringTools;
// Tests that lowering an empty string returns an empty string
TEST_CASE(__FILE__"/EmptyString", "[Strings][Lower]")
{

View File

@ -1,6 +1,9 @@
#include <StringTools/StringTools.h>
#include "Catch2.h"
using namespace Leonetienne::StringTools;
// Tests that padding to a length shorter adds no padding
TEST_CASE(__FILE__"/PadToShorterLength", "[Strings][PadLeft]")
{

View File

@ -1,6 +1,9 @@
#include <StringTools/StringTools.h>
#include "Catch2.h"
using namespace Leonetienne::StringTools;
// Tests that padding to a length shorter adds no padding
TEST_CASE(__FILE__"/PadToShorterLength", "[Strings][PadRight]")
{

View File

@ -1,6 +1,9 @@
#include <StringTools/StringTools.h>
#include "Catch2.h"
using namespace Leonetienne::StringTools;
// Tests that replacing something in an empty string returns an empty string
TEST_CASE(__FILE__"/EmptyString", "[Strings][ReplaceChar]")
{

View File

@ -1,6 +1,9 @@
#include <StringTools/StringTools.h>
#include "Catch2.h"
using namespace Leonetienne::StringTools;
// Tests that replacing something in an empty string returns an empty string
TEST_CASE(__FILE__"/EmptyString", "[Strings][ReplaceString]")
{

View File

@ -1,6 +1,9 @@
#include <StringTools/StringTools.h>
#include "Catch2.h"
using namespace Leonetienne::StringTools;
// Tests that splitting an empty string always returns {""}
TEST_CASE(__FILE__"/EmptyString", "[Strings][Split]")
{

View File

@ -1,6 +1,9 @@
#include <StringTools/StringTools.h>
#include "Catch2.h"
using namespace Leonetienne::StringTools;
// Tests that uppering an empty string returns an empty string
TEST_CASE(__FILE__"/EmptyString", "[Strings][Upper]")
{