#![cfg(feature = "nt")] use objio::{ObjectReader, ObjectWriter}; use rdftk_core::{error::Error, model::graph::Graph}; use rdftk_io::nt::{NTripleReader, NTripleWriter}; fn write_graph(graph: &Graph) { let writer = NTripleWriter::default(); let _ = writer.write(&mut std::io::stdout(), graph); } #[test] fn parse_simple() { let reader = NTripleReader::default(); let result: Result = reader.read_from_string( r###" "That Seventies Show"^^ . # literal with XML Schema string datatype "That Seventies Show" . # same as above "That Seventies Show"@en . # literal with a language tag "Cette Série des Années Septante"@fr-be . # literal outside of ASCII range with a region subtag "This is a multi-line\nliteral with many quotes (\"\"\"\"\")\nand two apostrophes ('')." . "2"^^ . # xsd:integer "1.663E-4"^^ . # xsd:double "### ); match result { Ok(g) => { println!("ok"); write_graph(&g); } Err(e) => { println!("{:?}", e); panic!(); } } } #[test] fn parse_simple_with_blanks() { let reader = NTripleReader::default(); let result: Result = reader.read_from_string( r###" . # comments here # or on a line by themselves _:subject1 "object1" . _:subject2 "object2" . "### ); match result { Ok(g) => { println!("ok"); write_graph(&g); } Err(e) => { println!("{:?}", e); panic!(); } } }