Improved tests for tokens

This commit is contained in:
2025-04-13 19:05:10 +02:00
parent ac2c1ae08b
commit 773134e65b
17 changed files with 968 additions and 1402 deletions

View File

@@ -33,16 +33,19 @@ impl CharTrieNode {
py: Python<'_>,
xml_validator: &XmlSchemaValidator,
) -> Vec<Py<PyAny>> {
let res = self.children.iter().map(|(c, n)|{
let mut node_validator = xml_validator.clone();
if node_validator.append_char(*c).is_ok() {
// If the node is valid, recursively check its children
n.find_invalid_tokens(py, &node_validator)
} else {
// If the node is invalid, add it and its children to the list of invalid tokens
n.all_tokens(py)
}
})
let res = self
.children
.iter()
.map(|(c, n)| {
let mut node_validator = xml_validator.clone();
if node_validator.append_char(*c).is_ok() {
// If the node is valid, recursively check its children
n.find_invalid_tokens(py, &node_validator)
} else {
// If the node is invalid, add it and its children to the list of invalid tokens
n.all_tokens(py)
}
})
.flatten()
.collect();
res
@@ -109,4 +112,4 @@ impl CharTrie {
root: self.root.clone_ref(py),
}
}
}
}