about summary refs log tree commit diff
path: root/src/test/stdtest/vec_str_conversions.rs
blob: bb8ad337e23fe5c43725a867a6c2fd2e888ff138 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


// -*- rust -*-
use std;
import std::istr;
import std::vec;

#[test]
fn test_simple() {
    let s1: istr = ~"All mimsy were the borogoves";

    let v: [u8] = istr::bytes(s1);
    let s2: istr = istr::unsafe_from_bytes(v);
    let i: uint = 0u;
    let n1: uint = istr::byte_len(s1);
    let n2: uint = vec::len::<u8>(v);
    assert (n1 == n2);
    while i < n1 {
        let a: u8 = s1[i];
        let b: u8 = s2[i];
        log a;
        log b;
        assert (a == b);
        i += 1u;
    }
}