-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
7,424 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,5 @@ lto = "thin" | |
|
||
[dev-dependencies] | ||
serial_test = "3.1.1" | ||
test-case = "3.3.1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@prefix : <http://xmlns.com/foaf/0.1/> . | ||
|
||
<mailto:[email protected]> | ||
a :Person ; | ||
:name "Anne Example-Person2" ; | ||
:interest <http://www.foaf-project.org/> , | ||
<http://www.ilrt.bris.ac.uk/discovery/2004/01/turtle/> . |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
@prefix : <http://xmlns.com/foaf/0.1/> . | ||
|
||
<mailto:[email protected]> | ||
a :Person ; | ||
:name "Anne Example-Person" ; | ||
:interest <http://www.foaf-project.org/> , <http://www.ilrt.bris.ac.uk/discovery/2004/01/turtle/> . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
@prefix ex: <http://example.org/> . | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | ||
|
||
ex:Resource1 rdfs:comment " | ||
This is a long comment | ||
that spans multiple lines. | ||
\n | ||
It contains spaces, special characters like %, &, and @, and | ||
even new lines. This format ensures the string is | ||
properly encapsulated without breaking syntax rules. | ||
\t\t | ||
You can add as much text as needed here. | ||
" . |
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
tests/expected_complex2.ttl → examples/turtle_doc/output/0002.ttl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
tests/expectedDiffDAndE.ttl → examples/turtle_doc/output/0004.ttl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
<mailto:[email protected]> <http://xmlns.com/foaf/0.1/name> "Anne Example-Person"^^<http://www.w3.org/2001/XMLSchema#string> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<http://example.org/Resource1> <http://www.w3.org/2000/01/rdf-schema#comment> " | ||
This is a long comment | ||
that spans multiple lines. | ||
|
||
|
||
It contains spaces, special characters like %, &, and @, and | ||
even new lines. This format ensures the string is | ||
properly encapsulated without breaking syntax rules. | ||
|
||
You can add as much text as needed here. | ||
"^^<http://www.w3.org/2001/XMLSchema#string>. |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
use std::{path::PathBuf, str::FromStr}; | ||
|
||
use crate::turtle::turtle_doc::TurtleDoc; | ||
|
||
fn cmp_input_file( | ||
test_name: &str, | ||
diff_file: Option<&str>, | ||
directory: &str, | ||
well_known_prefix: Option<String>, | ||
) { | ||
println!("running {test_name}"); | ||
let mut input_buf = String::new(); | ||
let mut output_buf = String::new(); | ||
let input = TurtleDoc::from_file( | ||
PathBuf::from_str(directory) | ||
.map(|p| p.join("input").join(format!("{test_name}.ttl"))) | ||
.unwrap(), | ||
well_known_prefix.clone(), | ||
&mut input_buf, | ||
) | ||
.unwrap(); | ||
|
||
let output = TurtleDoc::from_file( | ||
PathBuf::from_str(directory) | ||
.map(|p| p.join("output").join(format!("{test_name}.ttl"))) | ||
.unwrap(), | ||
well_known_prefix.clone(), | ||
&mut output_buf, | ||
) | ||
.unwrap(); | ||
if let Some(diff) = diff_file { | ||
let mut diff_buf = String::new(); | ||
let diff = TurtleDoc::from_file( | ||
PathBuf::from_str(directory) | ||
.map(|p| p.join("diff").join(format!("{diff}.ttl"))) | ||
.unwrap(), | ||
well_known_prefix, | ||
&mut diff_buf, | ||
) | ||
.unwrap(); | ||
let input = input.difference(&diff).unwrap(); | ||
assert!(!input.is_empty()); | ||
assert_eq!(input.difference(&output).unwrap().len(), 0); | ||
} else { | ||
let diff = input.difference(&output).unwrap(); | ||
println!( | ||
"{}", | ||
input | ||
.to_string() | ||
.replace("\n", "<NEWLINE>") | ||
.replace("\t", "<TAB>") | ||
.replace(" ", "<SPACE>"), | ||
); | ||
println!("==="); | ||
println!( | ||
"{}", | ||
output | ||
.to_string() | ||
.replace("\n", "<NEWLINE>") | ||
.replace("\t", "<TAB>") | ||
.replace(" ", "<SPACE>"), | ||
); | ||
assert_eq!(input.len(), output.len()); | ||
assert_eq!(diff.len(), 0); | ||
} | ||
} | ||
mod turtle_doc_test; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use serial_test::serial; | ||
use test_case::test_case; | ||
|
||
use crate::{tests::cmp_input_file, turtle::turtle_doc::reset_fake_uuid_gen}; | ||
|
||
const INPUT_DIR: &str = "examples/turtle_doc"; | ||
|
||
#[test_case("0001", None ; "EQ: complex document with blank nodes, nested objects, etc")] | ||
#[test_case("0002", None ; "EQ: another complex document")] | ||
#[test_case("0003", None ; "EQ: could not parse completely")] | ||
#[test_case("0004", Some("0004") ; "DIFF: diff is buggy")] | ||
#[test_case("0005", Some("0005") ; "DIFF: simple diff")] | ||
#[test_case("0006", None ; "EQ: complex string with spaces")] | ||
#[test_case("0007", None ; "EQ: complex string with spaces but more complex")] | ||
#[serial] | ||
fn test_turtle_doc(test_name: &str, diff_file: Option<&str>) { | ||
reset_fake_uuid_gen(); | ||
cmp_input_file(test_name, diff_file, INPUT_DIR, None); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.