Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/css/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ mod tests {
let doc = test_doc();
let root = doc.root_element().unwrap();
let result = eval(&doc, root, "table");
assert!(result.is_empty());
assert_eq!(result, [] as [NodeId; 0]);
}

#[test]
Expand Down Expand Up @@ -466,7 +466,7 @@ mod tests {
let doc = test_doc();
let root = doc.root_element().unwrap();
let result = eval(&doc, root, ".nonexistent");
assert!(result.is_empty());
assert_eq!(result, [] as [NodeId; 0]);
}

#[test]
Expand Down Expand Up @@ -495,7 +495,7 @@ mod tests {
let doc = test_doc();
let root = doc.root_element().unwrap();
let result = eval(&doc, root, "#nonexistent");
assert!(result.is_empty());
assert_eq!(result, [] as [NodeId; 0]);
}

#[test]
Expand Down Expand Up @@ -536,7 +536,7 @@ mod tests {
let doc = test_doc();
let root = doc.root_element().unwrap();
let result = eval(&doc, root, "[title]");
assert!(result.is_empty());
assert_eq!(result, [] as [NodeId; 0]);
}

#[test]
Expand All @@ -553,7 +553,7 @@ mod tests {
let doc = test_doc();
let root = doc.root_element().unwrap();
let result = eval(&doc, root, "[data-type=\"internal\"]");
assert!(result.is_empty());
assert_eq!(result, [] as [NodeId; 0]);
}

#[test]
Expand All @@ -570,7 +570,7 @@ mod tests {
let doc = test_doc();
let root = doc.root_element().unwrap();
let result = eval(&doc, root, "[href^=\"ftp\"]");
assert!(result.is_empty());
assert_eq!(result, [] as [NodeId; 0]);
}

#[test]
Expand All @@ -587,7 +587,7 @@ mod tests {
let doc = test_doc();
let root = doc.root_element().unwrap();
let result = eval(&doc, root, "[src$=\".jpg\"]");
assert!(result.is_empty());
assert_eq!(result, [] as [NodeId; 0]);
}

#[test]
Expand All @@ -604,7 +604,7 @@ mod tests {
let doc = test_doc();
let root = doc.root_element().unwrap();
let result = eval(&doc, root, "[href*=\"missing\"]");
assert!(result.is_empty());
assert_eq!(result, [] as [NodeId; 0]);
}

#[test]
Expand Down Expand Up @@ -632,7 +632,7 @@ mod tests {
let doc = test_doc();
let root = doc.root_element().unwrap();
let result = eval(&doc, root, "[lang|=\"de\"]");
assert!(result.is_empty());
assert_eq!(result, [] as [NodeId; 0]);
}

// ---------------------------------------------------------------
Expand Down Expand Up @@ -797,7 +797,7 @@ mod tests {
let root = doc.root_element().unwrap();
// li is NOT a direct child of div — it's a child of ul
let result = eval(&doc, root, "div > li");
assert!(result.is_empty());
assert_eq!(result, [] as [NodeId; 0]);
}

#[test]
Expand All @@ -816,7 +816,7 @@ mod tests {
let root = doc.root_element().unwrap();
// h1 is not immediately preceded by a <p>
let result = eval(&doc, root, "p + h1");
assert!(result.is_empty());
assert_eq!(result, [] as [NodeId; 0]);
}

#[test]
Expand All @@ -834,7 +834,7 @@ mod tests {
let root = doc.root_element().unwrap();
// h1 has no preceding sibling <a>
let result = eval(&doc, root, "a ~ h1");
assert!(result.is_empty());
assert_eq!(result, [] as [NodeId; 0]);
}

#[test]
Expand Down Expand Up @@ -937,7 +937,7 @@ mod tests {
let doc = test_doc();
let root = doc.root_element().unwrap();
let result = select(&doc, root, &group);
assert!(result.is_empty());
assert_eq!(result, [] as [NodeId; 0]);
}

#[test]
Expand All @@ -959,7 +959,7 @@ mod tests {
let doc = Document::parse_str("<root/>").unwrap();
let root = doc.root_element().unwrap();
let result = eval(&doc, root, "div");
assert!(result.is_empty());
assert_eq!(result, [] as [NodeId; 0]);
}

#[test]
Expand All @@ -971,7 +971,7 @@ mod tests {
let sidebar_nodes = eval(&doc, root, "#sidebar");
let sidebar = sidebar_nodes[0];
let result = eval(&doc, sidebar, "#main");
assert!(result.is_empty());
assert_eq!(result, [] as [NodeId; 0]);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/html/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1317,7 +1317,7 @@ mod tests {

// Should have body child (empty head is removed)
let children: Vec<_> = doc.children(html).collect();
assert!(!children.is_empty());
assert_ne!(children, [] as [NodeId; 0]);
// Body should contain the <p>
let body = children.last().unwrap();
assert_eq!(doc.node_name(*body), Some("body"));
Expand Down
6 changes: 1 addition & 5 deletions src/html5/tree_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1220,11 +1220,7 @@ impl<'a> TreeBuilder<'a> {
}

// EOF always uses normal rules.
if *token == Token::Eof {
return false;
}

true
*token != Token::Eof
}

#[allow(clippy::too_many_lines)]
Expand Down
2 changes: 1 addition & 1 deletion src/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ mod tests {
fn test_children_iterator_empty() {
let doc = Document::new();
let children: Vec<NodeId> = doc.children(doc.root()).collect();
assert!(children.is_empty());
assert_eq!(children, [] as [NodeId; 0]);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/xpath/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3023,7 +3023,7 @@ mod tests {
let ctx = XPathContext::new(&doc, root);
let result = ctx.evaluate(&expr).unwrap();
match &result {
XPathValue::NodeSet(ns) => assert!(ns.is_empty()),
XPathValue::NodeSet(ns) => assert_eq!(ns.as_slice(), []),
other => panic!("expected empty node-set, got {other:?}"),
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/xpath/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -986,13 +986,13 @@ mod tests {
#[test]
fn test_tokenize_empty_input() {
let tokens = tokenize("");
assert!(tokens.is_empty());
assert_eq!(tokens, [] as [Token; 0]);
}

#[test]
fn test_tokenize_whitespace_only() {
let tokens = tokenize(" \t\n ");
assert!(tokens.is_empty());
assert_eq!(tokens, [] as [Token; 0]);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/xpath/regex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ mod tests {
#[test]
fn test_tokenize_empty() {
let result: Vec<String> = tokenize("", ",");
assert!(result.is_empty());
assert_eq!(result, [] as [String; 0]);
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions tests/ffi_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ fn test_parse_error_message() {
let err = last_error();
assert!(err.is_some());
// Error message should contain something meaningful
assert!(!err.unwrap().is_empty());
assert_ne!(err.unwrap(), "");
}
}

Expand Down Expand Up @@ -1283,7 +1283,7 @@ fn test_dtd_validate_invalid() {
// Get error message
let msg = c_string_to_owned(xmloxide_validation_error_message(result, 0));
assert!(msg.is_some());
assert!(!msg.unwrap().is_empty());
assert_ne!(msg.unwrap(), "");

// Out of bounds returns null
let bad = xmloxide_validation_error_message(result, 999);
Expand Down