From aa26d98e2aabd55e2170fcfc936ee8f981d95e4c Mon Sep 17 00:00:00 2001 From: xmppftw Date: Sun, 4 Aug 2024 17:27:41 +0200 Subject: [PATCH] Check attr="" parse to Some("") in Option --- parsers/src/util/macro_tests.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/parsers/src/util/macro_tests.rs b/parsers/src/util/macro_tests.rs index d66a30d3..8e457f7c 100644 --- a/parsers/src/util/macro_tests.rs +++ b/parsers/src/util/macro_tests.rs @@ -1034,6 +1034,25 @@ fn optional_attribute_extract_positive_present() { } } +#[test] +fn optional_attribute_extract_positive_present_empty() { + #[allow(unused_imports)] + use std::{ + option::Option::{None, Some}, + result::Result::{Err, Ok}, + }; + match parse_str::( + "", + ) { + Ok(OptionalAttributeExtract { + contents: Some(contents), + }) => { + assert_eq!(contents, ""); + } + other => panic!("unexpected result: {:?}", other), + } +} + #[test] fn optional_attribute_extract_positive_absent() { #[allow(unused_imports)] @@ -1060,6 +1079,18 @@ fn optional_attribute_extract_roundtrip_present() { ) } +#[test] +fn optional_attribute_extract_roundtrip_present_empty() { + #[allow(unused_imports)] + use std::{ + option::Option::{None, Some}, + result::Result::{Err, Ok}, + }; + roundtrip_full::( + "", + ) +} + #[test] fn optional_attribute_extract_roundtrip_absent() { #[allow(unused_imports)]