diff --git a/tests/include/string_tests.h b/tests/include/string_tests.h new file mode 100644 index 0000000..d44fdc4 --- /dev/null +++ b/tests/include/string_tests.h @@ -0,0 +1,27 @@ +/* + * + * Copyright (C) 2024 Brett Terpstra + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef BLT_TESTS_STRING_H +#define BLT_TESTS_STRING_H + +namespace blt::test +{ + void run_string_test(); +} + +#endif diff --git a/tests/src/string_tests.cpp b/tests/src/string_tests.cpp new file mode 100644 index 0000000..4f3216e --- /dev/null +++ b/tests/src/string_tests.cpp @@ -0,0 +1,59 @@ +/* + * + * Copyright (C) 2024 Brett Terpstra + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include +#include +#include +#include + +namespace blt::test +{ + void run_string_test() + { + std::string str = "I HAVE A LOT OF\tTABULAR\tFORMED MEMORIES"; + + auto s_splits_c = blt::string::split(str, ' '); + auto s_splits_s = blt::string::split(str, "LOT"); + + auto sv_splits_c = blt::string::split_sv(str, ' '); + auto sv_splits_s = blt::string::split_sv(str, "LOT"); + + for (auto v : blt::enumerate(s_splits_c)) + { + if (v.second != sv_splits_c[v.first]) + { + BLT_WARN("THEY DO NOT MATCH!!! '%s' vs '%s'", v.second.c_str(), std::string(sv_splits_c[v.first]).c_str()); + } else + { + BLT_DEBUG(v.second); + } + } + + BLT_INFO(""); + + for (auto v : blt::enumerate(s_splits_s)) + { + if (v.second != sv_splits_s[v.first]) + { + BLT_WARN("THEY DO NOT MATCH!!! '%s' vs '%s'", v.second.c_str(), std::string(sv_splits_s[v.first]).c_str()); + } else + { + BLT_DEBUG(v.second); + } + } + } +} \ No newline at end of file