diff options
author | HampusM <hampus@hampusmat.com> | 2023-05-14 19:51:17 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2023-05-14 19:51:17 +0200 |
commit | ad142e9e749adf64642168c0d221b0cf47f149c7 (patch) | |
tree | 642308f9aec6032115c62bb6ae269fa37c3fc453 /src/test_utils.rs | |
parent | 4d46e44801d8ef40c8a2f4dea1d2c9088f2557a1 (diff) |
Diffstat (limited to 'src/test_utils.rs')
-rw-r--r-- | src/test_utils.rs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/test_utils.rs b/src/test_utils.rs new file mode 100644 index 0000000..0f80cb7 --- /dev/null +++ b/src/test_utils.rs @@ -0,0 +1,44 @@ +use std::convert::Infallible; + +use mockall::mock; +use xml_stinks::deserializer::{Deserializer, Error, IgnoreEnd, MaybeStatic}; +use xml_stinks::tagged::TagStart; +use xml_stinks::DeserializeTagged; + +mock! { + pub Deserializer {} + + impl Deserializer for Deserializer + { + fn de_tag<De: DeserializeTagged>( + &mut self, + tag_name: &str, + ignore_end: IgnoreEnd, + ) -> Result<De, Error<De::Error>>; + + fn de_tag_with<TOutput, Err, Func>( + &mut self, + tag_name: &str, + ignore_end: IgnoreEnd, + deserialize: Func, + ) -> Result<TOutput, Error<Err>> + where + TOutput: MaybeStatic, + Err: std::error::Error + Send + Sync + 'static, + Func: FnOnce(&TagStart, &mut MockDeserializer) -> Result<TOutput, Err> + MaybeStatic; + + fn de_tag_list<De, TagName>( + &mut self, + tag_name: Option<TagName> + ) -> Result<Vec<De>, Error<De::Error>> + where + De: DeserializeTagged, + TagName: AsRef<str> + MaybeStatic; + + fn de_text(&mut self) -> Result<String, Error<Infallible>>; + + fn skip_to_tag_start(&mut self, tag_name: &str) -> Result<(), Error<Infallible>>; + + fn skip_to_tag_end(&mut self, tag_name: &str) -> Result<(), Error<Infallible>>; + } +} |