diff options
Diffstat (limited to 'src/command.rs')
-rw-r--r-- | src/command.rs | 377 |
1 files changed, 239 insertions, 138 deletions
diff --git a/src/command.rs b/src/command.rs index fd449aa..deab0eb 100644 --- a/src/command.rs +++ b/src/command.rs @@ -320,22 +320,30 @@ mod tests { let mut mock_deserializer = MockDeserializer::new(); - mock_deserializer - .expect_de_text() - .returning(|_| { - Err(DeserializerError::UnexpectedEvent { - expected_event_name: "text".to_string(), - found_event: Event::Start(BytesStart::new("ptype")), + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer + .expect_de_text() + .returning(|_| { + Err(DeserializerError::UnexpectedEvent { + expected_event_name: "text".to_string(), + found_event: Event::Start(BytesStart::new("ptype")), + }) }) - }) - .times(1); + .times(1); + } - mock_deserializer - .expect_de_text() - .returning(|_| Ok("GLuint".to_string())) - .times(1); + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer + .expect_de_text() + .returning(|_| Ok("GLuint".to_string())) + .times(1); + } - mock_deserializer + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer .expect_de_tag_with::<String, DeserializerError, DeserializeWithFn<_, _, _>>() .with( eq("ptype"), @@ -346,33 +354,43 @@ mod tests func(&BytesStart::new(tag_name), deserializer) }) .times(1); + } - mock_deserializer - .expect_de_text() - .returning(|_| { - Err(DeserializerError::UnexpectedEvent { - expected_event_name: "text".to_string(), - found_event: Event::Start(BytesStart::new("name")), + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer + .expect_de_text() + .returning(|_| { + Err(DeserializerError::UnexpectedEvent { + expected_event_name: "text".to_string(), + found_event: Event::Start(BytesStart::new("name")), + }) }) - }) - .times(1); + .times(1); + } - mock_deserializer - .expect_de_text() - .returning(|_| Ok("glDoComplicatedThing".to_string())) - .times(1); + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer + .expect_de_text() + .returning(|_| Ok("glDoComplicatedThing".to_string())) + .times(1); + } - mock_deserializer - .expect_de_tag_with::<String, DeserializerError, DeserializeWithFn<_, _, _>>() - .with( - eq("name"), - function(|ignore_end| matches!(ignore_end, IgnoreEnd::No)), - always(), - ) - .returning(|deserializer, tag_name, _, func| { - func(&BytesStart::new(tag_name), deserializer) - }) - .times(1); + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer + .expect_de_tag_with::<String, DeserializerError, DeserializeWithFn<_, _, _>>() + .with( + eq("name"), + function(|ignore_end| matches!(ignore_end, IgnoreEnd::No)), + always(), + ) + .returning(|deserializer, tag_name, _, func| { + func(&BytesStart::new(tag_name), deserializer) + }) + .times(1); + } let prototype = Prototype::deserialize(&BytesStart::new("proto"), &mut mock_deserializer) @@ -387,12 +405,17 @@ mod tests { let mut mock_deserializer = MockDeserializer::new(); - mock_deserializer - .expect_de_text() - .returning(|_| Ok("void".to_string())) - .times(1); + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer + .expect_de_text() + .returning(|_| Ok("void".to_string())) + .times(1); + } - mock_deserializer + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer .expect_de_tag_with::<String, DeserializerError, DeserializeWithFn<_, _, _>>() .with( eq("ptype"), @@ -406,23 +429,32 @@ mod tests }) }) .times(1); + } - mock_deserializer - .expect_de_text() - .returning(|_| { - Err(DeserializerError::UnexpectedEvent { - expected_event_name: "text".to_string(), - found_event: Event::Start(BytesStart::new("name")), + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer + .expect_de_text() + .returning(|_| { + Err(DeserializerError::UnexpectedEvent { + expected_event_name: "text".to_string(), + found_event: Event::Start(BytesStart::new("name")), + }) }) - }) - .times(1); + .times(1); + } - mock_deserializer - .expect_de_text() - .returning(|_| Ok("glDoSomeThing".to_string())) - .times(1); + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer + .expect_de_text() + .returning(|_| Ok("glDoSomeThing".to_string())) + .times(1); + } - mock_deserializer + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer .expect_de_tag_with::<String, DeserializerError, DeserializeWithFn<_, _, _>>() .with( eq("name"), @@ -433,6 +465,7 @@ mod tests func(&BytesStart::new(tag_name), deserializer) }) .times(1); + } let prototype = Prototype::deserialize(&BytesStart::new("proto"), &mut mock_deserializer) @@ -447,22 +480,30 @@ mod tests { let mut mock_deserializer = MockDeserializer::new(); - mock_deserializer - .expect_de_text() - .returning(|_| { - Err(DeserializerError::UnexpectedEvent { - expected_event_name: "text".to_string(), - found_event: Event::Start(BytesStart::new("ptype")), + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer + .expect_de_text() + .returning(|_| { + Err(DeserializerError::UnexpectedEvent { + expected_event_name: "text".to_string(), + found_event: Event::Start(BytesStart::new("ptype")), + }) }) - }) - .times(1); + .times(1); + } - mock_deserializer - .expect_de_text() - .returning(|_| Ok("GLenum".to_string())) - .times(1); + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer + .expect_de_text() + .returning(|_| Ok("GLenum".to_string())) + .times(1); + } - mock_deserializer + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer .expect_de_tag_with::<String, DeserializerError, DeserializeWithFn<_, _, _>>() .with( eq("ptype"), @@ -473,23 +514,32 @@ mod tests func(&BytesStart::new(tag_name), deserializer) }) .times(1); + } - mock_deserializer - .expect_de_text() - .returning(|_| { - Err(DeserializerError::UnexpectedEvent { - expected_event_name: "text".to_string(), - found_event: Event::Start(BytesStart::new("name")), + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer + .expect_de_text() + .returning(|_| { + Err(DeserializerError::UnexpectedEvent { + expected_event_name: "text".to_string(), + found_event: Event::Start(BytesStart::new("name")), + }) }) - }) - .times(1); + .times(1); + } - mock_deserializer - .expect_de_text() - .returning(|_| Ok("value".to_string())) - .times(1); + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer + .expect_de_text() + .returning(|_| Ok("value".to_string())) + .times(1); + } - mock_deserializer + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer .expect_de_tag_with::<String, DeserializerError, DeserializeWithFn<_, _, _>>() .with( eq("name"), @@ -500,6 +550,7 @@ mod tests func(&BytesStart::new(tag_name), deserializer) }) .times(1); + } let parameter = Parameter::deserialize(&BytesStart::new("param"), &mut mock_deserializer) @@ -514,22 +565,29 @@ mod tests { let mut mock_deserializer = MockDeserializer::new(); - mock_deserializer - .expect_de_text() - .returning(|_| { - Err(DeserializerError::UnexpectedEvent { - expected_event_name: "text".to_string(), - found_event: Event::Start(BytesStart::new("ptype")), + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer + .expect_de_text() + .returning(|_| { + Err(DeserializerError::UnexpectedEvent { + expected_event_name: "text".to_string(), + found_event: Event::Start(BytesStart::new("ptype")), + }) }) - }) - .times(1); + .times(1); + } - mock_deserializer - .expect_de_text() - .returning(|_| Ok("GLchar".to_string())) - .times(1); + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer + .expect_de_text() + .returning(|_| Ok("GLchar".to_string())) + .times(1); + } - mock_deserializer + unsafe { + mock_deserializer .expect_de_tag_with::<String, DeserializerError, DeserializeWithFn<_, _, _>>() .with( eq("ptype"), @@ -540,18 +598,27 @@ mod tests func(&BytesStart::new(tag_name), deserializer) }) .times(1); + } - mock_deserializer - .expect_de_text() - .returning(|_| Ok("*".to_string())) - .times(1); + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer + .expect_de_text() + .returning(|_| Ok("*".to_string())) + .times(1); + } - mock_deserializer - .expect_de_text() - .returning(|_| Ok("source".to_string())) - .times(1); + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer + .expect_de_text() + .returning(|_| Ok("source".to_string())) + .times(1); + } - mock_deserializer + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer .expect_de_tag_with::<String, DeserializerError, DeserializeWithFn<_, _, _>>() .with( eq("name"), @@ -562,6 +629,7 @@ mod tests func(&BytesStart::new(tag_name), deserializer) }) .times(1); + } let parameter = Parameter::deserialize(&BytesStart::new("param"), &mut mock_deserializer) @@ -576,17 +644,25 @@ mod tests { let mut mock_deserializer = MockDeserializer::new(); - mock_deserializer - .expect_de_text() - .returning(|_| Ok("const".to_string())) - .times(1); + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer + .expect_de_text() + .returning(|_| Ok("const".to_string())) + .times(1); + } - mock_deserializer - .expect_de_text() - .returning(|_| Ok("GLchar".to_string())) - .times(1); + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer + .expect_de_text() + .returning(|_| Ok("GLchar".to_string())) + .times(1); + } - mock_deserializer + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer .expect_de_tag_with::<String, DeserializerError, DeserializeWithFn<_, _, _>>() .with( eq("ptype"), @@ -597,18 +673,27 @@ mod tests func(&BytesStart::new(tag_name), deserializer) }) .times(1); + } - mock_deserializer - .expect_de_text() - .returning(|_| Ok("*".to_string())) - .times(1); + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer + .expect_de_text() + .returning(|_| Ok("*".to_string())) + .times(1); + } - mock_deserializer - .expect_de_text() - .returning(|_| Ok("name".to_string())) - .times(1); + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer + .expect_de_text() + .returning(|_| Ok("name".to_string())) + .times(1); + } - mock_deserializer + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer .expect_de_tag_with::<String, DeserializerError, DeserializeWithFn<_, _, _>>() .with( eq("name"), @@ -619,6 +704,7 @@ mod tests func(&BytesStart::new(tag_name), deserializer) }) .times(1); + } let parameter = Parameter::deserialize(&BytesStart::new("param"), &mut mock_deserializer) @@ -633,12 +719,17 @@ mod tests { let mut mock_deserializer = MockDeserializer::new(); - mock_deserializer - .expect_de_text() - .returning(|_| Ok("void *".to_string())) - .times(1); + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer + .expect_de_text() + .returning(|_| Ok("void *".to_string())) + .times(1); + } - mock_deserializer + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer .expect_de_tag_with::<String, DeserializerError, DeserializeWithFn<_, _, _>>() .with( eq("ptype"), @@ -652,23 +743,32 @@ mod tests }) }) .times(1); + } - mock_deserializer - .expect_de_text() - .returning(|_| { - Err(DeserializerError::UnexpectedEvent { - expected_event_name: "text".to_string(), - found_event: Event::Start(BytesStart::new("name")), + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer + .expect_de_text() + .returning(|_| { + Err(DeserializerError::UnexpectedEvent { + expected_event_name: "text".to_string(), + found_event: Event::Start(BytesStart::new("name")), + }) }) - }) - .times(1); + .times(1); + } - mock_deserializer - .expect_de_text() - .returning(|_| Ok("pixels".to_string())) - .times(1); + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer + .expect_de_text() + .returning(|_| Ok("pixels".to_string())) + .times(1); + } - mock_deserializer + // SAFETY: No argument lifetime is mistreated + unsafe { + mock_deserializer .expect_de_tag_with::<String, DeserializerError, DeserializeWithFn<_, _, _>>() .with( eq("name"), @@ -679,6 +779,7 @@ mod tests func(&BytesStart::new(tag_name), deserializer) }) .times(1); + } let parameter = Parameter::deserialize(&BytesStart::new("param"), &mut mock_deserializer) |