Skip to content
Snippets Groups Projects
Commit 221dc1cc authored by Recolic Keghart's avatar Recolic Keghart
Browse files

working on writing tests

parent b2517279
No related branches found
No related tags found
No related merge requests found
......@@ -19,15 +19,23 @@
MODULES=string meta trait stdio sio scope_guard
CXXFLAGS=-I.
A=rlib/libr.a
FLAGS14=-std=c++14 rlib/libr.a
FLAGS17=-std=c++17
cxx14_all:
all: cxx14_all cxx17_all
cxx14_all: string_14
cxx17_all: string_17
string_14:
$(CXX) $(CXXFLAGS) -std=c++14 src/string.cc $(A) -o src/string_14
$(CXX) $(CXXFLAGS) src/string.cc $(FLAGS14) -o src/string_14.out
src/string_14.out
string_17:
$(CXX) $(CXXFLAGS) src/string.cc $(FLAGS17) -o src/string_17.out
src/string_17.out
cxx17_all:
#include <rlib/string.hpp>
using namespace rlib;
using namespace rlib::literals;
#include <rlib/stdio.hpp>
void test(const string &s)
{
println_iter(s.split());
println_iter(s.split("w"));
println(">>>", string("|").join(s.split()));
}
int main()
{
test("dsaf wefew fwef we ");
test("sfwaef wef wef wefew fwef eg") ;
test("");
test(">PAQ P<DSP<") ;
println(string(" 87sd6 8s7d5 8 8 75 ").strip() + "|");
string s = "fuck you r mom 34qwo0 ghwerf 0832 ";
s.replace("ghw", "fuck you");
println(s);
s.replace(" ", " ");
println(s);
println("{} are {} shits."_format("hust and hust", 2));
println("?"_rs .join(" shit !! ..."_rs .split()));
return 0;
}
......@@ -41,9 +41,18 @@ TEST_CASE("rlib::string others", "[string_op]") {
REQUIRE("hello world"_rs .strip("ld") == "hello wor");
REQUIRE(""_rs .strip("") == "");
REQUIRE("your mother suck fuck you"_rs.replace("you", "abc").strip("ac").split()[4] == "ab");
REQUIRE("fuck you"_rs.replace("", "") == "fuck you");
REQUIRE("123"_rs.replace("", "1") == "123");
REQUIRE("hello worlo"_rs.replace("lo", "") == "hel wor");
test_str = "hello world \n abc def some random ";
auto test_str2 = test_str;
REQUIRE(" "_rs.join(test_str.split(' ')) == test_str2);
}
File deleted
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment