MCPcopy Create free account
hub / github.com/cosdata/cosdata / test_entity_pattern_parser

Function test_entity_pattern_parser

src/cosql/pattern/entity.rs:42–89  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40
41 #[test]
42 fn test_entity_pattern_parser() {
43 let values = [
44 (
45 r#"$person1 isa person (
46 name: $name,
47 age: 18,
48 gender: "M"
49 )"#,
50 EntityPattern {
51 variable: "person1".to_string(),
52 entity_type: "person".to_string(),
53 attributes: vec![
54 Attribute {
55 name: "name".to_string(),
56 value: Value::Variable("name".to_string()),
57 },
58 Attribute {
59 name: "age".to_string(),
60 value: Value::Int(18),
61 },
62 Attribute {
63 name: "gender".to_string(),
64 value: Value::String("M".to_string()),
65 },
66 ],
67 },
68 ),
69 (
70 r#"$city1 isa city (
71 name: "New York"
72 )"#,
73 EntityPattern {
74 variable: "city1".to_string(),
75 entity_type: "city".to_string(),
76 attributes: vec![Attribute {
77 name: "name".to_string(),
78 value: Value::String("New York".to_string()),
79 }],
80 },
81 ),
82 ];
83
84 for (source, expected) in values {
85 let (_, parsed) = parse_entity_pattern(source).unwrap();
86
87 assert_eq!(parsed, expected);
88 }
89 }
90}

Callers

nothing calls this directly

Calls 1

parse_entity_patternFunction · 0.85

Tested by

no test coverage detected