mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Added String.quick_ztr and String.is_zstr
This commit is contained in:
@@ -12,6 +12,20 @@ fn void test_starts_with()
|
||||
assert(!s.starts_with("o"));
|
||||
}
|
||||
|
||||
fn void quick_zstr()
|
||||
{
|
||||
String str = "1234";
|
||||
ZString a = str.quick_zstr();
|
||||
ZString b = str[0..2].quick_zstr();
|
||||
ZString c = str[1..].quick_zstr();
|
||||
String empty = {};
|
||||
ZString d = empty.quick_zstr();
|
||||
assert((void*)a == str.ptr);
|
||||
assert((void*)b != str.ptr);
|
||||
assert((void*)c == &str[1]);
|
||||
assert(d[0] == 0);
|
||||
}
|
||||
|
||||
fn void test_print_null()
|
||||
{
|
||||
ZString z;
|
||||
@@ -201,6 +215,13 @@ fn void test_rindex_of_char()
|
||||
assert(@catch(test.index_of_char('x')));
|
||||
}
|
||||
|
||||
fn void test_base_13_convesion()
|
||||
{
|
||||
assert("13".to_long(13)!! == 13 + 3);
|
||||
assert("1a".to_long(13)!! == 13 + 10);
|
||||
assert("aa".to_long(13)!! == 13 * 10 + 10);
|
||||
}
|
||||
|
||||
fn void test_hex_conversion()
|
||||
{
|
||||
assert("0x123aCd".to_long()!! == 0x123acd);
|
||||
|
||||
Reference in New Issue
Block a user