Start refactor, restructure basic
This commit is contained in:
@@ -1,18 +1,58 @@
|
||||
#define BASIC_IMPL
|
||||
#include "basic/basic.h"
|
||||
#include "basic/filesystem.h"
|
||||
#include "basic/basic.cpp"
|
||||
|
||||
int main() {
|
||||
InitScratch();
|
||||
// Basic constructors
|
||||
{
|
||||
String a = "thing";
|
||||
String b("thing");
|
||||
Assert(a == b);
|
||||
String c = {};
|
||||
Assert(c.len == 0 && c.data == NULL);
|
||||
Assert(a != c);
|
||||
}
|
||||
|
||||
Scratch scratch;
|
||||
String data = ReadFile(scratch, "../data/init.lua");
|
||||
Array<String> array = {scratch};
|
||||
// Accessors
|
||||
{
|
||||
String a = "thing";
|
||||
Assert(Skip(a, 1) == "hing");
|
||||
Assert(Chop(a, 1) == "thin");
|
||||
Assert(GetPrefix(a, 1) == "t");
|
||||
Assert(GetPostfix(a, 1) == "g");
|
||||
Assert(GetSlice(a, 0) == "thing");
|
||||
Assert(GetSlice(a, 0, -1) == "thin");
|
||||
Assert(GetSlice(a, 1, -1) == "hin");
|
||||
Assert(GetSlice(a, -2, -1) == "n");
|
||||
}
|
||||
|
||||
Add(&array, String{"String BaseLuaConfig = R\"==(\n"});
|
||||
Add(&array, data);
|
||||
Add(&array, String{"\n)==\";\n"});
|
||||
String result = Merge(scratch, array, "");
|
||||
WriteFile("../src/text_editor/generated_config.cpp", result);
|
||||
{
|
||||
Scratch scratch;
|
||||
String16 a = Format16(scratch, "Memes %d", 30);
|
||||
Assert(a == u"Memes 30");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf("hello world\n");
|
||||
}
|
||||
|
||||
|
||||
// #define BASIC_IMPL
|
||||
// #include "basic/basic.h"
|
||||
// #include "basic/filesystem.h"
|
||||
|
||||
// int main() {
|
||||
// InitScratch();
|
||||
|
||||
// Scratch scratch;
|
||||
// String data = ReadFile(scratch, "../data/init.lua");
|
||||
// Array<String> array = {scratch};
|
||||
|
||||
// Add(&array, String{"String BaseLuaConfig = R\"==(\n"});
|
||||
// Add(&array, data);
|
||||
// Add(&array, String{"\n)==\";\n"});
|
||||
// String result = Merge(scratch, array, "");
|
||||
// WriteFile("../src/text_editor/generated_config.cpp", result);
|
||||
|
||||
// }
|
||||
Reference in New Issue
Block a user