Moved objects into namespace Leonetienne
This commit is contained in:
parent
954629f6bc
commit
7d9193e3ee
@ -1,6 +1,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <StringTools/StringTools.h>
|
#include <StringTools/StringTools.h>
|
||||||
|
|
||||||
|
using namespace Leonetienne::StringTools;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
std::vector<std::string> foo =
|
std::vector<std::string> foo =
|
||||||
|
@ -3,8 +3,10 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
/* Handy utensils to manipulate characters */
|
|
||||||
|
|
||||||
|
namespace Leonetienne::StringTools {
|
||||||
|
|
||||||
|
/* Handy utensils to manipulate characters */
|
||||||
class CharTools {
|
class CharTools {
|
||||||
public:
|
public:
|
||||||
//! Checks whether or not `c` is a vowel. You can define custom vowel characters.
|
//! 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);
|
static char CopySign(char sign, char c);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif //STRINGTOOLS_CHARTOOLS_H
|
#endif //STRINGTOOLS_CHARTOOLS_H
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
|
namespace Leonetienne::StringTools {
|
||||||
|
|
||||||
/* Handy utensils to manipulate strings */
|
/* Handy utensils to manipulate strings */
|
||||||
class StringTools
|
class StringTools
|
||||||
{
|
{
|
||||||
@ -40,4 +43,6 @@ private:
|
|||||||
StringTools();
|
StringTools();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif //STRINGTOOLS_STRINGTOOLS_H
|
#endif //STRINGTOOLS_STRINGTOOLS_H
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include "StringTools/CharTools.h"
|
#include "StringTools/CharTools.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
namespace Leonetienne::StringTools {
|
||||||
|
|
||||||
bool CharTools::IsVowel(const char c, const std::string &vowels) {
|
bool CharTools::IsVowel(const char c, const std::string &vowels) {
|
||||||
const char lc = MakeLower(c);
|
const char lc = MakeLower(c);
|
||||||
|
|
||||||
@ -66,3 +68,6 @@ char CharTools::CopySign(char sign, char c) {
|
|||||||
else
|
else
|
||||||
return MakeLower(c);
|
return MakeLower(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include "StringTools/StringTools.h"
|
#include "StringTools/StringTools.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
namespace Leonetienne::StringTools {
|
||||||
|
|
||||||
std::string StringTools::Replace(const std::string& str, const char find, const std::string& subst) {
|
std::string StringTools::Replace(const std::string& str, const char find, const std::string& subst) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|
||||||
@ -153,3 +155,6 @@ std::string StringTools::PadRight(const std::string& str, const char pad, const
|
|||||||
|
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#include <StringTools/CharTools.h>
|
#include <StringTools/CharTools.h>
|
||||||
#include "Catch2.h"
|
#include "Catch2.h"
|
||||||
|
|
||||||
|
using namespace Leonetienne::StringTools;
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE(__FILE__"/JustChars", "[Char][CopySign]")
|
TEST_CASE(__FILE__"/JustChars", "[Char][CopySign]")
|
||||||
{
|
{
|
||||||
// Setup
|
// Setup
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#include <StringTools/CharTools.h>
|
#include <StringTools/CharTools.h>
|
||||||
#include "Catch2.h"
|
#include "Catch2.h"
|
||||||
|
|
||||||
|
using namespace Leonetienne::StringTools;
|
||||||
|
|
||||||
|
|
||||||
// Tests character digit-ness by checking it against a map
|
// Tests character digit-ness by checking it against a map
|
||||||
TEST_CASE(__FILE__"/MapTest", "[Char][IsUpper]")
|
TEST_CASE(__FILE__"/MapTest", "[Char][IsUpper]")
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#include <StringTools/CharTools.h>
|
#include <StringTools/CharTools.h>
|
||||||
#include "Catch2.h"
|
#include "Catch2.h"
|
||||||
|
|
||||||
|
using namespace Leonetienne::StringTools;
|
||||||
|
|
||||||
|
|
||||||
// Tests character letter-ness by checking it against a map
|
// Tests character letter-ness by checking it against a map
|
||||||
TEST_CASE(__FILE__"/MapTest", "[Char][IsLetter]")
|
TEST_CASE(__FILE__"/MapTest", "[Char][IsLetter]")
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#include <StringTools/CharTools.h>
|
#include <StringTools/CharTools.h>
|
||||||
#include "Catch2.h"
|
#include "Catch2.h"
|
||||||
|
|
||||||
|
using namespace Leonetienne::StringTools;
|
||||||
|
|
||||||
|
|
||||||
// Tests character sign by checking it against a map
|
// Tests character sign by checking it against a map
|
||||||
TEST_CASE(__FILE__"/MapTest", "[Char][IsLower]")
|
TEST_CASE(__FILE__"/MapTest", "[Char][IsLower]")
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "Catch2.h"
|
#include "Catch2.h"
|
||||||
|
|
||||||
|
using namespace Leonetienne::StringTools;
|
||||||
|
|
||||||
|
|
||||||
// Tests character sign by checking it against a map
|
// Tests character sign by checking it against a map
|
||||||
TEST_CASE(__FILE__"/MapTest", "[Char][IsUpper]")
|
TEST_CASE(__FILE__"/MapTest", "[Char][IsUpper]")
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#include <StringTools/CharTools.h>
|
#include <StringTools/CharTools.h>
|
||||||
#include "Catch2.h"
|
#include "Catch2.h"
|
||||||
|
|
||||||
|
using namespace Leonetienne::StringTools;
|
||||||
|
|
||||||
|
|
||||||
// Tests character vowel-ness by checking it against a map
|
// Tests character vowel-ness by checking it against a map
|
||||||
TEST_CASE(__FILE__"/MapTest", "[Char][IsVowel]")
|
TEST_CASE(__FILE__"/MapTest", "[Char][IsVowel]")
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#include <StringTools/CharTools.h>
|
#include <StringTools/CharTools.h>
|
||||||
#include "Catch2.h"
|
#include "Catch2.h"
|
||||||
|
|
||||||
|
using namespace Leonetienne::StringTools;
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE(__FILE__"/LowerToUpper_NoSymbols", "[Char][MakeLower]")
|
TEST_CASE(__FILE__"/LowerToUpper_NoSymbols", "[Char][MakeLower]")
|
||||||
{
|
{
|
||||||
// Setup
|
// Setup
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#include <StringTools/CharTools.h>
|
#include <StringTools/CharTools.h>
|
||||||
#include "Catch2.h"
|
#include "Catch2.h"
|
||||||
|
|
||||||
|
using namespace Leonetienne::StringTools;
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE(__FILE__"/LowerToUpper_NoSymbols", "[Char][MakeUpper]")
|
TEST_CASE(__FILE__"/LowerToUpper_NoSymbols", "[Char][MakeUpper]")
|
||||||
{
|
{
|
||||||
// Setup
|
// Setup
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#include <StringTools/StringTools.h>
|
#include <StringTools/StringTools.h>
|
||||||
#include "Catch2.h"
|
#include "Catch2.h"
|
||||||
|
|
||||||
|
using namespace Leonetienne::StringTools;
|
||||||
|
|
||||||
|
|
||||||
// Tests that lowering an empty string returns an empty string
|
// Tests that lowering an empty string returns an empty string
|
||||||
TEST_CASE(__FILE__"/EmptyString", "[Strings][Lower]")
|
TEST_CASE(__FILE__"/EmptyString", "[Strings][Lower]")
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#include <StringTools/StringTools.h>
|
#include <StringTools/StringTools.h>
|
||||||
#include "Catch2.h"
|
#include "Catch2.h"
|
||||||
|
|
||||||
|
using namespace Leonetienne::StringTools;
|
||||||
|
|
||||||
|
|
||||||
// Tests that padding to a length shorter adds no padding
|
// Tests that padding to a length shorter adds no padding
|
||||||
TEST_CASE(__FILE__"/PadToShorterLength", "[Strings][PadLeft]")
|
TEST_CASE(__FILE__"/PadToShorterLength", "[Strings][PadLeft]")
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#include <StringTools/StringTools.h>
|
#include <StringTools/StringTools.h>
|
||||||
#include "Catch2.h"
|
#include "Catch2.h"
|
||||||
|
|
||||||
|
using namespace Leonetienne::StringTools;
|
||||||
|
|
||||||
|
|
||||||
// Tests that padding to a length shorter adds no padding
|
// Tests that padding to a length shorter adds no padding
|
||||||
TEST_CASE(__FILE__"/PadToShorterLength", "[Strings][PadRight]")
|
TEST_CASE(__FILE__"/PadToShorterLength", "[Strings][PadRight]")
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#include <StringTools/StringTools.h>
|
#include <StringTools/StringTools.h>
|
||||||
#include "Catch2.h"
|
#include "Catch2.h"
|
||||||
|
|
||||||
|
using namespace Leonetienne::StringTools;
|
||||||
|
|
||||||
|
|
||||||
// Tests that replacing something in an empty string returns an empty string
|
// Tests that replacing something in an empty string returns an empty string
|
||||||
TEST_CASE(__FILE__"/EmptyString", "[Strings][ReplaceChar]")
|
TEST_CASE(__FILE__"/EmptyString", "[Strings][ReplaceChar]")
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#include <StringTools/StringTools.h>
|
#include <StringTools/StringTools.h>
|
||||||
#include "Catch2.h"
|
#include "Catch2.h"
|
||||||
|
|
||||||
|
using namespace Leonetienne::StringTools;
|
||||||
|
|
||||||
|
|
||||||
// Tests that replacing something in an empty string returns an empty string
|
// Tests that replacing something in an empty string returns an empty string
|
||||||
TEST_CASE(__FILE__"/EmptyString", "[Strings][ReplaceString]")
|
TEST_CASE(__FILE__"/EmptyString", "[Strings][ReplaceString]")
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#include <StringTools/StringTools.h>
|
#include <StringTools/StringTools.h>
|
||||||
#include "Catch2.h"
|
#include "Catch2.h"
|
||||||
|
|
||||||
|
using namespace Leonetienne::StringTools;
|
||||||
|
|
||||||
|
|
||||||
// Tests that splitting an empty string always returns {""}
|
// Tests that splitting an empty string always returns {""}
|
||||||
TEST_CASE(__FILE__"/EmptyString", "[Strings][Split]")
|
TEST_CASE(__FILE__"/EmptyString", "[Strings][Split]")
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#include <StringTools/StringTools.h>
|
#include <StringTools/StringTools.h>
|
||||||
#include "Catch2.h"
|
#include "Catch2.h"
|
||||||
|
|
||||||
|
using namespace Leonetienne::StringTools;
|
||||||
|
|
||||||
|
|
||||||
// Tests that uppering an empty string returns an empty string
|
// Tests that uppering an empty string returns an empty string
|
||||||
TEST_CASE(__FILE__"/EmptyString", "[Strings][Upper]")
|
TEST_CASE(__FILE__"/EmptyString", "[Strings][Upper]")
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user