1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, Default)]
pub struct Empty {}
#[cfg(test)]
mod tests {
use super::*;
use crate::serde::{from_slice, to_vec};
#[test]
fn empty_can_be_instantiated() {
let instance = Empty::default();
assert_eq!(instance, Empty {});
}
#[test]
fn empty_can_be_instantiated_serialized_and_deserialized() {
let instance = Empty {};
let serialized = to_vec(&instance).unwrap();
assert_eq!(serialized, b"{}");
let deserialized: Empty = from_slice(b"{}").unwrap();
assert_eq!(deserialized, instance);
let deserialized: Empty = from_slice(b"{\"stray\":\"data\"}").unwrap();
assert_eq!(deserialized, instance);
}
}