mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Add String.trim_left() / right() (#1773)
* Add String.trim_left() / right() * Fix formatting
This commit is contained in:
@@ -59,6 +59,7 @@ fn void test_ends_with()
|
||||
assert(s.ends_with(""));
|
||||
assert(!s.ends_with("e"));
|
||||
}
|
||||
|
||||
fn void test_trim()
|
||||
{
|
||||
String s = " \t\nabc ";
|
||||
@@ -67,6 +68,29 @@ fn void test_trim()
|
||||
assert(" \n\tok".trim() == "ok");
|
||||
assert("!! \n\t ".trim() == "!!");
|
||||
assert(s.trim("c \t") == "\nab");
|
||||
assert("".trim() == "");
|
||||
|
||||
|
||||
}
|
||||
|
||||
fn void test_trim_left()
|
||||
{
|
||||
String s = " \t\nabc ";
|
||||
assert(s.trim_left() == "abc ");
|
||||
assert("\n\t".trim_left() == "");
|
||||
assert(" \n\tok".trim_left() == "ok");
|
||||
assert("!! \n\t ".trim_left() == "!! \n\t ");
|
||||
assert("".trim_left() == "");
|
||||
}
|
||||
|
||||
fn void test_trim_right()
|
||||
{
|
||||
String s = " \t\nabc ";
|
||||
assert(s.trim_right() == " \t\nabc");
|
||||
assert("\n\t".trim_right() == "");
|
||||
assert(" \n\tok".trim_right() == " \n\tok");
|
||||
assert("!! \n\t ".trim_right() == "!!");
|
||||
assert("".trim_right() == "");
|
||||
}
|
||||
|
||||
fn void test_split()
|
||||
@@ -175,4 +199,4 @@ fn void! test_hex_conversion()
|
||||
{
|
||||
assert("0x123aCd".to_long()! == 0x123acd);
|
||||
assert("123acD".to_long(16)! == 0x123acd);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user