1 // Copyright 2022 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4 // https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5 // <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
6 // option. This file may not be copied, modified, or distributed
7 // except according to those terms.
8 
9 #![cfg(feature = "serde")]
10 
11 use serde_test::Token;
12 use uguid::{guid, Guid};
13 
14 #[test]
test_serde()15 fn test_serde() {
16     let guid = guid!("01234567-89ab-cdef-0123-456789abcdef");
17 
18     serde_test::assert_tokens(
19         &guid,
20         &[Token::Str("01234567-89ab-cdef-0123-456789abcdef")],
21     );
22 
23     serde_test::assert_de_tokens_error::<Guid>(
24         &[Token::Str("1234")],
25         "GUID string has wrong length (expected 36 bytes)",
26     );
27 
28     serde_test::assert_de_tokens_error::<Guid>(
29         &[Token::U64(1234)],
30         "invalid type: integer `1234`, expected a string in the format \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"");
31 }
32