diff options
author | Pixel <pixel@nobis-crew.org> | 2011-12-04 01:19:09 -0800 |
---|---|---|
committer | Pixel <pixel@nobis-crew.org> | 2011-12-04 01:20:10 -0800 |
commit | d440c3f50a918a932293ad98bcec96eaa4683222 (patch) | |
tree | 33e8e42a8e4506ae9da70cdb44dd133bde7f7219 /tests/test-String.cc | |
parent | e5577eb7a643ce7885e5d14660a6d24254161622 (diff) |
Reworked some things in the architecture, mainly exceptions and asserts.
-) Removed Assert()
-) Added AAssert(), IAssert(), RAssert(), TAssert() and Failure()
-) Reworked all asserts in the code, and added meaningful messages to them.
-) Changed the way the startup code is generated; BALAU_STARTUP is no longer necessary.
Diffstat (limited to 'tests/test-String.cc')
-rw-r--r-- | tests/test-String.cc | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/tests/test-String.cc b/tests/test-String.cc index 1f7efc0..9637911 100644 --- a/tests/test-String.cc +++ b/tests/test-String.cc @@ -1,54 +1,52 @@ #include <BString.h> #include <Main.h> -BALAU_STARTUP; - using namespace Balau; void MainTask::Do() { Printer::log(M_STATUS, "Test::String running."); String x = "foobar"; - Assert(x == "foobar"); - Assert(x != "barfoo"); + TAssert(x == "foobar"); + TAssert(x != "barfoo"); String y = "xyz"; - x = "abcdef"; Assert(x < y); Assert(x + y == "abcdefxyz"); - x.set("x:%i", 42); Assert(x == "x:42"); + x = "abcdef"; TAssert(x < y); TAssert(x + y == "abcdefxyz"); + x.set("x:%i", 42); TAssert(x == "x:42"); - x = "foobar"; Assert(x == "foobar"); + x = "foobar"; TAssert(x == "foobar"); - y = x.extract(3); Assert(y == "bar"); - y = x.extract(1, 3); Assert(y == "oob"); + y = x.extract(3); TAssert(y == "bar"); + y = x.extract(1, 3); TAssert(y == "oob"); y = " foo bar "; - x = y; x.do_ltrim(); Assert(x == "foo bar "); - x = y; x.do_rtrim(); Assert(x == " foo bar"); - x = y; x.do_trim(); Assert(x == "foo bar"); + x = y; x.do_ltrim(); TAssert(x == "foo bar "); + x = y; x.do_rtrim(); TAssert(x == " foo bar"); + x = y; x.do_trim(); TAssert(x == "foo bar"); y = " "; - x = y; x.do_ltrim(); Assert(x == ""); - x = y; x.do_rtrim(); Assert(x == ""); - x = y; x.do_trim(); Assert(x == ""); + x = y; x.do_ltrim(); TAssert(x == ""); + x = y; x.do_rtrim(); TAssert(x == ""); + x = y; x.do_trim(); TAssert(x == ""); - x = "42"; Assert(x.to_int() == 42); - x = "0x42"; Assert(x.to_int() == 0x42); - x = "42"; Assert(x.to_int(16) == 0x42); - x = "4.2"; Assert(x.to_double() == 4.2); + x = "42"; TAssert(x.to_int() == 42); + x = "0x42"; TAssert(x.to_int() == 0x42); + x = "42"; TAssert(x.to_int(16) == 0x42); + x = "4.2"; TAssert(x.to_double() == 4.2); x = "foobar"; - Assert(x[0] == 'f'); - Assert(x[5] == 'r'); - Assert(x.strlen() == 6); - Assert(x.strchr('o') == 1); - Assert(x.strrchr('o') == 2); - Assert(x.strchrcnt('o') == 2); - Assert(x.strstr("bar") == 3); + TAssert(x[0] == 'f'); + TAssert(x[5] == 'r'); + TAssert(x.strlen() == 6); + TAssert(x.strchr('o') == 1); + TAssert(x.strrchr('o') == 2); + TAssert(x.strchrcnt('o') == 2); + TAssert(x.strstr("bar") == 3); x = "\xc3\xa9"; y = x.iconv("UTF-8", "Latin1"); - Assert(((unsigned char) y[0]) == 0xe9); + TAssert(((unsigned char) y[0]) == 0xe9); Printer::log(M_STATUS, "Test::String passed."); } |