Extend test to cover . and _, too

This commit is contained in:
Dirkjan Ochtman 2024-04-01 22:43:59 +02:00
parent 6b483b7e6d
commit 2b691c5131
2 changed files with 5 additions and 3 deletions

View File

@ -134,7 +134,9 @@ impl NamespaceMeta {
(NsState::Prefix, TokenTree::Ident(id)) => NsState::Eq {
prefix: id.to_string(),
},
(NsState::Eq { mut prefix }, TokenTree::Punct(punct)) if punct.as_char() == '-' => {
(NsState::Eq { mut prefix }, TokenTree::Punct(punct))
if punct.as_char() == '-' || punct.as_char() == '.' =>
{
prefix.push(punct.as_char());
NsState::Eq { prefix }
}

View File

@ -160,7 +160,7 @@ fn other_namespaces() {
}
#[derive(Debug, Eq, PartialEq, FromXml)]
#[xml(ns("URI", dashed-ns = "dashed"))]
#[xml(ns("URI", da_sh.ed-ns = "dashed"))]
struct DashedNs {
#[xml(ns("dashed"))]
element: String,
@ -169,7 +169,7 @@ struct DashedNs {
#[test]
fn dashed_ns() {
assert_eq!(
from_str("<DashedNs xmlns=\"URI\" xmlns:dashed-ns=\"dashed\"><dashed-ns:element>hello</dashed-ns:element></DashedNs>"),
from_str("<DashedNs xmlns=\"URI\" xmlns:da_sh.ed-ns=\"dashed\"><da_sh.ed-ns:element>hello</da_sh.ed-ns:element></DashedNs>"),
Ok(DashedNs { element: "hello".to_owned() })
);
}