Testing
This commit is contained in:
parent
d362d8c3b3
commit
c75cb9fb48
7 changed files with 145 additions and 155 deletions
21
Strings/tests/Tests.cpp
Normal file
21
Strings/tests/Tests.cpp
Normal 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();
|
||||
}
|
||||
11
Strings/tests/TestsLogging.cpp
Normal file
11
Strings/tests/TestsLogging.cpp
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
#include "Testing.hpp"
|
||||
#include "Logging.hpp"
|
||||
|
||||
TEST_DEF_STATIC(Simple) {
|
||||
TEST(false);
|
||||
}
|
||||
|
||||
TEST_DEF(Logging) {
|
||||
testSimple();
|
||||
}
|
||||
16
Strings/tests/TestsStrings.cpp
Normal file
16
Strings/tests/TestsStrings.cpp
Normal 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();
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue