add string tests

v1
Brett 2024-02-08 14:14:37 -05:00
parent c89aa61cca
commit 80f4cc5e50
2 changed files with 86 additions and 0 deletions

View File

@ -0,0 +1,27 @@
/*
* <Short Description>
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef BLT_TESTS_STRING_H
#define BLT_TESTS_STRING_H
namespace blt::test
{
void run_string_test();
}
#endif

View File

@ -0,0 +1,59 @@
/*
* <Short Description>
* 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 <https://www.gnu.org/licenses/>.
*/
#include <string_tests.h>
#include <blt/std/utility.h>
#include <blt/std/string.h>
#include <blt/std/logging.h>
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);
}
}
}
}