We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It is useful to have at least a basic test for each generated struct to verify that yaserde works fine for all cases.
#[test] fn test_profile() { ser_de(tt::Profile::default()); } // mod utils: fn ser_de<T: YaSerialize + YaDeserialize>(value: T) { let ser = yaserde::ser::to_string(&value).unwrap(); println!("{}", ser); let _ = yaserde::de::from_str::<T>(&ser).unwrap(); }
As a bonus point all Option fields should have Some value and all Vecs should not be empty. To accomplish this we can generate something like
Option
Some
Vec
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tt", namespace = "tt: http://www.onvif.org/ver10/schema")] pub struct Profile { // User readable name of the profile. #[yaserde(prefix = "tt", rename = "Name")] pub name: Name, // Optional configuration of the Video input. #[yaserde(prefix = "tt", rename = "VideoSourceConfiguration")] pub video_source_configuration: Option<VideoSourceConfiguration>, ... etc } #[cfg(test)] fn create_test_profile() -> tt::Profile { tt::Profile { name: create_test_name(), video_source_configuration: Some(create_test_video_source_configuration()), ... etc } } #[test] fn test_profile() { ser_de(create_test_profile()); } #[derive(Default, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)] pub struct Name(pub String); #[cfg(test)] fn create_test_name() -> tt::Name { tt::Name("test Name".to_string()) } #[test] fn test_name() { ser_de(create_test_name()); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
It is useful to have at least a basic test for each generated struct to verify that yaserde works fine for all cases.
As a bonus point all
Option
fields should haveSome
value and allVec
s should not be empty. To accomplish this we can generate something likeThe text was updated successfully, but these errors were encountered: