Moved objects into namespace Leonetienne
This commit is contained in:
parent
954629f6bc
commit
7d9193e3ee
@ -1,6 +1,8 @@
|
||||
#include <iostream>
|
||||
#include <StringTools/StringTools.h>
|
||||
|
||||
using namespace Leonetienne::StringTools;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::vector<std::string> foo =
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,9 @@
|
||||
#include <StringTools/CharTools.h>
|
||||
#include "Catch2.h"
|
||||
|
||||
using namespace Leonetienne::StringTools;
|
||||
|
||||
|
||||
TEST_CASE(__FILE__"/JustChars", "[Char][CopySign]")
|
||||
{
|
||||
// Setup
|
||||
|
@ -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]")
|
||||
{
|
||||
|
@ -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]")
|
||||
{
|
||||
|
@ -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]")
|
||||
{
|
||||
|
@ -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]")
|
||||
{
|
||||
|
@ -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]")
|
||||
{
|
||||
|
@ -1,6 +1,9 @@
|
||||
#include <StringTools/CharTools.h>
|
||||
#include "Catch2.h"
|
||||
|
||||
using namespace Leonetienne::StringTools;
|
||||
|
||||
|
||||
TEST_CASE(__FILE__"/LowerToUpper_NoSymbols", "[Char][MakeLower]")
|
||||
{
|
||||
// Setup
|
||||
|
@ -1,6 +1,9 @@
|
||||
#include <StringTools/CharTools.h>
|
||||
#include "Catch2.h"
|
||||
|
||||
using namespace Leonetienne::StringTools;
|
||||
|
||||
|
||||
TEST_CASE(__FILE__"/LowerToUpper_NoSymbols", "[Char][MakeUpper]")
|
||||
{
|
||||
// Setup
|
||||
|
@ -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]")
|
||||
{
|
||||
|
@ -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]")
|
||||
{
|
||||
|
@ -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]")
|
||||
{
|
||||
|
@ -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]")
|
||||
{
|
||||
|
@ -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]")
|
||||
{
|
||||
|
@ -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]")
|
||||
{
|
||||
|
@ -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]")
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user