An example of the string class.
#ifndef DEBUG
#define DEBUG
#endif
#include <stdio.h>
extern "C" int main()
{
char buff[33];
char *tokens = NULL;
unsigned count = 0;
const char *tp;
const char *array[5];
assert(
eq_case(
"hello this is a test", *mystr));
assert(
eq_case(
"second test", *testing));
assert(
eq_case(
" Is a test", mystr(-10)));
mystr = " abc 123 \n ";
while(NULL != (tp =
String::token(buff, &tokens,
" ",
"\"\"")) && count < 4)
array[count++] = tp;
assert(count == 3);
assert(
eq_case(array[2],
"a test"));
unsigned char core[4] = {0x01, 0x10, 0x2f, 0x45};
char hexbuf[12];
assert(
eq(hexbuf,
"01102f-45"));
unsigned char hcore[4];
assert(
eq(hexbuf,
"01102f-45"));
Real num1;
Unsigned num2;
numstr % num1 % "," % num2;
assert(num1 == -33.5);
assert(num2 == 25);
assert(numstr.
len() == 0);
char *test = strdup(str("hello") + " test" + str((short)13));
assert(
eq(test,
"hello test13"));
char *cdup = dup<char>(test[6]);
assert(
eq(cdup,
"test13"));
paste_test.
paste(3,
"bar", 3);
paste_test_empty.
paste(3,
"bar", 3);
assert(
eq(paste_test,
"foobar"));
assert(
eq(paste_test_empty,
"bar"));
delete[] test;
delete[] cdup;
return 0;
}