|
|
@ -702,36 +702,30 @@ impl<S: StringStore + Default> Default for Encoder<S> { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mod test { |
|
|
|
#[test] |
|
|
|
use model::*; |
|
|
|
fn test_encoding() { |
|
|
|
use store::numeric_encoder::*; |
|
|
|
let encoder: Encoder<MemoryStringStore> = Encoder::default(); |
|
|
|
|
|
|
|
let terms: Vec<Term> = vec![ |
|
|
|
#[test] |
|
|
|
NamedNode::from_str("http://foo.com").unwrap().into(), |
|
|
|
fn test_encoding() { |
|
|
|
NamedNode::from_str("http://bar.com").unwrap().into(), |
|
|
|
let encoder: Encoder<MemoryStringStore> = Encoder::default(); |
|
|
|
NamedNode::from_str("http://foo.com").unwrap().into(), |
|
|
|
let terms: Vec<Term> = vec![ |
|
|
|
BlankNode::default().into(), |
|
|
|
NamedNode::from_str("http://foo.com").unwrap().into(), |
|
|
|
Literal::new_simple_literal("foo").into(), |
|
|
|
NamedNode::from_str("http://bar.com").unwrap().into(), |
|
|
|
Literal::from(true).into(), |
|
|
|
NamedNode::from_str("http://foo.com").unwrap().into(), |
|
|
|
Literal::from(1.2).into(), |
|
|
|
BlankNode::default().into(), |
|
|
|
Literal::from(1).into(), |
|
|
|
Literal::new_simple_literal("foo").into(), |
|
|
|
Literal::from("foo").into(), |
|
|
|
Literal::from(true).into(), |
|
|
|
Literal::new_language_tagged_literal("foo", "fr").into(), |
|
|
|
Literal::from(1.2).into(), |
|
|
|
]; |
|
|
|
Literal::from(1).into(), |
|
|
|
for term in terms { |
|
|
|
Literal::from("foo").into(), |
|
|
|
let encoded = encoder.encode_term(&term).unwrap(); |
|
|
|
Literal::new_language_tagged_literal("foo", "fr").into(), |
|
|
|
assert_eq!(term, encoder.decode_term(encoded).unwrap()) |
|
|
|
]; |
|
|
|
|
|
|
|
for term in terms { |
|
|
|
|
|
|
|
let encoded = encoder.encode_term(&term).unwrap(); |
|
|
|
|
|
|
|
assert_eq!(term, encoder.decode_term(encoded).unwrap()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
|
fn test_encoded_term_size() { |
|
|
|
fn test_encoded_term_size() { |
|
|
|
use std::mem::size_of; |
|
|
|
use std::mem::size_of; |
|
|
|
|
|
|
|
|
|
|
|
assert_eq!(size_of::<EncodedTerm>(), 24); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert_eq!(size_of::<EncodedTerm>(), 24); |
|
|
|
} |
|
|
|
} |
|
|
|