Added simple testing capabilities

This commit is contained in:
kilroy
2025-11-28 19:38:18 -05:00
parent b7ce065002
commit a7a2759053
3 changed files with 52 additions and 35 deletions

View File

@@ -5,41 +5,8 @@
int main(void)
{
// C-style to string
string a;
a.chars = "Manual transformation of C-style to String";
a.length = strlen(a.chars);
string a = StrLit("Hello, world!");
PrintStr(a);
// Automatic c-style to string
string b = CStyleToLengthString_Assign("Function transformation of C-style to String");
PrintStr(b);
// String assigning (shallow copy) and copying (deep copy)
char xx[] = "String Assign Copy";
char yy[] = "String Deep Copy";
string x = CStyleToLengthString_Assign(xx);
string y = CStyleToLengthString_Assign(yy);
string c = x;
PrintStr(c);
string d = StringCopy(y);
PrintStr(d);
x.chars[3] = '!';
y.chars[3] = '!';
PrintStr(c);
PrintStr(d);
// Manual string slicing
string e;
e.chars = &a.chars[7];
e.length = 14;
PrintStr(e);
// Automatic string slicing (by length or by index range)
string f = StringSlice_Length(a, 7, 14);
string g = StringSlice_Index(a, 7, 21);
PrintStr(f);
PrintStr(g);
return 0;
}