This commit is contained in:
IlushaShurupov 2023-07-15 10:29:51 +03:00 committed by Ilya Shurupov
parent b7560534c1
commit f46ea7e0fb
7 changed files with 145 additions and 155 deletions

21
Strings/tests/Tests.cpp Normal file
View file

@ -0,0 +1,21 @@
#include "Testing.hpp"
#include "Strings.hpp"
void testStrings();
void testLogging();
int main() {
tp::ModuleManifest* deps[] = { &tp::gModuleStrings, &tp::gModuleUtils, nullptr };
tp::ModuleManifest testModule("StringsTest", nullptr, nullptr, deps);
if (!testModule.initialize()) {
return 1;
}
testStrings();
testLogging();
testModule.deinitialize();
}

View file

@ -0,0 +1,11 @@
#include "Testing.hpp"
#include "Logging.hpp"
TEST_DEF_STATIC(Simple) {
TEST(false);
}
TEST_DEF(Logging) {
testSimple();
}

View file

@ -0,0 +1,16 @@
#include "Testing.hpp"
#include "Strings.hpp"
TEST_DEF_STATIC(StringLogic) {
TEST(false);
}
TEST_DEF_STATIC(Simple) {
TEST(false);
}
TEST_DEF(Strings) {
testStringLogic();
testSimple();
}

View file

@ -1,66 +0,0 @@
#include "common.h"
#include "allocators.h"
#include "strings.h"
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include "TextEditor.hpp"
#include "Logging.hpp"
using namespace tp;
void test_conversions() {
for (auto i : tp::Range(1000)) {
auto sign = bool(std::rand() % 2) ? 1 : -1;
auto floating = std::rand() / (tp::alnf)std::rand() * sign;
auto tmp = std::to_string(floating);
auto left = tp::string(tmp.c_str());
auto right = tp::string(floating);
DBG_BREAK(left != right);
auto back = (tp::alnf)right;
//DBG_BREAK(back != floating);
auto integer = std::rand() * sign;
tmp = std::to_string(integer);
left = tp::string(tmp.c_str());
right = tp::string(integer);
DBG_BREAK(left != right);
back = (tp::alni)right;
DBG_BREAK(back != integer);
}
}
void test_editor() {
tp::string str = " initial ";
str.createEdited();
auto edited = str.getEdited();
edited->setCursor({0, 4});
edited->insert({"aaa", 3});
str.saveEdited();
str.clearEdited();
GLog->write(str, true);
}
int main() {
tp::alloc_init();
string::Initialize();
Logger::init();
//test_conversions();
test_editor();
Logger::deinit();
string::UnInitialize();
tp::alloc_uninit();
}