mirror of
https://github.com/odin-lang/Odin.git
synced 2026-07-11 02:19:30 +00:00
Fix whitespace normalize
This commit is contained in:
@@ -146,6 +146,7 @@ decode_xml :: proc(input: string, options := XML_Decode_Options{}, allocator :=
|
||||
for i in 0..<count {
|
||||
write_rune(&builder, decoded[i])
|
||||
}
|
||||
prev = decoded[count - 1]
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package test_core_xml
|
||||
|
||||
import "core:encoding/entity"
|
||||
import "core:encoding/xml"
|
||||
import "core:testing"
|
||||
import "core:strings"
|
||||
@@ -217,6 +218,29 @@ run_test :: proc(t: ^testing.T, test: TEST, loc := #caller_location) {
|
||||
}
|
||||
}
|
||||
|
||||
@(test)
|
||||
test_normalize_whitespace :: proc(t: ^testing.T) {
|
||||
s := "A & B"
|
||||
normalized_entity_decode, _ := entity.decode_xml(s, {.Normalize_Whitespace})
|
||||
defer delete(normalized_entity_decode)
|
||||
|
||||
testing.expect_value(t, normalized_entity_decode, "A & B")
|
||||
|
||||
s = `<hellope attr="A & B">A & B</hellope>`
|
||||
|
||||
opts := xml.Options{
|
||||
flags = {.Ignore_Unsupported, .Decode_SGML_Entities},
|
||||
}
|
||||
|
||||
doc, err := xml.parse_bytes(transmute([]byte)s, opts)
|
||||
defer xml.destroy(doc)
|
||||
assert(err == .None)
|
||||
|
||||
testing.expect_value(t, doc.elements[0].value[0], "A & B")
|
||||
attr := doc.elements[0].attribs
|
||||
testing.expect_value(t, attr[0].val, "A & B")
|
||||
}
|
||||
|
||||
@(private)
|
||||
doc_to_string :: proc(doc: ^xml.Document) -> (result: string) {
|
||||
/*
|
||||
@@ -298,4 +322,4 @@ doc_to_string :: proc(doc: ^xml.Document) -> (result: string) {
|
||||
|
||||
print(strings.to_writer(&buf), doc)
|
||||
return strings.clone(strings.to_string(buf))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user