2013-03-21 17:00:29 -05:00
|
|
|
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2013-10-23 03:49:18 -05:00
|
|
|
|
2014-10-02 00:10:09 -05:00
|
|
|
#[deriving(Show)]
|
2013-03-21 17:00:29 -05:00
|
|
|
enum Token {
|
2014-10-02 00:10:09 -05:00
|
|
|
Text(String),
|
|
|
|
ETag(Vec<String>, String),
|
|
|
|
UTag(Vec<String>, String),
|
|
|
|
Section(Vec<String>, bool, Vec<Token>, String,
|
|
|
|
String, String, String, String),
|
|
|
|
IncompleteSection(Vec<String>, bool, String, bool),
|
|
|
|
Partial(String, String, String),
|
2013-03-21 17:00:29 -05:00
|
|
|
}
|
2013-05-03 18:25:04 -05:00
|
|
|
|
2013-03-21 17:00:29 -05:00
|
|
|
fn check_strs(actual: &str, expected: &str) -> bool
|
|
|
|
{
|
2014-02-05 16:33:10 -06:00
|
|
|
if actual != expected
|
|
|
|
{
|
|
|
|
println!("Found {}, but expected {}", actual, expected);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2013-03-21 17:00:29 -05:00
|
|
|
}
|
2013-05-03 18:25:04 -05:00
|
|
|
|
2013-03-27 11:58:28 -05:00
|
|
|
pub fn main()
|
2013-03-21 17:00:29 -05:00
|
|
|
{
|
2014-05-25 05:10:11 -05:00
|
|
|
// assert!(check_strs(fmt!("%?", Text(@"foo".to_string())), "Text(@~\"foo\")"));
|
|
|
|
// assert!(check_strs(fmt!("%?", ETag(@~["foo".to_string()], @"bar".to_string())),
|
2014-04-15 20:17:48 -05:00
|
|
|
// "ETag(@~[ ~\"foo\" ], @~\"bar\")"));
|
2013-05-03 18:25:04 -05:00
|
|
|
|
2014-11-06 02:05:53 -06:00
|
|
|
let t = Token::Text("foo".to_string());
|
|
|
|
let u = Token::Section(vec!["alpha".to_string()],
|
2014-10-02 00:10:09 -05:00
|
|
|
true,
|
|
|
|
vec![t],
|
|
|
|
"foo".to_string(),
|
|
|
|
"foo".to_string(), "foo".to_string(), "foo".to_string(),
|
|
|
|
"foo".to_string());
|
|
|
|
let v = format!("{}", u); // this is the line that causes the seg fault
|
2014-02-05 16:33:10 -06:00
|
|
|
assert!(v.len() > 0);
|
2013-03-21 17:00:29 -05:00
|
|
|
}
|