Add unit text for eval_html / encoding.

This commit is contained in:
jcamiel 2023-05-11 11:40:49 +02:00
parent df9918bc40
commit a2d91cc197
No known key found for this signature in database
GPG Key ID: 07FF11CFD55356CC
5 changed files with 13 additions and 3 deletions

View File

@ -4,4 +4,5 @@
<span class="line"><span class="section-header">[Asserts]</span></span>
<span class="line"><span class="query-type">xpath</span> <span class="string">"normalize-space(//data)"</span> <span class="predicate-type">==</span> <span class="string">"café"</span></span>
<span class="line"><span class="query-type">xpath</span> <span class="string">"normalize-space(//data)"</span> <span class="predicate-type">==</span> <span class="string">"caf\u{e9}"</span></span>
<span class="line"><span class="query-type">bytes</span> <span class="predicate-type">==</span> hex,<span class="hex">3c646174613e636166c3a93c2f646174613e</span>;</span>
</span></span></code></pre>

View File

@ -4,3 +4,4 @@ HTTP 200
[Asserts]
xpath "normalize-space(//data)" == "café"
xpath "normalize-space(//data)" == "caf\u{e9}"
bytes == hex,3c646174613e636166c3a93c2f646174613e;

View File

@ -1 +1 @@
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/utf8"},"response":{"status":200,"asserts":[{"query":{"type":"xpath","expr":"normalize-space(//data)"},"predicate":{"type":"equal","value":"café"}},{"query":{"type":"xpath","expr":"normalize-space(//data)"},"predicate":{"type":"equal","value":"café"}}]}}]}
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/utf8"},"response":{"status":200,"asserts":[{"query":{"type":"xpath","expr":"normalize-space(//data)"},"predicate":{"type":"equal","value":"café"}},{"query":{"type":"xpath","expr":"normalize-space(//data)"},"predicate":{"type":"equal","value":"café"}},{"query":{"type":"bytes"},"predicate":{"type":"equal","value":"PGRhdGE+Y2Fmw6k8L2RhdGE+","encoding":"base64"}}]}}]}

View File

@ -1,3 +1,3 @@
#!/bin/bash
set -Eeuo pipefail
hurl tests_ok/utf8.hurl --verbose
hurl tests_ok/utf8.hurl --very-verbose

View File

@ -283,13 +283,21 @@ mod tests {
}
#[test]
fn test_cafe() {
fn test_cafe_xml() {
assert_eq!(
eval_xml("<data>café</data>", "normalize-space(//data)").unwrap(),
Value::String(String::from("café"))
);
}
#[test]
fn test_cafe_html() {
assert_eq!(
eval_html("<data>café</data>", "normalize-space(//data)").unwrap(),
Value::String(String::from("café"))
);
}
#[test]
fn test_html() {
let html = r#"<html>