From 4642153f7f0f996cf5d10660ad90b17dbccbdb8b Mon Sep 17 00:00:00 2001 From: cmdoret Date: Mon, 26 Aug 2024 20:18:42 +0200 Subject: [PATCH] test(rules): use in cases --- src/rules.rs | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/rules.rs b/src/rules.rs index d9a767b..cecd920 100644 --- a/src/rules.rs +++ b/src/rules.rs @@ -138,8 +138,8 @@ mod tests { use serde_yml; // Instance used in tests - const NODE_IRI: &str = "Alice"; - const PREDICATE_IRI: &str = "hasName"; + const NODE_IRI: &str = ""; + const PREDICATE_IRI: &str = ""; // Helper macro to create a HashMap from pairs #[macro_export] @@ -162,11 +162,11 @@ mod tests { #[rstest] // Subject is in the rules & type index - #[case(index! { NODE_IRI => "Person" }, "Person", true)] + #[case(index! { NODE_IRI => "" }, "", true)] // Subject is in the type index, not in the rules - #[case(index! { NODE_IRI => "Person" }, "Bank", false)] + #[case(index! { NODE_IRI => "" }, "", false)] // Subject is not in the type index - #[case(index! { "BankName" => "Bank" }, "Bank", false)] + #[case(index! { "" => "" }, "", false)] fn type_rule( #[case] mut index: TypeIndex, #[case] rule_type: &str, @@ -201,13 +201,13 @@ mod tests { #[rstest] // Subject predicate in config - #[case("Person", "hasName", index! { NODE_IRI => "Person" }, true)] + #[case("", "", index! { NODE_IRI => "" }, true)] // Subject in config, predicate not - #[case("Person", "hasAge", index! { NODE_IRI => "Person" }, false)] + #[case("", "", index! { NODE_IRI => "" }, false)] // Subject predicate not in config - #[case("Bob", "hasAge", index! { NODE_IRI => "Person" }, false)] + #[case("", "", index! { NODE_IRI => "" }, false)] // Subject not in type index - #[case("Bob", "hasAge", index! { "Bob" => "Person" }, false)] + #[case("", "", index! { "" => "" }, false)] fn type_predicate_rule( #[case] rule_type: &str, #[case] rule_predicate: &str, @@ -245,18 +245,20 @@ mod tests { let rules: Rules = parse_rules( r#" nodes: - of_type: ["urn:Person"] + of_type: [""] objects: - on_predicate: ["urn:hasLastName"] + on_predicate: [""] on_type_predicate: - "urn:Person": ["urn:hasAge"] + "": [""] "#, ); let mut index = index! { - "urn:Alice" => "urn:Person", - "urn:Bob" => "urn:Person", - "urn:ACME" => "urn:Organization" + "" => "", + "" => "", + "" => "" }; + println!("{}", serde_yml::to_string(&rules).unwrap()); + println!("{}", serde_json::to_string(&index).unwrap()); TurtleParser::new(triple.as_ref(), None) .parse_all(&mut |t| { let mask = match_rules(&t.into(), &rules, &mut index);