1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 use std::strbuf::StrBuf;
13 fn test_stack_assign() {
15 println!("{}", s.clone());
22 fn test_heap_lit() { ~"a big string"; }
24 fn test_heap_assign() {
25 let s: ~str = ~"a big ol' string";
26 let t: ~str = ~"a big ol' string";
28 let u: ~str = ~"a bad ol' string";
32 fn test_heap_log() { let s = ~"a big ol' string"; println!("{}", s); }
35 assert_eq!(~"a" + "b", ~"ab");
37 assert_eq!(s + s, ~"aa");
38 assert_eq!(~"" + "", ~"");
41 fn test_stack_heap_add() { assert!((~"a" + "bracadabra" == ~"abracadabra")); }
44 assert_eq!(~"this should" + " totally work", ~"this should totally work");
48 let mut s = StrBuf::new();
50 assert_eq!(s.as_slice(), "a");
52 let mut s = StrBuf::from_str("a");
54 println!("{}", s.clone());
55 assert_eq!(s.as_slice(), "ab");
57 let mut s = StrBuf::from_str("c");
59 assert!(s.as_slice() == "coffee");
62 assert!(s.as_slice() == "coffee&tea");
71 test_stack_heap_add();