mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
More refactorings in the stdlib. More Path functions. Updated Win32 format for types. Fix bug with codegen of defer if ... More string functions.
This commit is contained in:
committed by
Christoffer Lerno
parent
39dd3e40a6
commit
d2a16961cf
@@ -12,6 +12,43 @@ fn void test_starts_with()
|
||||
assert(!s.starts_with("o"));
|
||||
}
|
||||
|
||||
fn void test_strip()
|
||||
{
|
||||
String s = "ofke";
|
||||
assert(s.strip("of") == "ke");
|
||||
assert(s.strip("ofke") == "");
|
||||
assert(s.strip("ofkes") == "ofke");
|
||||
assert(s.strip("ofkf") == "ofke");
|
||||
assert(s.strip("") == "ofke");
|
||||
s = "";
|
||||
assert(s.strip("") == "");
|
||||
assert(s.strip("o") == "");
|
||||
}
|
||||
|
||||
fn void test_strip_end()
|
||||
{
|
||||
String s = "ofke";
|
||||
assert(s.strip_end("ke") == "of");
|
||||
assert(s.strip_end("ofke") == "");
|
||||
assert(s.strip_end("ofkes") == "ofke");
|
||||
assert(s.strip_end("ofkf") == "ofke");
|
||||
assert(s.strip_end("") == "ofke");
|
||||
s = "";
|
||||
assert(s.strip_end("") == "");
|
||||
assert(s.strip_end("o") == "");
|
||||
}
|
||||
|
||||
fn void test_ends_with()
|
||||
{
|
||||
String s = "ofke";
|
||||
assert(s.ends_with("ke"));
|
||||
assert(s.ends_with("ofke"));
|
||||
assert(!s.ends_with("ofkes"));
|
||||
assert(!s.ends_with("ofkf"));
|
||||
s = "";
|
||||
assert(s.ends_with(""));
|
||||
assert(!s.ends_with("e"));
|
||||
}
|
||||
fn void test_trim()
|
||||
{
|
||||
String s = " \t\nabc ";
|
||||
|
||||
14
test/unit/stdlib/io/path.c3
Normal file
14
test/unit/stdlib/io/path.c3
Normal file
@@ -0,0 +1,14 @@
|
||||
module std::io::path @test;
|
||||
|
||||
|
||||
fn void! test_parent()
|
||||
{
|
||||
Path p = path::new("")?;
|
||||
assert(catch(p.parent()));
|
||||
p = path::new("/")?;
|
||||
assert(catch(p.parent()));
|
||||
p = path::new("/a/b/c")?;
|
||||
assert(path::new("/a/b")? == p.parent()?);
|
||||
p = path::new("/a/b/c/")?;
|
||||
assert(path::new("/a/b")? == p.parent()?);
|
||||
}
|
||||
Reference in New Issue
Block a user