diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2011-12-15 16:56:33 -0800 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2011-12-15 17:39:53 -0800 |
| commit | fd1dd76977f808ec40796d6ca66e4bf98de6de9c (patch) | |
| tree | 8cea66fdfdd74af92cd74fb472f82854af538c01 /src/test/stdtest | |
| parent | 1f8f6054d283f7a2d5e5277f422463bfaecbe139 (diff) | |
| download | rust-fd1dd76977f808ec40796d6ca66e4bf98de6de9c.tar.gz rust-fd1dd76977f808ec40796d6ca66e4bf98de6de9c.zip | |
stdlib: Add a str::split_str() to split on a delimiter string of any length
Diffstat (limited to 'src/test/stdtest')
| -rw-r--r-- | src/test/stdtest/str.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/test/stdtest/str.rs b/src/test/stdtest/str.rs index d540f32ea51..b5199048364 100644 --- a/src/test/stdtest/str.rs +++ b/src/test/stdtest/str.rs @@ -60,6 +60,20 @@ fn test_split() { } #[test] +fn test_split_str() { + fn t(s: str, sep: str, i: int, k: str) { + let v = str::split_str(s, sep); + assert str::eq(v[i], k); + } + t("abc::hello::there", "::", 0, "abc"); + t("abc::hello::there", "::", 1, "hello"); + t("abc::hello::there", "::", 2, "there"); + t("::hello::there", "::", 0, "hello"); + t("hello::there::", "::", 2, ""); + t("::hello::there::", "::", 2, ""); +} + +#[test] fn test_find() { fn t(haystack: str, needle: str, i: int) { let j: int = str::find(haystack, needle); |
