use super::framework::*;
use super::helpers::*;
fn runner() -> ConformanceTestRunner {
ConformanceTestRunner::new()
}
#[test]
fn test_pp_01_sequence_direct() {
let ds = hierarchy_dataset();
let path = path_seq(
path_iri(&format!("{EX}child")),
path_iri(&format!("{EX}child")),
);
let algebra = property_path(var("s"), path, var("o"));
let test = ConformanceTest::new(
"pp-01",
ConformanceGroup::PropertyPaths,
algebra,
ds,
ConformanceResult::ResultCount(3), );
runner().run_test(&test).expect("pp-01 failed");
}
#[test]
fn test_pp_02_sequence_triple_hop() {
let ds = hierarchy_dataset();
let path = path_seq(
path_seq(
path_iri(&format!("{EX}child")),
path_iri(&format!("{EX}child")),
),
path_iri(&format!("{EX}child")),
);
let algebra = property_path(var("s"), path, var("o"));
let test = ConformanceTest::new(
"pp-02",
ConformanceGroup::PropertyPaths,
algebra,
ds,
ConformanceResult::ResultCount(2), );
runner().run_test(&test).expect("pp-02 failed");
}
#[test]
fn test_pp_03_alternative() {
let ds = hierarchy_dataset();
let path = path_alt(
path_iri(&format!("{EX}child")),
path_iri(&format!("{EX}knows")),
);
let algebra = property_path(var("s"), path, var("o"));
let test = ConformanceTest::new(
"pp-03",
ConformanceGroup::PropertyPaths,
algebra,
ds,
ConformanceResult::ResultCount(4),
);
runner().run_test(&test).expect("pp-03 failed");
}
#[test]
fn test_pp_04_alternative_three() {
let mut ds = InMemoryDataset::new();
ds.add_triple(ex("s"), ex("p1"), ex("o1"));
ds.add_triple(ex("s"), ex("p2"), ex("o2"));
ds.add_triple(ex("s"), ex("p3"), ex("o3"));
ds.add_triple(ex("s"), ex("p4"), ex("o4"));
let path = path_alt(
path_alt(path_iri(&format!("{EX}p1")), path_iri(&format!("{EX}p2"))),
path_iri(&format!("{EX}p3")),
);
let algebra = property_path(ex("s"), path, var("o"));
let test = ConformanceTest::new(
"pp-04",
ConformanceGroup::PropertyPaths,
algebra,
ds,
ConformanceResult::ResultCount(3), );
runner().run_test(&test).expect("pp-04 failed");
}
#[test]
fn test_pp_05_zero_or_more_from_specific() {
let ds = hierarchy_dataset();
let path = path_star(path_iri(&format!("{EX}child")));
let algebra = property_path(ex("a"), path, var("o"));
let test = ConformanceTest::new(
"pp-05",
ConformanceGroup::PropertyPaths,
algebra,
ds,
ConformanceResult::ResultCount(5),
);
runner().run_test(&test).expect("pp-05 failed");
}
#[test]
fn test_pp_06_zero_or_more_variable_subject() {
let ds = hierarchy_dataset();
let path = path_star(path_iri(&format!("{EX}child")));
let algebra = property_path(var("s"), path, ex("e"));
let test = ConformanceTest::new(
"pp-06",
ConformanceGroup::PropertyPaths,
algebra,
ds,
ConformanceResult::ResultCount(5),
);
runner().run_test(&test).expect("pp-06 failed");
}
#[test]
fn test_pp_07_one_or_more() {
let ds = hierarchy_dataset();
let path = path_plus(path_iri(&format!("{EX}child")));
let algebra = property_path(ex("a"), path, var("o"));
let test = ConformanceTest::new(
"pp-07",
ConformanceGroup::PropertyPaths,
algebra,
ds,
ConformanceResult::ResultCount(4),
);
runner().run_test(&test).expect("pp-07 failed");
}
#[test]
fn test_pp_08_one_or_more_direct() {
let mut ds = InMemoryDataset::new();
ds.add_triple(ex("a"), ex("p"), ex("b"));
let path = path_plus(path_iri(&format!("{EX}p")));
let algebra = property_path(ex("a"), path, var("o"));
let test = ConformanceTest::new(
"pp-08",
ConformanceGroup::PropertyPaths,
algebra,
ds,
ConformanceResult::ResultCount(1), );
runner().run_test(&test).expect("pp-08 failed");
}
#[test]
fn test_pp_09_zero_or_one_present() {
let mut ds = InMemoryDataset::new();
ds.add_triple(ex("a"), ex("child"), ex("b"));
let path = path_opt(path_iri(&format!("{EX}child")));
let algebra = property_path(ex("a"), path, var("o"));
let test = ConformanceTest::new(
"pp-09",
ConformanceGroup::PropertyPaths,
algebra,
ds,
ConformanceResult::ResultCount(2),
);
runner().run_test(&test).expect("pp-09 failed");
}
#[test]
fn test_pp_10_zero_or_one_absent() {
let mut ds = InMemoryDataset::new();
ds.add_triple(ex("a"), ex("other"), ex("c"));
let path = path_opt(path_iri(&format!("{EX}child")));
let algebra = property_path(ex("a"), path, var("o"));
let test = ConformanceTest::new(
"pp-10",
ConformanceGroup::PropertyPaths,
algebra,
ds,
ConformanceResult::ResultCount(1),
);
runner().run_test(&test).expect("pp-10 failed");
}
#[test]
fn test_pp_11_inverse() {
let ds = hierarchy_dataset();
let path = path_inv(path_iri(&format!("{EX}child")));
let algebra = property_path(var("s"), path, ex("b"));
let test = ConformanceTest::new(
"pp-11",
ConformanceGroup::PropertyPaths,
algebra,
ds,
ConformanceResult::ResultCount(1), );
runner().run_test(&test).expect("pp-11 failed");
}
#[test]
fn test_pp_12_inverse_full() {
let ds = hierarchy_dataset();
let path = path_inv(path_iri(&format!("{EX}child")));
let algebra = property_path(var("s"), path, var("o"));
let test = ConformanceTest::new(
"pp-12",
ConformanceGroup::PropertyPaths,
algebra,
ds,
ConformanceResult::ResultCount(4), );
runner().run_test(&test).expect("pp-12 failed");
}
#[test]
fn test_pp_13_negated() {
let ds = hierarchy_dataset();
let path = path_neg(vec![path_iri(&format!("{EX}child"))]);
let algebra = property_path(var("s"), path, var("o"));
let test = ConformanceTest::new(
"pp-13",
ConformanceGroup::PropertyPaths,
algebra,
ds,
ConformanceResult::ResultCount(2), );
runner().run_test(&test).expect("pp-13 failed");
}
#[test]
fn test_pp_14_negated_empty_set() {
let ds = hierarchy_dataset();
let path = path_neg(vec![]);
let algebra = property_path(var("s"), path, var("o"));
let test = ConformanceTest::new(
"pp-14",
ConformanceGroup::PropertyPaths,
algebra,
ds,
ConformanceResult::ResultCount(4),
);
runner().run_test(&test).expect("pp-14 failed");
}
#[test]
fn test_pp_15_seq_star() {
let ds = hierarchy_dataset();
let path = path_seq(
path_iri(&format!("{EX}knows")),
path_star(path_iri(&format!("{EX}child"))),
);
let algebra = property_path(var("s"), path, var("o"));
let test = ConformanceTest::new(
"pp-15",
ConformanceGroup::PropertyPaths,
algebra,
ds,
ConformanceResult::ResultCount(7), );
runner().run_test(&test).expect("pp-15 failed");
}
#[test]
fn test_pp_16_alt_star() {
let ds = hierarchy_dataset();
let path = path_star(path_alt(
path_iri(&format!("{EX}child")),
path_iri(&format!("{EX}knows")),
));
let algebra = property_path(ex("a"), path, var("o"));
let test = ConformanceTest::new(
"pp-16",
ConformanceGroup::PropertyPaths,
algebra,
ds,
ConformanceResult::ResultCount(5),
);
runner().run_test(&test).expect("pp-16 failed");
}
#[test]
fn test_pp_17_direct_iri_path() {
let ds = person_dataset();
let path = path_iri(&format!("{FOAF}name"));
let algebra = property_path(var("s"), path, var("o"));
let test = ConformanceTest::new(
"pp-17",
ConformanceGroup::PropertyPaths,
algebra,
ds,
ConformanceResult::ResultCount(3),
);
runner().run_test(&test).expect("pp-17 failed");
}
#[test]
fn test_pp_18_path_with_bgp_join() {
let ds = hierarchy_dataset();
let path_algebra = property_path(
var("s"),
path_plus(path_iri(&format!("{EX}child"))),
var("o"),
);
let bgp_algebra = bgp(vec![triple(var("o"), ex("child"), var("leaf"))]);
let algebra = project(
join(path_algebra, bgp_algebra),
vec![variable("s"), variable("o"), variable("leaf")],
);
let test = ConformanceTest::new(
"pp-18",
ConformanceGroup::PropertyPaths,
algebra,
ds,
ConformanceResult::ResultCount(6),
);
runner().run_test(&test).expect("pp-18 failed");
}