diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-08-25 22:11:42 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-08-27 15:54:44 -0700 |
| commit | 138973335aba835a451ce7c9914c7ca020bcc753 (patch) | |
| tree | 650da654e1d6cba0d2bd19c5c3686958a285c695 /src/test/stdtest | |
| parent | 7284f820d57e13b10fd9f1c3fc771fac52b6b66a (diff) | |
| download | rust-138973335aba835a451ce7c9914c7ca020bcc753.tar.gz rust-138973335aba835a451ce7c9914c7ca020bcc753.zip | |
Add std::istr::as_buf for converting to cstrs. Issue #855
Diffstat (limited to 'src/test/stdtest')
| -rw-r--r-- | src/test/stdtest/istr.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/test/stdtest/istr.rs b/src/test/stdtest/istr.rs index b762e438336..32497a8858b 100644 --- a/src/test/stdtest/istr.rs +++ b/src/test/stdtest/istr.rs @@ -264,4 +264,24 @@ fn str_from_cstr() { let b = vec::to_ptr(a); let c = istr::str_from_cstr(b); assert c == ~"AAAAAAA"; -} \ No newline at end of file +} + +#[test] +fn as_buf() { + let a = ~"Abcdefg"; + let b = istr::as_buf(a, { |buf| + assert *buf == 65u8; + 100 + }); + assert b == 100; +} + +#[test] +fn as_buf_small() { + let a = ~"A"; + let b = istr::as_buf(a, { |buf| + assert *buf == 65u8; + 100 + }); + assert b == 100; +} |
