Ignore if_then_panic clippy lint
error: only a `panic!` in `if`-then statement
--> serde_derive/src/internals/ctxt.rs:58:9
|
58 | / if !thread::panicking() && self.errors.borrow().is_some() {
59 | | panic!("forgot to check for errors");
60 | | }
| |_________^ help: try: `assert!(!!thread::panicking() && self.errors.borrow().is_some(), "forgot to check for errors");`
|
note: the lint level is defined here
--> serde_derive/src/lib.rs:18:9
|
18 | #![deny(clippy::all, clippy::pedantic)]
| ^^^^^^^^^^^
= note: `#[deny(clippy::if_then_panic)]` implied by `#[deny(clippy::all)]`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
error: only a `panic!` in `if`-then statement
--> serde_test/src/assert.rs:73:5
|
73 | / if ser.remaining() > 0 {
74 | | panic!("{} remaining tokens", ser.remaining());
75 | | }
| |_____^ help: try: `assert!(!ser.remaining() > 0, "{} remaining tokens", ser.remaining());`
|
note: the lint level is defined here
--> serde_test/src/lib.rs:149:44
|
149 | #![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
| ^^^^^^
= note: `#[deny(clippy::if_then_panic)]` implied by `#[deny(clippy::all)]`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
error: only a `panic!` in `if`-then statement
--> serde_test/src/assert.rs:126:5
|
126 | / if ser.remaining() > 0 {
127 | | panic!("{} remaining tokens", ser.remaining());
128 | | }
| |_____^ help: try: `assert!(!ser.remaining() > 0, "{} remaining tokens", ser.remaining());`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
error: only a `panic!` in `if`-then statement
--> serde_test/src/assert.rs:166:5
|
166 | / if de.remaining() > 0 {
167 | | panic!("{} remaining tokens", de.remaining());
168 | | }
| |_____^ help: try: `assert!(!de.remaining() > 0, "{} remaining tokens", de.remaining());`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
error: only a `panic!` in `if`-then statement
--> serde_test/src/assert.rs:180:5
|
180 | / if de.remaining() > 0 {
181 | | panic!("{} remaining tokens", de.remaining());
182 | | }
| |_____^ help: try: `assert!(!de.remaining() > 0, "{} remaining tokens", de.remaining());`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
error: only a `panic!` in `if`-then statement
--> serde_test/src/assert.rs:220:5
|
220 | / if de.remaining() > 0 {
221 | | panic!("{} remaining tokens", de.remaining());
222 | | }
| |_____^ help: try: `assert!(!de.remaining() > 0, "{} remaining tokens", de.remaining());`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
error: only a `panic!` in `if`-then statement
--> test_suite/tests/test_de.rs:1349:9
|
1349 | / if de.remaining() > 0 {
1350 | | panic!("{} remaining tokens", de.remaining());
1351 | | }
| |_________^ help: try: `assert!(!de.remaining() > 0, "{} remaining tokens", de.remaining());`
|
= note: `-D clippy::if-then-panic` implied by `-D clippy::all`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
2021-09-29 23:27:28 -05:00
|
|
|
#![allow(
|
2022-01-20 23:38:31 -06:00
|
|
|
clippy::cast_lossless,
|
Ignore if_then_panic clippy lint
error: only a `panic!` in `if`-then statement
--> serde_derive/src/internals/ctxt.rs:58:9
|
58 | / if !thread::panicking() && self.errors.borrow().is_some() {
59 | | panic!("forgot to check for errors");
60 | | }
| |_________^ help: try: `assert!(!!thread::panicking() && self.errors.borrow().is_some(), "forgot to check for errors");`
|
note: the lint level is defined here
--> serde_derive/src/lib.rs:18:9
|
18 | #![deny(clippy::all, clippy::pedantic)]
| ^^^^^^^^^^^
= note: `#[deny(clippy::if_then_panic)]` implied by `#[deny(clippy::all)]`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
error: only a `panic!` in `if`-then statement
--> serde_test/src/assert.rs:73:5
|
73 | / if ser.remaining() > 0 {
74 | | panic!("{} remaining tokens", ser.remaining());
75 | | }
| |_____^ help: try: `assert!(!ser.remaining() > 0, "{} remaining tokens", ser.remaining());`
|
note: the lint level is defined here
--> serde_test/src/lib.rs:149:44
|
149 | #![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
| ^^^^^^
= note: `#[deny(clippy::if_then_panic)]` implied by `#[deny(clippy::all)]`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
error: only a `panic!` in `if`-then statement
--> serde_test/src/assert.rs:126:5
|
126 | / if ser.remaining() > 0 {
127 | | panic!("{} remaining tokens", ser.remaining());
128 | | }
| |_____^ help: try: `assert!(!ser.remaining() > 0, "{} remaining tokens", ser.remaining());`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
error: only a `panic!` in `if`-then statement
--> serde_test/src/assert.rs:166:5
|
166 | / if de.remaining() > 0 {
167 | | panic!("{} remaining tokens", de.remaining());
168 | | }
| |_____^ help: try: `assert!(!de.remaining() > 0, "{} remaining tokens", de.remaining());`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
error: only a `panic!` in `if`-then statement
--> serde_test/src/assert.rs:180:5
|
180 | / if de.remaining() > 0 {
181 | | panic!("{} remaining tokens", de.remaining());
182 | | }
| |_____^ help: try: `assert!(!de.remaining() > 0, "{} remaining tokens", de.remaining());`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
error: only a `panic!` in `if`-then statement
--> serde_test/src/assert.rs:220:5
|
220 | / if de.remaining() > 0 {
221 | | panic!("{} remaining tokens", de.remaining());
222 | | }
| |_____^ help: try: `assert!(!de.remaining() > 0, "{} remaining tokens", de.remaining());`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
error: only a `panic!` in `if`-then statement
--> test_suite/tests/test_de.rs:1349:9
|
1349 | / if de.remaining() > 0 {
1350 | | panic!("{} remaining tokens", de.remaining());
1351 | | }
| |_________^ help: try: `assert!(!de.remaining() > 0, "{} remaining tokens", de.remaining());`
|
= note: `-D clippy::if-then-panic` implied by `-D clippy::all`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
2021-09-29 23:27:28 -05:00
|
|
|
clippy::decimal_literal_representation,
|
Ignore derive_partial_eq_without_eq clippy lint
error: you are deriving `PartialEq` and can implement `Eq`
--> serde/src/de/value.rs:51:17
|
51 | #[derive(Clone, PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= note: `-D clippy::derive-partial-eq-without-eq` implied by `-D clippy::all`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> serde_derive/src/internals/case.rs:13:23
|
13 | #[derive(Copy, Clone, PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/unstable/mod.rs:6:21
|
6 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_ignored_any.rs:7:10
|
7 | #[derive(PartialEq, Debug, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_identifier.rs:7:34
|
7 | #[derive(Deserialize, Debug, PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_identifier.rs:24:34
|
24 | #[derive(Deserialize, Debug, PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_identifier.rs:41:34
|
41 | #[derive(Deserialize, Debug, PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_identifier.rs:59:34
|
59 | #[derive(Deserialize, Debug, PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_ser.rs:46:10
|
46 | #[derive(PartialEq, Debug)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_value.rs:11:34
|
11 | #[derive(Deserialize, Debug, PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_de_error.rs:15:23
|
15 | #[derive(Copy, Clone, PartialEq, Debug, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_de_error.rs:18:10
|
18 | #[derive(PartialEq, Debug, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_de_error.rs:26:10
|
26 | #[derive(PartialEq, Debug, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_de_error.rs:34:10
|
34 | #[derive(PartialEq, Debug, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_de_error.rs:41:19
|
41 | #[derive(Default, PartialEq, Debug)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_de_error.rs:60:10
|
60 | #[derive(PartialEq, Debug, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_borrow.rs:70:34
|
70 | #[derive(Deserialize, Debug, PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_borrow.rs:97:34
|
97 | #[derive(Deserialize, Debug, PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_borrow.rs:106:34
|
106 | #[derive(Deserialize, Debug, PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_de.rs:43:23
|
43 | #[derive(Copy, Clone, PartialEq, Debug, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_de.rs:46:10
|
46 | #[derive(PartialEq, Debug, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_de.rs:49:10
|
49 | #[derive(PartialEq, Debug, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_de.rs:52:10
|
52 | #[derive(PartialEq, Debug, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_de.rs:76:10
|
76 | #[derive(PartialEq, Debug, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_de.rs:82:10
|
82 | #[derive(PartialEq, Debug, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_de.rs:102:10
|
102 | #[derive(PartialEq, Debug, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_de.rs:109:19
|
109 | #[derive(Default, PartialEq, Debug)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_de.rs:128:10
|
128 | #[derive(PartialEq, Debug, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_de.rs:135:10
|
135 | #[derive(PartialEq, Debug)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_de.rs:185:14
|
185 | #[derive(PartialEq, Debug, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_macros.rs:25:17
|
25 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_macros.rs:110:17
|
110 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_macros.rs:580:21
|
580 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_macros.rs:607:21
|
607 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_macros.rs:681:21
|
681 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_macros.rs:684:21
|
684 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_macros.rs:816:21
|
816 | #[derive(Debug, PartialEq, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_macros.rs:976:21
|
976 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_macros.rs:1027:21
|
1027 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_macros.rs:1273:21
|
1273 | #[derive(Debug, PartialEq, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_macros.rs:1342:21
|
1342 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_macros.rs:1413:21
|
1413 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_macros.rs:1450:21
|
1450 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_macros.rs:1474:21
|
1474 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_macros.rs:1509:21
|
1509 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_macros.rs:1543:21
|
1543 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_macros.rs:1601:21
|
1601 | #[derive(Debug, PartialEq, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_macros.rs:1743:45
|
1743 | #[derive(Serialize, Deserialize, Debug, PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_macros.rs:1763:45
|
1763 | #[derive(Serialize, Deserialize, Debug, PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_macros.rs:1770:45
|
1770 | #[derive(Serialize, Deserialize, Debug, PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_macros.rs:1870:21
|
1870 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_macros.rs:1888:21
|
1888 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:108:17
|
108 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:124:17
|
124 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:147:17
|
147 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:344:17
|
344 | #[derive(Debug, PartialEq, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:394:17
|
394 | #[derive(Debug, PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:413:17
|
413 | #[derive(Debug, PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:458:17
|
458 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:512:17
|
512 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:520:17
|
520 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:528:17
|
528 | #[derive(Debug, PartialEq, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:647:17
|
647 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_gen.rs:835:17
|
835 | #[derive(Debug, PartialEq, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:675:17
|
675 | #[derive(Debug, PartialEq, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:1047:17
|
1047 | #[derive(Debug, PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:1050:17
|
1050 | #[derive(Debug, PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:1196:17
|
1196 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:1514:17
|
1514 | #[derive(Debug, PartialEq, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:1548:41
|
1548 | #[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:1566:41
|
1566 | #[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:1600:30
|
1600 | #[derive(Clone, Deserialize, PartialEq, Debug)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:1803:21
|
1803 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:1843:21
|
1843 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:1852:21
|
1852 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:1947:21
|
1947 | #[derive(Debug, PartialEq, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:2003:21
|
2003 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:2037:21
|
2037 | #[derive(Debug, PartialEq, Serialize, Deserialize)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:2074:45
|
2074 | #[derive(Deserialize, Serialize, Debug, PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:2080:45
|
2080 | #[derive(Deserialize, Serialize, Debug, PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:2157:38
|
2157 | #[derive(Serialize, Deserialize, PartialEq, Debug)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:2193:38
|
2193 | #[derive(Serialize, Deserialize, PartialEq, Debug)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:2200:38
|
2200 | #[derive(Serialize, Deserialize, PartialEq, Debug)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:2240:38
|
2240 | #[derive(Serialize, Deserialize, PartialEq, Debug)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:2279:38
|
2279 | #[derive(Serialize, Deserialize, PartialEq, Debug)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:2316:38
|
2316 | #[derive(Serialize, Deserialize, PartialEq, Debug)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:2359:38
|
2359 | #[derive(Serialize, Deserialize, PartialEq, Debug)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:2390:38
|
2390 | #[derive(Serialize, Deserialize, PartialEq, Debug)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:2421:38
|
2421 | #[derive(Serialize, Deserialize, PartialEq, Debug)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:2426:38
|
2426 | #[derive(Serialize, Deserialize, PartialEq, Debug)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:2483:38
|
2483 | #[derive(Serialize, Deserialize, PartialEq, Debug)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:2507:38
|
2507 | #[derive(Serialize, Deserialize, PartialEq, Debug)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:2521:27
|
2521 | #[derive(Deserialize, PartialEq, Debug)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:2552:27
|
2552 | #[derive(Deserialize, PartialEq, Debug)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:2558:27
|
2558 | #[derive(Deserialize, PartialEq, Debug)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:2586:14
|
2586 | #[derive(PartialEq, Debug)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:2624:27
|
2624 | #[derive(Deserialize, PartialEq, Debug)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
error: you are deriving `PartialEq` and can implement `Eq`
--> test_suite/tests/test_annotations.rs:2647:27
|
2647 | #[derive(Deserialize, PartialEq, Debug)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
2022-05-21 22:36:25 -05:00
|
|
|
clippy::derive_partial_eq_without_eq,
|
2021-11-04 22:21:43 -05:00
|
|
|
clippy::empty_enum,
|
2021-11-04 21:57:14 -05:00
|
|
|
clippy::manual_assert,
|
2021-11-04 22:21:43 -05:00
|
|
|
clippy::needless_pass_by_value,
|
Ignore uninlined_format_args pedantic clippy lint false positive
Clippy's suggested fix is not valid in 2018 edition. The
serde_test_suite crate can't be updated to 2021 edition yet because CI
of the serde crate on old toolchains needs to be able to parse all
manifests in the workspace, even if serde_test_suite is not being
compiled in those builds.
error: variables can be used directly in the `format!` string
--> test_suite/tests/test_de.rs:2260:23
|
2260 | Err(e) => panic!("tokens failed to deserialize: {}", e),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
= note: `-D clippy::uninlined-format-args` implied by `-D clippy::pedantic`
help: change this to
|
2260 - Err(e) => panic!("tokens failed to deserialize: {}", e),
2260 + Err(e) => panic!("tokens failed to deserialize: {e}"),
|
warning: unused variable: `e`
--> test_suite/tests/test_de.rs:2260:17
|
2260 | Err(e) => panic!("tokens failed to deserialize: {e}"),
| ^ help: if this is intentional, prefix it with an underscore: `_e`
|
= note: `#[warn(unused_variables)]` on by default
warning: panic message contains an unused formatting placeholder
--> test_suite/tests/test_de.rs:2260:61
|
2260 | Err(e) => panic!("tokens failed to deserialize: {e}"),
| ^^^
|
= note: this message is not used as a format string when given without arguments, but will be in Rust 2021
= note: `#[warn(non_fmt_panics)]` on by default
help: add the missing argument
|
2260 | Err(e) => panic!("tokens failed to deserialize: {e}", ...),
| +++++
help: or add a "{}" format string to use the message literally
|
2260 | Err(e) => panic!("{}", "tokens failed to deserialize: {e}"),
| +++++
2022-10-07 23:46:14 -05:00
|
|
|
clippy::uninlined_format_args,
|
Ignore if_then_panic clippy lint
error: only a `panic!` in `if`-then statement
--> serde_derive/src/internals/ctxt.rs:58:9
|
58 | / if !thread::panicking() && self.errors.borrow().is_some() {
59 | | panic!("forgot to check for errors");
60 | | }
| |_________^ help: try: `assert!(!!thread::panicking() && self.errors.borrow().is_some(), "forgot to check for errors");`
|
note: the lint level is defined here
--> serde_derive/src/lib.rs:18:9
|
18 | #![deny(clippy::all, clippy::pedantic)]
| ^^^^^^^^^^^
= note: `#[deny(clippy::if_then_panic)]` implied by `#[deny(clippy::all)]`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
error: only a `panic!` in `if`-then statement
--> serde_test/src/assert.rs:73:5
|
73 | / if ser.remaining() > 0 {
74 | | panic!("{} remaining tokens", ser.remaining());
75 | | }
| |_____^ help: try: `assert!(!ser.remaining() > 0, "{} remaining tokens", ser.remaining());`
|
note: the lint level is defined here
--> serde_test/src/lib.rs:149:44
|
149 | #![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
| ^^^^^^
= note: `#[deny(clippy::if_then_panic)]` implied by `#[deny(clippy::all)]`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
error: only a `panic!` in `if`-then statement
--> serde_test/src/assert.rs:126:5
|
126 | / if ser.remaining() > 0 {
127 | | panic!("{} remaining tokens", ser.remaining());
128 | | }
| |_____^ help: try: `assert!(!ser.remaining() > 0, "{} remaining tokens", ser.remaining());`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
error: only a `panic!` in `if`-then statement
--> serde_test/src/assert.rs:166:5
|
166 | / if de.remaining() > 0 {
167 | | panic!("{} remaining tokens", de.remaining());
168 | | }
| |_____^ help: try: `assert!(!de.remaining() > 0, "{} remaining tokens", de.remaining());`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
error: only a `panic!` in `if`-then statement
--> serde_test/src/assert.rs:180:5
|
180 | / if de.remaining() > 0 {
181 | | panic!("{} remaining tokens", de.remaining());
182 | | }
| |_____^ help: try: `assert!(!de.remaining() > 0, "{} remaining tokens", de.remaining());`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
error: only a `panic!` in `if`-then statement
--> serde_test/src/assert.rs:220:5
|
220 | / if de.remaining() > 0 {
221 | | panic!("{} remaining tokens", de.remaining());
222 | | }
| |_____^ help: try: `assert!(!de.remaining() > 0, "{} remaining tokens", de.remaining());`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
error: only a `panic!` in `if`-then statement
--> test_suite/tests/test_de.rs:1349:9
|
1349 | / if de.remaining() > 0 {
1350 | | panic!("{} remaining tokens", de.remaining());
1351 | | }
| |_________^ help: try: `assert!(!de.remaining() > 0, "{} remaining tokens", de.remaining());`
|
= note: `-D clippy::if-then-panic` implied by `-D clippy::all`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
2021-09-29 23:27:28 -05:00
|
|
|
clippy::unreadable_literal
|
|
|
|
)]
|
2019-12-15 21:52:59 -06:00
|
|
|
#![cfg_attr(feature = "unstable", feature(never_type))]
|
2018-01-13 16:28:12 -06:00
|
|
|
|
2023-07-25 23:06:57 -05:00
|
|
|
use fnv::FnvHasher;
|
2023-10-25 21:42:00 -05:00
|
|
|
use serde::de::value::{F32Deserializer, F64Deserializer};
|
2023-07-25 23:06:57 -05:00
|
|
|
use serde::de::{Deserialize, DeserializeOwned, Deserializer, IntoDeserializer};
|
|
|
|
use serde_derive::Deserialize;
|
|
|
|
use serde_test::{assert_de_tokens, Configure, Token};
|
2015-03-20 22:35:01 -05:00
|
|
|
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
|
2017-02-20 15:34:52 -06:00
|
|
|
use std::default::Default;
|
2018-06-03 02:27:26 -05:00
|
|
|
use std::ffi::{CStr, CString, OsString};
|
2019-07-16 11:16:50 -05:00
|
|
|
use std::fmt::Debug;
|
2023-07-02 23:11:09 -05:00
|
|
|
use std::iter;
|
2018-04-30 03:41:22 -05:00
|
|
|
use std::net;
|
2022-01-20 23:43:08 -06:00
|
|
|
use std::num::{
|
|
|
|
NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize, NonZeroU128,
|
2024-03-04 11:56:15 -06:00
|
|
|
NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize, Saturating, Wrapping,
|
2022-01-20 23:43:08 -06:00
|
|
|
};
|
2019-02-01 23:02:57 -06:00
|
|
|
use std::ops::Bound;
|
2018-04-30 03:41:22 -05:00
|
|
|
use std::path::{Path, PathBuf};
|
2018-05-07 13:16:40 -05:00
|
|
|
use std::rc::{Rc, Weak as RcWeak};
|
2019-07-16 11:16:50 -05:00
|
|
|
use std::sync::atomic::{
|
2019-07-16 12:00:44 -05:00
|
|
|
AtomicBool, AtomicI16, AtomicI32, AtomicI8, AtomicIsize, AtomicU16, AtomicU32, AtomicU8,
|
|
|
|
AtomicUsize, Ordering,
|
2019-07-16 11:16:50 -05:00
|
|
|
};
|
2019-07-17 11:11:35 -05:00
|
|
|
#[cfg(target_arch = "x86_64")]
|
2019-07-16 12:00:44 -05:00
|
|
|
use std::sync::atomic::{AtomicI64, AtomicU64};
|
2023-07-25 23:06:57 -05:00
|
|
|
use std::sync::{Arc, Weak as ArcWeak};
|
|
|
|
use std::time::{Duration, UNIX_EPOCH};
|
2015-03-03 23:19:55 -06:00
|
|
|
|
2017-02-24 17:32:13 -06:00
|
|
|
#[macro_use]
|
|
|
|
mod macros;
|
|
|
|
|
2015-03-03 23:19:55 -06:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2015-04-05 12:20:33 -05:00
|
|
|
#[derive(Copy, Clone, PartialEq, Debug, Deserialize)]
|
2015-07-04 14:11:20 -05:00
|
|
|
struct UnitStruct;
|
2015-03-03 23:19:55 -06:00
|
|
|
|
2023-07-09 18:31:40 -05:00
|
|
|
#[derive(Copy, Clone, PartialEq, Debug, Deserialize)]
|
|
|
|
struct GenericUnitStruct<const N: u8>;
|
|
|
|
|
2017-04-05 11:19:22 -05:00
|
|
|
#[derive(PartialEq, Debug, Deserialize)]
|
|
|
|
struct NewtypeStruct(i32);
|
|
|
|
|
2015-03-19 09:49:42 -05:00
|
|
|
#[derive(PartialEq, Debug, Deserialize)]
|
2015-07-04 14:11:20 -05:00
|
|
|
struct TupleStruct(i32, i32, i32);
|
2015-03-03 23:19:55 -06:00
|
|
|
|
2015-03-19 09:49:42 -05:00
|
|
|
#[derive(PartialEq, Debug, Deserialize)]
|
2015-07-04 14:11:20 -05:00
|
|
|
struct Struct {
|
2015-03-03 23:19:55 -06:00
|
|
|
a: i32,
|
|
|
|
b: i32,
|
2017-12-23 22:24:57 -06:00
|
|
|
#[serde(skip_deserializing)]
|
|
|
|
c: i32,
|
2015-03-03 23:19:55 -06:00
|
|
|
}
|
|
|
|
|
2017-02-20 15:34:52 -06:00
|
|
|
#[derive(PartialEq, Debug, Deserialize)]
|
|
|
|
#[serde(default)]
|
2017-02-20 19:03:38 -06:00
|
|
|
struct StructDefault<T> {
|
2017-02-20 15:34:52 -06:00
|
|
|
a: i32,
|
2017-02-20 19:03:38 -06:00
|
|
|
b: T,
|
2017-02-20 15:34:52 -06:00
|
|
|
}
|
|
|
|
|
2017-02-20 19:03:38 -06:00
|
|
|
impl Default for StructDefault<String> {
|
|
|
|
fn default() -> Self {
|
|
|
|
StructDefault {
|
2017-02-20 15:34:52 -06:00
|
|
|
a: 100,
|
|
|
|
b: "default".to_string(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-13 03:12:31 -06:00
|
|
|
#[derive(PartialEq, Debug, Deserialize)]
|
|
|
|
struct StructSkipAll {
|
2017-12-23 22:24:57 -06:00
|
|
|
#[serde(skip_deserializing)]
|
|
|
|
a: i32,
|
2017-01-13 03:12:31 -06:00
|
|
|
}
|
|
|
|
|
2017-12-06 14:07:16 -06:00
|
|
|
#[derive(PartialEq, Debug, Deserialize)]
|
|
|
|
#[serde(default)]
|
|
|
|
struct StructSkipDefault {
|
2017-12-23 22:24:57 -06:00
|
|
|
#[serde(skip_deserializing)]
|
|
|
|
a: i32,
|
2017-12-06 14:07:16 -06:00
|
|
|
}
|
|
|
|
|
2017-12-11 22:59:54 -06:00
|
|
|
#[derive(PartialEq, Debug, Deserialize)]
|
|
|
|
#[serde(default)]
|
|
|
|
struct StructSkipDefaultGeneric<T> {
|
2017-12-23 22:24:57 -06:00
|
|
|
#[serde(skip_deserializing)]
|
|
|
|
t: T,
|
2017-12-11 22:59:54 -06:00
|
|
|
}
|
|
|
|
|
2017-12-06 14:07:16 -06:00
|
|
|
impl Default for StructSkipDefault {
|
|
|
|
fn default() -> Self {
|
2017-12-23 22:13:08 -06:00
|
|
|
StructSkipDefault { a: 16 }
|
2017-12-06 14:07:16 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-13 03:12:31 -06:00
|
|
|
#[derive(PartialEq, Debug, Deserialize)]
|
|
|
|
#[serde(deny_unknown_fields)]
|
|
|
|
struct StructSkipAllDenyUnknown {
|
2017-12-23 22:24:57 -06:00
|
|
|
#[serde(skip_deserializing)]
|
|
|
|
a: i32,
|
2017-01-13 03:12:31 -06:00
|
|
|
}
|
|
|
|
|
2019-09-07 03:43:28 -05:00
|
|
|
#[derive(Default, PartialEq, Debug)]
|
|
|
|
struct NotDeserializable;
|
|
|
|
|
2015-03-19 09:49:42 -05:00
|
|
|
#[derive(PartialEq, Debug, Deserialize)]
|
2015-03-03 23:19:55 -06:00
|
|
|
enum Enum {
|
2017-01-13 01:35:39 -06:00
|
|
|
#[allow(dead_code)]
|
|
|
|
#[serde(skip_deserializing)]
|
|
|
|
Skipped,
|
2015-03-03 23:19:55 -06:00
|
|
|
Unit,
|
2015-07-30 09:54:55 -05:00
|
|
|
Simple(i32),
|
2015-03-03 23:19:55 -06:00
|
|
|
Seq(i32, i32, i32),
|
2017-12-23 22:13:08 -06:00
|
|
|
Map {
|
|
|
|
a: i32,
|
|
|
|
b: i32,
|
|
|
|
c: i32,
|
|
|
|
},
|
2019-09-07 03:43:28 -05:00
|
|
|
SimpleWithSkipped(#[serde(skip_deserializing)] NotDeserializable),
|
2015-03-03 23:19:55 -06:00
|
|
|
}
|
|
|
|
|
2018-09-10 11:25:02 -05:00
|
|
|
#[derive(PartialEq, Debug, Deserialize)]
|
|
|
|
enum EnumOther {
|
|
|
|
Unit,
|
|
|
|
#[serde(other)]
|
2018-09-12 01:00:08 -05:00
|
|
|
Other,
|
2018-09-10 11:25:02 -05:00
|
|
|
}
|
|
|
|
|
2019-06-27 12:07:06 -05:00
|
|
|
#[derive(PartialEq, Debug)]
|
|
|
|
struct IgnoredAny;
|
|
|
|
|
|
|
|
impl<'de> Deserialize<'de> for IgnoredAny {
|
|
|
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
|
|
|
where
|
|
|
|
D: Deserializer<'de>,
|
|
|
|
{
|
|
|
|
serde::de::IgnoredAny::deserialize(deserializer)?;
|
|
|
|
Ok(IgnoredAny)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-03 23:19:55 -06:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
#[track_caller]
|
2022-01-20 22:42:17 -06:00
|
|
|
fn test<'de, T>(value: T, tokens: &'de [Token])
|
|
|
|
where
|
|
|
|
T: Deserialize<'de> + PartialEq + Debug,
|
|
|
|
{
|
2022-01-20 19:51:41 -06:00
|
|
|
// Test ser/de roundtripping
|
|
|
|
assert_de_tokens(&value, tokens);
|
2017-10-18 01:15:35 -05:00
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
// Test that the tokens are ignorable
|
|
|
|
assert_de_tokens_ignore(tokens);
|
2015-03-03 23:19:55 -06:00
|
|
|
}
|
|
|
|
|
2018-05-07 13:16:40 -05:00
|
|
|
#[derive(Debug)]
|
|
|
|
struct SkipPartialEq<T>(T);
|
|
|
|
|
|
|
|
impl<'de, T> Deserialize<'de> for SkipPartialEq<T>
|
|
|
|
where
|
|
|
|
T: Deserialize<'de>,
|
|
|
|
{
|
|
|
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
|
|
|
where
|
|
|
|
D: Deserializer<'de>,
|
|
|
|
{
|
|
|
|
T::deserialize(deserializer).map(SkipPartialEq)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T> PartialEq for SkipPartialEq<T> {
|
|
|
|
fn eq(&self, _other: &Self) -> bool {
|
|
|
|
true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
#[track_caller]
|
2017-10-18 01:09:50 -05:00
|
|
|
fn assert_de_tokens_ignore(ignorable_tokens: &[Token]) {
|
2016-06-28 23:47:54 -05:00
|
|
|
#[derive(PartialEq, Debug, Deserialize)]
|
|
|
|
struct IgnoreBase {
|
|
|
|
a: i32,
|
|
|
|
}
|
2016-07-12 08:44:19 -05:00
|
|
|
|
2016-06-28 23:47:54 -05:00
|
|
|
// Embed the tokens to be ignored in the normal token
|
|
|
|
// stream for an IgnoreBase type
|
2017-04-13 14:28:23 -05:00
|
|
|
let concated_tokens: Vec<Token> = vec![
|
2017-04-19 15:06:31 -05:00
|
|
|
Token::Map { len: Some(2) },
|
2017-04-13 14:28:23 -05:00
|
|
|
Token::Str("a"),
|
|
|
|
Token::I32(1),
|
|
|
|
Token::Str("ignored"),
|
2018-11-21 03:13:17 -06:00
|
|
|
]
|
|
|
|
.into_iter()
|
2021-12-17 20:25:00 -06:00
|
|
|
.chain(ignorable_tokens.iter().copied())
|
2023-07-02 23:11:09 -05:00
|
|
|
.chain(iter::once(Token::MapEnd))
|
2018-08-07 00:40:28 -05:00
|
|
|
.collect();
|
2016-07-12 08:44:19 -05:00
|
|
|
|
2023-05-04 19:25:17 -05:00
|
|
|
let expected = IgnoreBase { a: 1 };
|
|
|
|
assert_de_tokens(&expected, &concated_tokens);
|
2016-06-28 23:47:54 -05:00
|
|
|
}
|
|
|
|
|
2015-03-03 23:19:55 -06:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
#[test]
|
|
|
|
fn test_bool() {
|
|
|
|
test(true, &[Token::Bool(true)]);
|
|
|
|
test(false, &[Token::Bool(false)]);
|
|
|
|
}
|
|
|
|
|
2022-01-20 22:42:17 -06:00
|
|
|
#[test]
|
|
|
|
fn test_i8() {
|
|
|
|
let test = test::<i8>;
|
|
|
|
|
|
|
|
// from signed
|
|
|
|
test(-128, &[Token::I8(-128)]);
|
|
|
|
test(-128, &[Token::I16(-128)]);
|
|
|
|
test(-128, &[Token::I32(-128)]);
|
|
|
|
test(-128, &[Token::I64(-128)]);
|
|
|
|
test(127, &[Token::I8(127)]);
|
|
|
|
test(127, &[Token::I16(127)]);
|
|
|
|
test(127, &[Token::I32(127)]);
|
|
|
|
test(127, &[Token::I64(127)]);
|
|
|
|
|
|
|
|
// from unsigned
|
|
|
|
test(0, &[Token::U8(0)]);
|
|
|
|
test(0, &[Token::U16(0)]);
|
|
|
|
test(0, &[Token::U32(0)]);
|
|
|
|
test(0, &[Token::U64(0)]);
|
|
|
|
test(127, &[Token::U8(127)]);
|
|
|
|
test(127, &[Token::U16(127)]);
|
|
|
|
test(127, &[Token::U32(127)]);
|
|
|
|
test(127, &[Token::U64(127)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_i16() {
|
|
|
|
let test = test::<i16>;
|
|
|
|
|
|
|
|
// from signed
|
|
|
|
test(-128, &[Token::I8(-128)]);
|
|
|
|
test(-32768, &[Token::I16(-32768)]);
|
|
|
|
test(-32768, &[Token::I32(-32768)]);
|
|
|
|
test(-32768, &[Token::I64(-32768)]);
|
|
|
|
test(127, &[Token::I8(127)]);
|
|
|
|
test(32767, &[Token::I16(32767)]);
|
|
|
|
test(32767, &[Token::I32(32767)]);
|
|
|
|
test(32767, &[Token::I64(32767)]);
|
|
|
|
|
|
|
|
// from unsigned
|
|
|
|
test(0, &[Token::U8(0)]);
|
|
|
|
test(0, &[Token::U16(0)]);
|
|
|
|
test(0, &[Token::U32(0)]);
|
|
|
|
test(0, &[Token::U64(0)]);
|
|
|
|
test(255, &[Token::U8(255)]);
|
|
|
|
test(32767, &[Token::U16(32767)]);
|
|
|
|
test(32767, &[Token::U32(32767)]);
|
|
|
|
test(32767, &[Token::U64(32767)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_i32() {
|
|
|
|
let test = test::<i32>;
|
|
|
|
|
|
|
|
// from signed
|
|
|
|
test(-128, &[Token::I8(-128)]);
|
|
|
|
test(-32768, &[Token::I16(-32768)]);
|
|
|
|
test(-2147483648, &[Token::I32(-2147483648)]);
|
|
|
|
test(-2147483648, &[Token::I64(-2147483648)]);
|
|
|
|
test(127, &[Token::I8(127)]);
|
|
|
|
test(32767, &[Token::I16(32767)]);
|
|
|
|
test(2147483647, &[Token::I32(2147483647)]);
|
|
|
|
test(2147483647, &[Token::I64(2147483647)]);
|
|
|
|
|
|
|
|
// from unsigned
|
|
|
|
test(0, &[Token::U8(0)]);
|
|
|
|
test(0, &[Token::U16(0)]);
|
|
|
|
test(0, &[Token::U32(0)]);
|
|
|
|
test(0, &[Token::U64(0)]);
|
|
|
|
test(255, &[Token::U8(255)]);
|
|
|
|
test(65535, &[Token::U16(65535)]);
|
|
|
|
test(2147483647, &[Token::U32(2147483647)]);
|
|
|
|
test(2147483647, &[Token::U64(2147483647)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_i64() {
|
|
|
|
let test = test::<i64>;
|
|
|
|
|
|
|
|
// from signed
|
|
|
|
test(-128, &[Token::I8(-128)]);
|
|
|
|
test(-32768, &[Token::I16(-32768)]);
|
|
|
|
test(-2147483648, &[Token::I32(-2147483648)]);
|
|
|
|
test(-9223372036854775808, &[Token::I64(-9223372036854775808)]);
|
|
|
|
test(127, &[Token::I8(127)]);
|
|
|
|
test(32767, &[Token::I16(32767)]);
|
|
|
|
test(2147483647, &[Token::I32(2147483647)]);
|
|
|
|
test(9223372036854775807, &[Token::I64(9223372036854775807)]);
|
|
|
|
|
|
|
|
// from unsigned
|
|
|
|
test(0, &[Token::U8(0)]);
|
|
|
|
test(0, &[Token::U16(0)]);
|
|
|
|
test(0, &[Token::U32(0)]);
|
|
|
|
test(0, &[Token::U64(0)]);
|
|
|
|
test(255, &[Token::U8(255)]);
|
|
|
|
test(65535, &[Token::U16(65535)]);
|
|
|
|
test(4294967295, &[Token::U32(4294967295)]);
|
|
|
|
test(9223372036854775807, &[Token::U64(9223372036854775807)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_i128() {
|
|
|
|
let test = test::<i128>;
|
|
|
|
|
|
|
|
// from signed
|
|
|
|
test(-128, &[Token::I8(-128)]);
|
|
|
|
test(-32768, &[Token::I16(-32768)]);
|
|
|
|
test(-2147483648, &[Token::I32(-2147483648)]);
|
|
|
|
test(-9223372036854775808, &[Token::I64(-9223372036854775808)]);
|
|
|
|
test(127, &[Token::I8(127)]);
|
|
|
|
test(32767, &[Token::I16(32767)]);
|
|
|
|
test(2147483647, &[Token::I32(2147483647)]);
|
|
|
|
test(9223372036854775807, &[Token::I64(9223372036854775807)]);
|
|
|
|
|
|
|
|
// from unsigned
|
|
|
|
test(0, &[Token::U8(0)]);
|
|
|
|
test(0, &[Token::U16(0)]);
|
|
|
|
test(0, &[Token::U32(0)]);
|
|
|
|
test(0, &[Token::U64(0)]);
|
|
|
|
test(255, &[Token::U8(255)]);
|
|
|
|
test(65535, &[Token::U16(65535)]);
|
|
|
|
test(4294967295, &[Token::U32(4294967295)]);
|
|
|
|
test(18446744073709551615, &[Token::U64(18446744073709551615)]);
|
|
|
|
}
|
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
#[test]
|
|
|
|
fn test_isize() {
|
2022-01-20 22:42:17 -06:00
|
|
|
let test = test::<isize>;
|
|
|
|
|
|
|
|
// from signed
|
|
|
|
test(-10, &[Token::I8(-10)]);
|
|
|
|
test(-10, &[Token::I16(-10)]);
|
|
|
|
test(-10, &[Token::I32(-10)]);
|
|
|
|
test(-10, &[Token::I64(-10)]);
|
|
|
|
test(10, &[Token::I8(10)]);
|
|
|
|
test(10, &[Token::I16(10)]);
|
|
|
|
test(10, &[Token::I32(10)]);
|
|
|
|
test(10, &[Token::I64(10)]);
|
|
|
|
|
|
|
|
// from unsigned
|
|
|
|
test(0, &[Token::U8(0)]);
|
|
|
|
test(0, &[Token::U16(0)]);
|
|
|
|
test(0, &[Token::U32(0)]);
|
|
|
|
test(0, &[Token::U64(0)]);
|
|
|
|
test(10, &[Token::U8(10)]);
|
|
|
|
test(10, &[Token::U16(10)]);
|
|
|
|
test(10, &[Token::U32(10)]);
|
|
|
|
test(10, &[Token::U64(10)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_u8() {
|
|
|
|
let test = test::<u8>;
|
|
|
|
|
|
|
|
// from signed
|
|
|
|
test(0, &[Token::I8(0)]);
|
|
|
|
test(0, &[Token::I16(0)]);
|
|
|
|
test(0, &[Token::I32(0)]);
|
|
|
|
test(0, &[Token::I64(0)]);
|
|
|
|
test(127, &[Token::I8(127)]);
|
|
|
|
test(255, &[Token::I16(255)]);
|
|
|
|
test(255, &[Token::I32(255)]);
|
|
|
|
test(255, &[Token::I64(255)]);
|
|
|
|
|
|
|
|
// from unsigned
|
|
|
|
test(0, &[Token::U8(0)]);
|
|
|
|
test(0, &[Token::U16(0)]);
|
|
|
|
test(0, &[Token::U32(0)]);
|
|
|
|
test(0, &[Token::U64(0)]);
|
|
|
|
test(255, &[Token::U8(255)]);
|
|
|
|
test(255, &[Token::U16(255)]);
|
|
|
|
test(255, &[Token::U32(255)]);
|
|
|
|
test(255, &[Token::U64(255)]);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2022-01-20 22:42:17 -06:00
|
|
|
fn test_u16() {
|
|
|
|
let test = test::<u16>;
|
|
|
|
|
|
|
|
// from signed
|
|
|
|
test(0, &[Token::I8(0)]);
|
|
|
|
test(0, &[Token::I16(0)]);
|
|
|
|
test(0, &[Token::I32(0)]);
|
|
|
|
test(0, &[Token::I64(0)]);
|
|
|
|
test(127, &[Token::I8(127)]);
|
|
|
|
test(32767, &[Token::I16(32767)]);
|
|
|
|
test(65535, &[Token::I32(65535)]);
|
|
|
|
test(65535, &[Token::I64(65535)]);
|
|
|
|
|
|
|
|
// from unsigned
|
|
|
|
test(0, &[Token::U8(0)]);
|
|
|
|
test(0, &[Token::U16(0)]);
|
|
|
|
test(0, &[Token::U32(0)]);
|
|
|
|
test(0, &[Token::U64(0)]);
|
|
|
|
test(255, &[Token::U8(255)]);
|
|
|
|
test(65535, &[Token::U16(65535)]);
|
|
|
|
test(65535, &[Token::U32(65535)]);
|
|
|
|
test(65535, &[Token::U64(65535)]);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2022-01-20 22:42:17 -06:00
|
|
|
fn test_u32() {
|
|
|
|
let test = test::<u32>;
|
|
|
|
|
|
|
|
// from signed
|
|
|
|
test(0, &[Token::I8(0)]);
|
|
|
|
test(0, &[Token::I16(0)]);
|
|
|
|
test(0, &[Token::I32(0)]);
|
|
|
|
test(0, &[Token::I64(0)]);
|
|
|
|
test(127, &[Token::I8(127)]);
|
|
|
|
test(32767, &[Token::I16(32767)]);
|
|
|
|
test(2147483647, &[Token::I32(2147483647)]);
|
|
|
|
test(4294967295, &[Token::I64(4294967295)]);
|
|
|
|
|
|
|
|
// from unsigned
|
|
|
|
test(0, &[Token::U8(0)]);
|
|
|
|
test(0, &[Token::U16(0)]);
|
|
|
|
test(0, &[Token::U32(0)]);
|
|
|
|
test(0, &[Token::U64(0)]);
|
|
|
|
test(255, &[Token::U8(255)]);
|
|
|
|
test(65535, &[Token::U16(65535)]);
|
|
|
|
test(4294967295, &[Token::U32(4294967295)]);
|
|
|
|
test(4294967295, &[Token::U64(4294967295)]);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2022-01-20 22:42:17 -06:00
|
|
|
fn test_u64() {
|
|
|
|
let test = test::<u64>;
|
|
|
|
|
|
|
|
// from signed
|
|
|
|
test(0, &[Token::I8(0)]);
|
|
|
|
test(0, &[Token::I16(0)]);
|
|
|
|
test(0, &[Token::I32(0)]);
|
|
|
|
test(0, &[Token::I64(0)]);
|
|
|
|
test(127, &[Token::I8(127)]);
|
|
|
|
test(32767, &[Token::I16(32767)]);
|
|
|
|
test(2147483647, &[Token::I32(2147483647)]);
|
|
|
|
test(9223372036854775807, &[Token::I64(9223372036854775807)]);
|
|
|
|
|
|
|
|
// from unsigned
|
|
|
|
test(0, &[Token::U8(0)]);
|
|
|
|
test(0, &[Token::U16(0)]);
|
|
|
|
test(0, &[Token::U32(0)]);
|
|
|
|
test(0, &[Token::U64(0)]);
|
|
|
|
test(255, &[Token::U8(255)]);
|
|
|
|
test(65535, &[Token::U16(65535)]);
|
|
|
|
test(4294967295, &[Token::U32(4294967295)]);
|
|
|
|
test(18446744073709551615, &[Token::U64(18446744073709551615)]);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2022-01-20 22:42:17 -06:00
|
|
|
fn test_u128() {
|
|
|
|
let test = test::<u128>;
|
|
|
|
|
|
|
|
// from signed
|
|
|
|
test(0, &[Token::I8(0)]);
|
|
|
|
test(0, &[Token::I16(0)]);
|
|
|
|
test(0, &[Token::I32(0)]);
|
|
|
|
test(0, &[Token::I64(0)]);
|
|
|
|
test(127, &[Token::I8(127)]);
|
|
|
|
test(32767, &[Token::I16(32767)]);
|
|
|
|
test(2147483647, &[Token::I32(2147483647)]);
|
|
|
|
test(9223372036854775807, &[Token::I64(9223372036854775807)]);
|
|
|
|
|
|
|
|
// from unsigned
|
|
|
|
test(0, &[Token::U8(0)]);
|
|
|
|
test(0, &[Token::U16(0)]);
|
|
|
|
test(0, &[Token::U32(0)]);
|
|
|
|
test(0, &[Token::U64(0)]);
|
|
|
|
test(255, &[Token::U8(255)]);
|
|
|
|
test(65535, &[Token::U16(65535)]);
|
|
|
|
test(4294967295, &[Token::U32(4294967295)]);
|
|
|
|
test(18446744073709551615, &[Token::U64(18446744073709551615)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_usize() {
|
|
|
|
let test = test::<usize>;
|
|
|
|
|
|
|
|
// from signed
|
|
|
|
test(0, &[Token::I8(0)]);
|
|
|
|
test(0, &[Token::I16(0)]);
|
|
|
|
test(0, &[Token::I32(0)]);
|
|
|
|
test(0, &[Token::I64(0)]);
|
|
|
|
test(10, &[Token::I8(10)]);
|
|
|
|
test(10, &[Token::I16(10)]);
|
|
|
|
test(10, &[Token::I32(10)]);
|
|
|
|
test(10, &[Token::I64(10)]);
|
|
|
|
|
|
|
|
// from unsigned
|
|
|
|
test(0, &[Token::U8(0)]);
|
|
|
|
test(0, &[Token::U16(0)]);
|
|
|
|
test(0, &[Token::U32(0)]);
|
|
|
|
test(0, &[Token::U64(0)]);
|
|
|
|
test(10, &[Token::U8(10)]);
|
|
|
|
test(10, &[Token::U16(10)]);
|
|
|
|
test(10, &[Token::U32(10)]);
|
|
|
|
test(10, &[Token::U64(10)]);
|
|
|
|
}
|
|
|
|
|
2022-01-20 23:43:08 -06:00
|
|
|
#[test]
|
|
|
|
fn test_nonzero_i8() {
|
|
|
|
let test = |value, tokens| test(NonZeroI8::new(value).unwrap(), tokens);
|
|
|
|
|
|
|
|
// from signed
|
|
|
|
test(-128, &[Token::I8(-128)]);
|
|
|
|
test(-128, &[Token::I16(-128)]);
|
|
|
|
test(-128, &[Token::I32(-128)]);
|
|
|
|
test(-128, &[Token::I64(-128)]);
|
|
|
|
test(127, &[Token::I8(127)]);
|
|
|
|
test(127, &[Token::I16(127)]);
|
|
|
|
test(127, &[Token::I32(127)]);
|
|
|
|
test(127, &[Token::I64(127)]);
|
|
|
|
|
|
|
|
// from unsigned
|
|
|
|
test(1, &[Token::U8(1)]);
|
|
|
|
test(1, &[Token::U16(1)]);
|
|
|
|
test(1, &[Token::U32(1)]);
|
|
|
|
test(1, &[Token::U64(1)]);
|
|
|
|
test(127, &[Token::U8(127)]);
|
|
|
|
test(127, &[Token::U16(127)]);
|
|
|
|
test(127, &[Token::U32(127)]);
|
|
|
|
test(127, &[Token::U64(127)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_nonzero_i16() {
|
|
|
|
let test = |value, tokens| test(NonZeroI16::new(value).unwrap(), tokens);
|
|
|
|
|
|
|
|
// from signed
|
|
|
|
test(-128, &[Token::I8(-128)]);
|
|
|
|
test(-32768, &[Token::I16(-32768)]);
|
|
|
|
test(-32768, &[Token::I32(-32768)]);
|
|
|
|
test(-32768, &[Token::I64(-32768)]);
|
|
|
|
test(127, &[Token::I8(127)]);
|
|
|
|
test(32767, &[Token::I16(32767)]);
|
|
|
|
test(32767, &[Token::I32(32767)]);
|
|
|
|
test(32767, &[Token::I64(32767)]);
|
|
|
|
|
|
|
|
// from unsigned
|
|
|
|
test(1, &[Token::U8(1)]);
|
|
|
|
test(1, &[Token::U16(1)]);
|
|
|
|
test(1, &[Token::U32(1)]);
|
|
|
|
test(1, &[Token::U64(1)]);
|
|
|
|
test(255, &[Token::U8(255)]);
|
|
|
|
test(32767, &[Token::U16(32767)]);
|
|
|
|
test(32767, &[Token::U32(32767)]);
|
|
|
|
test(32767, &[Token::U64(32767)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_nonzero_i32() {
|
|
|
|
let test = |value, tokens| test(NonZeroI32::new(value).unwrap(), tokens);
|
|
|
|
|
|
|
|
// from signed
|
|
|
|
test(-128, &[Token::I8(-128)]);
|
|
|
|
test(-32768, &[Token::I16(-32768)]);
|
|
|
|
test(-2147483648, &[Token::I32(-2147483648)]);
|
|
|
|
test(-2147483648, &[Token::I64(-2147483648)]);
|
|
|
|
test(127, &[Token::I8(127)]);
|
|
|
|
test(32767, &[Token::I16(32767)]);
|
|
|
|
test(2147483647, &[Token::I32(2147483647)]);
|
|
|
|
test(2147483647, &[Token::I64(2147483647)]);
|
|
|
|
|
|
|
|
// from unsigned
|
|
|
|
test(1, &[Token::U8(1)]);
|
|
|
|
test(1, &[Token::U16(1)]);
|
|
|
|
test(1, &[Token::U32(1)]);
|
|
|
|
test(1, &[Token::U64(1)]);
|
|
|
|
test(255, &[Token::U8(255)]);
|
|
|
|
test(65535, &[Token::U16(65535)]);
|
|
|
|
test(2147483647, &[Token::U32(2147483647)]);
|
|
|
|
test(2147483647, &[Token::U64(2147483647)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_nonzero_i64() {
|
|
|
|
let test = |value, tokens| test(NonZeroI64::new(value).unwrap(), tokens);
|
|
|
|
|
|
|
|
// from signed
|
|
|
|
test(-128, &[Token::I8(-128)]);
|
|
|
|
test(-32768, &[Token::I16(-32768)]);
|
|
|
|
test(-2147483648, &[Token::I32(-2147483648)]);
|
|
|
|
test(-9223372036854775808, &[Token::I64(-9223372036854775808)]);
|
|
|
|
test(127, &[Token::I8(127)]);
|
|
|
|
test(32767, &[Token::I16(32767)]);
|
|
|
|
test(2147483647, &[Token::I32(2147483647)]);
|
|
|
|
test(9223372036854775807, &[Token::I64(9223372036854775807)]);
|
|
|
|
|
|
|
|
// from unsigned
|
|
|
|
test(1, &[Token::U8(1)]);
|
|
|
|
test(1, &[Token::U16(1)]);
|
|
|
|
test(1, &[Token::U32(1)]);
|
|
|
|
test(1, &[Token::U64(1)]);
|
|
|
|
test(255, &[Token::U8(255)]);
|
|
|
|
test(65535, &[Token::U16(65535)]);
|
|
|
|
test(4294967295, &[Token::U32(4294967295)]);
|
|
|
|
test(9223372036854775807, &[Token::U64(9223372036854775807)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_nonzero_i128() {
|
|
|
|
let test = |value, tokens| test(NonZeroI128::new(value).unwrap(), tokens);
|
|
|
|
|
|
|
|
// from signed
|
|
|
|
test(-128, &[Token::I8(-128)]);
|
|
|
|
test(-32768, &[Token::I16(-32768)]);
|
|
|
|
test(-2147483648, &[Token::I32(-2147483648)]);
|
|
|
|
test(-9223372036854775808, &[Token::I64(-9223372036854775808)]);
|
|
|
|
test(127, &[Token::I8(127)]);
|
|
|
|
test(32767, &[Token::I16(32767)]);
|
|
|
|
test(2147483647, &[Token::I32(2147483647)]);
|
|
|
|
test(9223372036854775807, &[Token::I64(9223372036854775807)]);
|
|
|
|
|
|
|
|
// from unsigned
|
|
|
|
test(1, &[Token::U8(1)]);
|
|
|
|
test(1, &[Token::U16(1)]);
|
|
|
|
test(1, &[Token::U32(1)]);
|
|
|
|
test(1, &[Token::U64(1)]);
|
|
|
|
test(255, &[Token::U8(255)]);
|
|
|
|
test(65535, &[Token::U16(65535)]);
|
|
|
|
test(4294967295, &[Token::U32(4294967295)]);
|
|
|
|
test(18446744073709551615, &[Token::U64(18446744073709551615)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_nonzero_isize() {
|
|
|
|
let test = |value, tokens| test(NonZeroIsize::new(value).unwrap(), tokens);
|
|
|
|
|
|
|
|
// from signed
|
|
|
|
test(-10, &[Token::I8(-10)]);
|
|
|
|
test(-10, &[Token::I16(-10)]);
|
|
|
|
test(-10, &[Token::I32(-10)]);
|
|
|
|
test(-10, &[Token::I64(-10)]);
|
|
|
|
test(10, &[Token::I8(10)]);
|
|
|
|
test(10, &[Token::I16(10)]);
|
|
|
|
test(10, &[Token::I32(10)]);
|
|
|
|
test(10, &[Token::I64(10)]);
|
|
|
|
|
|
|
|
// from unsigned
|
|
|
|
test(1, &[Token::U8(1)]);
|
|
|
|
test(1, &[Token::U16(1)]);
|
|
|
|
test(1, &[Token::U32(1)]);
|
|
|
|
test(1, &[Token::U64(1)]);
|
|
|
|
test(10, &[Token::U8(10)]);
|
|
|
|
test(10, &[Token::U16(10)]);
|
|
|
|
test(10, &[Token::U32(10)]);
|
|
|
|
test(10, &[Token::U64(10)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_nonzero_u8() {
|
|
|
|
let test = |value, tokens| test(NonZeroU8::new(value).unwrap(), tokens);
|
|
|
|
|
|
|
|
// from signed
|
|
|
|
test(1, &[Token::I8(1)]);
|
|
|
|
test(1, &[Token::I16(1)]);
|
|
|
|
test(1, &[Token::I32(1)]);
|
|
|
|
test(1, &[Token::I64(1)]);
|
|
|
|
test(127, &[Token::I8(127)]);
|
|
|
|
test(255, &[Token::I16(255)]);
|
|
|
|
test(255, &[Token::I32(255)]);
|
|
|
|
test(255, &[Token::I64(255)]);
|
|
|
|
|
|
|
|
// from unsigned
|
|
|
|
test(1, &[Token::U8(1)]);
|
|
|
|
test(1, &[Token::U16(1)]);
|
|
|
|
test(1, &[Token::U32(1)]);
|
|
|
|
test(1, &[Token::U64(1)]);
|
|
|
|
test(255, &[Token::U8(255)]);
|
|
|
|
test(255, &[Token::U16(255)]);
|
|
|
|
test(255, &[Token::U32(255)]);
|
|
|
|
test(255, &[Token::U64(255)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_nonzero_u16() {
|
|
|
|
let test = |value, tokens| test(NonZeroU16::new(value).unwrap(), tokens);
|
|
|
|
|
|
|
|
// from signed
|
|
|
|
test(1, &[Token::I8(1)]);
|
|
|
|
test(1, &[Token::I16(1)]);
|
|
|
|
test(1, &[Token::I32(1)]);
|
|
|
|
test(1, &[Token::I64(1)]);
|
|
|
|
test(127, &[Token::I8(127)]);
|
|
|
|
test(32767, &[Token::I16(32767)]);
|
|
|
|
test(65535, &[Token::I32(65535)]);
|
|
|
|
test(65535, &[Token::I64(65535)]);
|
|
|
|
|
|
|
|
// from unsigned
|
|
|
|
test(1, &[Token::U8(1)]);
|
|
|
|
test(1, &[Token::U16(1)]);
|
|
|
|
test(1, &[Token::U32(1)]);
|
|
|
|
test(1, &[Token::U64(1)]);
|
|
|
|
test(255, &[Token::U8(255)]);
|
|
|
|
test(65535, &[Token::U16(65535)]);
|
|
|
|
test(65535, &[Token::U32(65535)]);
|
|
|
|
test(65535, &[Token::U64(65535)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_nonzero_u32() {
|
|
|
|
let test = |value, tokens| test(NonZeroU32::new(value).unwrap(), tokens);
|
|
|
|
|
|
|
|
// from signed
|
|
|
|
test(1, &[Token::I8(1)]);
|
|
|
|
test(1, &[Token::I16(1)]);
|
|
|
|
test(1, &[Token::I32(1)]);
|
|
|
|
test(1, &[Token::I64(1)]);
|
|
|
|
test(127, &[Token::I8(127)]);
|
|
|
|
test(32767, &[Token::I16(32767)]);
|
|
|
|
test(2147483647, &[Token::I32(2147483647)]);
|
|
|
|
test(4294967295, &[Token::I64(4294967295)]);
|
|
|
|
|
|
|
|
// from unsigned
|
|
|
|
test(1, &[Token::U8(1)]);
|
|
|
|
test(1, &[Token::U16(1)]);
|
|
|
|
test(1, &[Token::U32(1)]);
|
|
|
|
test(1, &[Token::U64(1)]);
|
|
|
|
test(255, &[Token::U8(255)]);
|
|
|
|
test(65535, &[Token::U16(65535)]);
|
|
|
|
test(4294967295, &[Token::U32(4294967295)]);
|
|
|
|
test(4294967295, &[Token::U64(4294967295)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_nonzero_u64() {
|
|
|
|
let test = |value, tokens| test(NonZeroU64::new(value).unwrap(), tokens);
|
|
|
|
|
|
|
|
// from signed
|
|
|
|
test(1, &[Token::I8(1)]);
|
|
|
|
test(1, &[Token::I16(1)]);
|
|
|
|
test(1, &[Token::I32(1)]);
|
|
|
|
test(1, &[Token::I64(1)]);
|
|
|
|
test(127, &[Token::I8(127)]);
|
|
|
|
test(32767, &[Token::I16(32767)]);
|
|
|
|
test(2147483647, &[Token::I32(2147483647)]);
|
|
|
|
test(9223372036854775807, &[Token::I64(9223372036854775807)]);
|
|
|
|
|
|
|
|
// from unsigned
|
|
|
|
test(1, &[Token::U8(1)]);
|
|
|
|
test(1, &[Token::U16(1)]);
|
|
|
|
test(1, &[Token::U32(1)]);
|
|
|
|
test(1, &[Token::U64(1)]);
|
|
|
|
test(255, &[Token::U8(255)]);
|
|
|
|
test(65535, &[Token::U16(65535)]);
|
|
|
|
test(4294967295, &[Token::U32(4294967295)]);
|
|
|
|
test(18446744073709551615, &[Token::U64(18446744073709551615)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_nonzero_u128() {
|
|
|
|
let test = |value, tokens| test(NonZeroU128::new(value).unwrap(), tokens);
|
|
|
|
|
|
|
|
// from signed
|
|
|
|
test(1, &[Token::I8(1)]);
|
|
|
|
test(1, &[Token::I16(1)]);
|
|
|
|
test(1, &[Token::I32(1)]);
|
|
|
|
test(1, &[Token::I64(1)]);
|
|
|
|
test(127, &[Token::I8(127)]);
|
|
|
|
test(32767, &[Token::I16(32767)]);
|
|
|
|
test(2147483647, &[Token::I32(2147483647)]);
|
|
|
|
test(9223372036854775807, &[Token::I64(9223372036854775807)]);
|
|
|
|
|
|
|
|
// from unsigned
|
|
|
|
test(1, &[Token::U8(1)]);
|
|
|
|
test(1, &[Token::U16(1)]);
|
|
|
|
test(1, &[Token::U32(1)]);
|
|
|
|
test(1, &[Token::U64(1)]);
|
|
|
|
test(255, &[Token::U8(255)]);
|
|
|
|
test(65535, &[Token::U16(65535)]);
|
|
|
|
test(4294967295, &[Token::U32(4294967295)]);
|
|
|
|
test(18446744073709551615, &[Token::U64(18446744073709551615)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_nonzero_usize() {
|
|
|
|
let test = |value, tokens| test(NonZeroUsize::new(value).unwrap(), tokens);
|
|
|
|
|
|
|
|
// from signed
|
|
|
|
test(1, &[Token::I8(1)]);
|
|
|
|
test(1, &[Token::I16(1)]);
|
|
|
|
test(1, &[Token::I32(1)]);
|
|
|
|
test(1, &[Token::I64(1)]);
|
|
|
|
test(10, &[Token::I8(10)]);
|
|
|
|
test(10, &[Token::I16(10)]);
|
|
|
|
test(10, &[Token::I32(10)]);
|
|
|
|
test(10, &[Token::I64(10)]);
|
|
|
|
|
|
|
|
// from unsigned
|
|
|
|
test(1, &[Token::U8(1)]);
|
|
|
|
test(1, &[Token::U16(1)]);
|
|
|
|
test(1, &[Token::U32(1)]);
|
|
|
|
test(1, &[Token::U64(1)]);
|
|
|
|
test(10, &[Token::U8(10)]);
|
|
|
|
test(10, &[Token::U16(10)]);
|
|
|
|
test(10, &[Token::U32(10)]);
|
|
|
|
test(10, &[Token::U64(10)]);
|
|
|
|
}
|
|
|
|
|
2022-01-20 22:42:17 -06:00
|
|
|
#[test]
|
|
|
|
fn test_f32() {
|
|
|
|
let test = test::<f32>;
|
|
|
|
|
|
|
|
test(1.11, &[Token::F32(1.11)]);
|
|
|
|
test(1.11, &[Token::F64(1.11)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_f64() {
|
|
|
|
let test = test::<f64>;
|
|
|
|
|
|
|
|
test(1.11f32 as f64, &[Token::F32(1.11)]);
|
|
|
|
test(1.11, &[Token::F64(1.11)]);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
2023-10-25 21:42:00 -05:00
|
|
|
#[test]
|
|
|
|
fn test_nan() {
|
|
|
|
let f32_deserializer = F32Deserializer::<serde::de::value::Error>::new;
|
|
|
|
let f64_deserializer = F64Deserializer::<serde::de::value::Error>::new;
|
|
|
|
|
|
|
|
let pos_f32_nan = f32_deserializer(f32::NAN.copysign(1.0));
|
|
|
|
let pos_f64_nan = f64_deserializer(f64::NAN.copysign(1.0));
|
|
|
|
assert!(f32::deserialize(pos_f32_nan).unwrap().is_sign_positive());
|
|
|
|
assert!(f32::deserialize(pos_f64_nan).unwrap().is_sign_positive());
|
|
|
|
assert!(f64::deserialize(pos_f32_nan).unwrap().is_sign_positive());
|
|
|
|
assert!(f64::deserialize(pos_f64_nan).unwrap().is_sign_positive());
|
|
|
|
|
|
|
|
let neg_f32_nan = f32_deserializer(f32::NAN.copysign(-1.0));
|
|
|
|
let neg_f64_nan = f64_deserializer(f64::NAN.copysign(-1.0));
|
|
|
|
assert!(f32::deserialize(neg_f32_nan).unwrap().is_sign_negative());
|
|
|
|
assert!(f32::deserialize(neg_f64_nan).unwrap().is_sign_negative());
|
|
|
|
assert!(f64::deserialize(neg_f32_nan).unwrap().is_sign_negative());
|
|
|
|
assert!(f64::deserialize(neg_f64_nan).unwrap().is_sign_negative());
|
|
|
|
}
|
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
#[test]
|
|
|
|
fn test_char() {
|
|
|
|
test('a', &[Token::Char('a')]);
|
|
|
|
test('a', &[Token::Str("a")]);
|
|
|
|
test('a', &[Token::String("a")]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_string() {
|
|
|
|
test("abc".to_owned(), &[Token::Str("abc")]);
|
|
|
|
test("abc".to_owned(), &[Token::String("abc")]);
|
|
|
|
test("a".to_owned(), &[Token::Char('a')]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_option() {
|
|
|
|
test(None::<i32>, &[Token::Unit]);
|
|
|
|
test(None::<i32>, &[Token::None]);
|
2022-01-20 21:24:35 -06:00
|
|
|
test(Some(1), &[Token::Some, Token::I32(1)]);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_result() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
Ok::<i32, i32>(0),
|
|
|
|
&[
|
|
|
|
Token::Enum { name: "Result" },
|
|
|
|
Token::Str("Ok"),
|
|
|
|
Token::I32(0),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
Err::<i32, i32>(1),
|
|
|
|
&[
|
|
|
|
Token::Enum { name: "Result" },
|
|
|
|
Token::Str("Err"),
|
|
|
|
Token::I32(1),
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_unit() {
|
|
|
|
test((), &[Token::Unit]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_unit_struct() {
|
|
|
|
test(UnitStruct, &[Token::Unit]);
|
2022-01-20 21:24:35 -06:00
|
|
|
test(UnitStruct, &[Token::UnitStruct { name: "UnitStruct" }]);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
2023-07-09 18:31:40 -05:00
|
|
|
#[test]
|
|
|
|
fn test_generic_unit_struct() {
|
|
|
|
test(GenericUnitStruct::<8>, &[Token::Unit]);
|
|
|
|
test(
|
|
|
|
GenericUnitStruct::<8>,
|
|
|
|
&[Token::UnitStruct {
|
|
|
|
name: "GenericUnitStruct",
|
|
|
|
}],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
#[test]
|
|
|
|
fn test_newtype_struct() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
NewtypeStruct(1),
|
|
|
|
&[
|
|
|
|
Token::NewtypeStruct {
|
|
|
|
name: "NewtypeStruct",
|
|
|
|
},
|
|
|
|
Token::I32(1),
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_tuple_struct() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
TupleStruct(1, 2, 3),
|
|
|
|
&[
|
|
|
|
Token::Seq { len: Some(3) },
|
2015-03-03 23:19:55 -06:00
|
|
|
Token::I32(1),
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::I32(2),
|
|
|
|
Token::I32(3),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::SeqEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
TupleStruct(1, 2, 3),
|
|
|
|
&[
|
|
|
|
Token::Seq { len: None },
|
2015-08-27 22:01:09 -05:00
|
|
|
Token::I32(1),
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::I32(2),
|
|
|
|
Token::I32(3),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::SeqEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
TupleStruct(1, 2, 3),
|
|
|
|
&[
|
|
|
|
Token::TupleStruct {
|
|
|
|
name: "TupleStruct",
|
|
|
|
len: 3,
|
|
|
|
},
|
2017-04-05 11:19:22 -05:00
|
|
|
Token::I32(1),
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::I32(2),
|
|
|
|
Token::I32(3),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::TupleStructEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
TupleStruct(1, 2, 3),
|
|
|
|
&[
|
|
|
|
Token::TupleStruct {
|
|
|
|
name: "TupleStruct",
|
|
|
|
len: 3,
|
|
|
|
},
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::I32(1),
|
|
|
|
Token::I32(2),
|
|
|
|
Token::I32(3),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::TupleStructEnd,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_btreeset() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
BTreeSet::<isize>::new(),
|
|
|
|
&[Token::Seq { len: Some(0) }, Token::SeqEnd],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
btreeset![btreeset![], btreeset![1], btreeset![2, 3]],
|
|
|
|
&[
|
|
|
|
Token::Seq { len: Some(3) },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::Seq { len: Some(0) },
|
2015-03-03 23:19:55 -06:00
|
|
|
Token::SeqEnd,
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::Seq { len: Some(1) },
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::I32(1),
|
2015-08-27 22:01:09 -05:00
|
|
|
Token::SeqEnd,
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::Seq { len: Some(2) },
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::I32(2),
|
|
|
|
Token::I32(3),
|
|
|
|
Token::SeqEnd,
|
2015-03-20 22:35:01 -05:00
|
|
|
Token::SeqEnd,
|
2022-01-20 21:24:35 -06:00
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
BTreeSet::<isize>::new(),
|
|
|
|
&[
|
|
|
|
Token::TupleStruct {
|
|
|
|
name: "Anything",
|
|
|
|
len: 0,
|
|
|
|
},
|
|
|
|
Token::TupleStructEnd,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_hashset() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
HashSet::<isize>::new(),
|
|
|
|
&[Token::Seq { len: Some(0) }, Token::SeqEnd],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
hashset![1, 2, 3],
|
|
|
|
&[
|
|
|
|
Token::Seq { len: Some(3) },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::I32(1),
|
|
|
|
Token::I32(2),
|
|
|
|
Token::I32(3),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::SeqEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
HashSet::<isize>::new(),
|
|
|
|
&[
|
|
|
|
Token::TupleStruct {
|
|
|
|
name: "Anything",
|
|
|
|
len: 0,
|
|
|
|
},
|
|
|
|
Token::TupleStructEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
hashset![FnvHasher @ 1, 2, 3],
|
|
|
|
&[
|
|
|
|
Token::Seq { len: Some(3) },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::I32(1),
|
|
|
|
Token::I32(2),
|
|
|
|
Token::I32(3),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::SeqEnd,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_vec() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
Vec::<isize>::new(),
|
|
|
|
&[Token::Seq { len: Some(0) }, Token::SeqEnd],
|
|
|
|
);
|
|
|
|
|
|
|
|
test(
|
|
|
|
vec![vec![], vec![1], vec![2, 3]],
|
|
|
|
&[
|
|
|
|
Token::Seq { len: Some(3) },
|
2017-04-19 15:06:31 -05:00
|
|
|
Token::Seq { len: Some(0) },
|
2015-03-20 22:35:01 -05:00
|
|
|
Token::SeqEnd,
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::Seq { len: Some(1) },
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::I32(1),
|
2015-03-03 23:19:55 -06:00
|
|
|
Token::SeqEnd,
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::Seq { len: Some(2) },
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::I32(2),
|
|
|
|
Token::I32(3),
|
|
|
|
Token::SeqEnd,
|
2016-06-11 11:59:29 -05:00
|
|
|
Token::SeqEnd,
|
2022-01-20 21:24:35 -06:00
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
Vec::<isize>::new(),
|
|
|
|
&[
|
|
|
|
Token::TupleStruct {
|
|
|
|
name: "Anything",
|
|
|
|
len: 0,
|
|
|
|
},
|
|
|
|
Token::TupleStructEnd,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_array() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test([0; 0], &[Token::Seq { len: Some(0) }, Token::SeqEnd]);
|
|
|
|
test([0; 0], &[Token::Tuple { len: 0 }, Token::TupleEnd]);
|
|
|
|
test(
|
|
|
|
([0; 0], [1], [2, 3]),
|
|
|
|
&[
|
|
|
|
Token::Seq { len: Some(3) },
|
2017-04-19 15:06:31 -05:00
|
|
|
Token::Seq { len: Some(0) },
|
2015-05-16 06:32:58 -05:00
|
|
|
Token::SeqEnd,
|
2017-04-19 15:06:31 -05:00
|
|
|
Token::Seq { len: Some(1) },
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::I32(1),
|
2015-03-03 23:19:55 -06:00
|
|
|
Token::SeqEnd,
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::Seq { len: Some(2) },
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::I32(2),
|
|
|
|
Token::I32(3),
|
|
|
|
Token::SeqEnd,
|
2015-03-03 23:19:55 -06:00
|
|
|
Token::SeqEnd,
|
2022-01-20 21:24:35 -06:00
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
([0; 0], [1], [2, 3]),
|
|
|
|
&[
|
|
|
|
Token::Tuple { len: 3 },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::Tuple { len: 0 },
|
|
|
|
Token::TupleEnd,
|
2017-04-19 15:06:31 -05:00
|
|
|
Token::Tuple { len: 1 },
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::I32(1),
|
2016-02-23 07:15:44 -06:00
|
|
|
Token::TupleEnd,
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::Tuple { len: 2 },
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::I32(2),
|
|
|
|
Token::I32(3),
|
2016-02-23 07:15:44 -06:00
|
|
|
Token::TupleEnd,
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::TupleEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
[0; 0],
|
|
|
|
&[
|
|
|
|
Token::TupleStruct {
|
|
|
|
name: "Anything",
|
|
|
|
len: 0,
|
|
|
|
},
|
|
|
|
Token::TupleStructEnd,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_tuple() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
(1,),
|
|
|
|
&[Token::Seq { len: Some(1) }, Token::I32(1), Token::SeqEnd],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
(1, 2, 3),
|
|
|
|
&[
|
|
|
|
Token::Seq { len: Some(3) },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::I32(1),
|
|
|
|
Token::I32(2),
|
|
|
|
Token::I32(3),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::SeqEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
(1,),
|
|
|
|
&[Token::Tuple { len: 1 }, Token::I32(1), Token::TupleEnd],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
(1, 2, 3),
|
|
|
|
&[
|
|
|
|
Token::Tuple { len: 3 },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::I32(1),
|
|
|
|
Token::I32(2),
|
|
|
|
Token::I32(3),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::TupleEnd,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_btreemap() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
BTreeMap::<isize, isize>::new(),
|
|
|
|
&[Token::Map { len: Some(0) }, Token::MapEnd],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
btreemap![1 => 2],
|
|
|
|
&[
|
|
|
|
Token::Map { len: Some(1) },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::I32(1),
|
|
|
|
Token::I32(2),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::MapEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
btreemap![1 => 2, 3 => 4],
|
|
|
|
&[
|
|
|
|
Token::Map { len: Some(2) },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::I32(1),
|
|
|
|
Token::I32(2),
|
|
|
|
Token::I32(3),
|
|
|
|
Token::I32(4),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::MapEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
btreemap![1 => btreemap![], 2 => btreemap![3 => 4, 5 => 6]],
|
|
|
|
&[
|
|
|
|
Token::Map { len: Some(2) },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::I32(1),
|
2017-04-19 15:06:31 -05:00
|
|
|
Token::Map { len: Some(0) },
|
2015-03-20 10:47:33 -05:00
|
|
|
Token::MapEnd,
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::I32(2),
|
|
|
|
Token::Map { len: Some(2) },
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::I32(3),
|
|
|
|
Token::I32(4),
|
|
|
|
Token::I32(5),
|
|
|
|
Token::I32(6),
|
2015-03-03 23:19:55 -06:00
|
|
|
Token::MapEnd,
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::MapEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
BTreeMap::<isize, isize>::new(),
|
|
|
|
&[
|
|
|
|
Token::Struct {
|
|
|
|
name: "Anything",
|
|
|
|
len: 0,
|
|
|
|
},
|
|
|
|
Token::StructEnd,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
2015-03-03 23:19:55 -06:00
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
#[test]
|
|
|
|
fn test_hashmap() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
HashMap::<isize, isize>::new(),
|
|
|
|
&[Token::Map { len: Some(0) }, Token::MapEnd],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
hashmap![1 => 2],
|
|
|
|
&[
|
|
|
|
Token::Map { len: Some(1) },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::I32(1),
|
|
|
|
Token::I32(2),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::MapEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
hashmap![1 => 2, 3 => 4],
|
|
|
|
&[
|
|
|
|
Token::Map { len: Some(2) },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::I32(1),
|
|
|
|
Token::I32(2),
|
|
|
|
Token::I32(3),
|
|
|
|
Token::I32(4),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::MapEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
hashmap![1 => hashmap![], 2 => hashmap![3 => 4, 5 => 6]],
|
|
|
|
&[
|
|
|
|
Token::Map { len: Some(2) },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::I32(1),
|
2017-04-19 15:06:31 -05:00
|
|
|
Token::Map { len: Some(0) },
|
2015-03-20 22:35:01 -05:00
|
|
|
Token::MapEnd,
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::I32(2),
|
|
|
|
Token::Map { len: Some(2) },
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::I32(3),
|
|
|
|
Token::I32(4),
|
|
|
|
Token::I32(5),
|
|
|
|
Token::I32(6),
|
2015-03-20 22:35:01 -05:00
|
|
|
Token::MapEnd,
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::MapEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
HashMap::<isize, isize>::new(),
|
|
|
|
&[
|
|
|
|
Token::Struct {
|
|
|
|
name: "Anything",
|
|
|
|
len: 0,
|
|
|
|
},
|
|
|
|
Token::StructEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
hashmap![FnvHasher @ 1 => 2, 3 => 4],
|
|
|
|
&[
|
|
|
|
Token::Map { len: Some(2) },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::I32(1),
|
|
|
|
Token::I32(2),
|
|
|
|
Token::I32(3),
|
|
|
|
Token::I32(4),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::MapEnd,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
2015-03-20 22:35:01 -05:00
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
#[test]
|
|
|
|
fn test_struct() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
Struct { a: 1, b: 2, c: 0 },
|
|
|
|
&[
|
|
|
|
Token::Map { len: Some(3) },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::Str("a"),
|
|
|
|
Token::I32(1),
|
|
|
|
Token::Str("b"),
|
|
|
|
Token::I32(2),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::MapEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
Struct { a: 1, b: 2, c: 0 },
|
|
|
|
&[
|
|
|
|
Token::Map { len: Some(3) },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::U8(0),
|
|
|
|
Token::I32(1),
|
|
|
|
Token::U8(1),
|
|
|
|
Token::I32(2),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::MapEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
Struct { a: 1, b: 2, c: 0 },
|
|
|
|
&[
|
|
|
|
Token::Map { len: Some(3) },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::U16(0),
|
|
|
|
Token::I32(1),
|
|
|
|
Token::U16(1),
|
|
|
|
Token::I32(2),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::MapEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
Struct { a: 1, b: 2, c: 0 },
|
|
|
|
&[
|
|
|
|
Token::Map { len: Some(3) },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::U32(0),
|
|
|
|
Token::I32(1),
|
|
|
|
Token::U32(1),
|
|
|
|
Token::I32(2),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::MapEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
Struct { a: 1, b: 2, c: 0 },
|
|
|
|
&[
|
|
|
|
Token::Map { len: Some(3) },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::U64(0),
|
|
|
|
Token::I32(1),
|
|
|
|
Token::U64(1),
|
|
|
|
Token::I32(2),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::MapEnd,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
// Mixed key types
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
Struct { a: 1, b: 2, c: 0 },
|
|
|
|
&[
|
|
|
|
Token::Map { len: Some(3) },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::U8(0),
|
|
|
|
Token::I32(1),
|
|
|
|
Token::U64(1),
|
|
|
|
Token::I32(2),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::MapEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
Struct { a: 1, b: 2, c: 0 },
|
|
|
|
&[
|
|
|
|
Token::Map { len: Some(3) },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::U8(0),
|
|
|
|
Token::I32(1),
|
|
|
|
Token::Str("b"),
|
|
|
|
Token::I32(2),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::MapEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
Struct { a: 1, b: 2, c: 0 },
|
|
|
|
&[
|
|
|
|
Token::Struct {
|
|
|
|
name: "Struct",
|
|
|
|
len: 2,
|
|
|
|
},
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::Str("a"),
|
|
|
|
Token::I32(1),
|
|
|
|
Token::Str("b"),
|
|
|
|
Token::I32(2),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::StructEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
Struct { a: 1, b: 2, c: 0 },
|
|
|
|
&[
|
|
|
|
Token::Seq { len: Some(3) },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::I32(1),
|
|
|
|
Token::I32(2),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::SeqEnd,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
2016-03-07 01:27:12 -06:00
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
#[test]
|
|
|
|
fn test_struct_borrowed_keys() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
Struct { a: 1, b: 2, c: 0 },
|
|
|
|
&[
|
|
|
|
Token::Map { len: Some(3) },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::BorrowedStr("a"),
|
|
|
|
Token::I32(1),
|
|
|
|
Token::BorrowedStr("b"),
|
|
|
|
Token::I32(2),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::MapEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
Struct { a: 1, b: 2, c: 0 },
|
|
|
|
&[
|
|
|
|
Token::Struct {
|
|
|
|
name: "Struct",
|
|
|
|
len: 2,
|
|
|
|
},
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::BorrowedStr("a"),
|
|
|
|
Token::I32(1),
|
|
|
|
Token::BorrowedStr("b"),
|
|
|
|
Token::I32(2),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::StructEnd,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
2020-10-22 01:15:39 -05:00
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
#[test]
|
|
|
|
fn test_struct_owned_keys() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
Struct { a: 1, b: 2, c: 0 },
|
|
|
|
&[
|
|
|
|
Token::Map { len: Some(3) },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::String("a"),
|
|
|
|
Token::I32(1),
|
|
|
|
Token::String("b"),
|
|
|
|
Token::I32(2),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::MapEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
Struct { a: 1, b: 2, c: 0 },
|
|
|
|
&[
|
|
|
|
Token::Struct {
|
|
|
|
name: "Struct",
|
|
|
|
len: 2,
|
|
|
|
},
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::String("a"),
|
|
|
|
Token::I32(1),
|
|
|
|
Token::String("b"),
|
|
|
|
Token::I32(2),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::StructEnd,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
2015-03-03 23:19:55 -06:00
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
#[test]
|
|
|
|
fn test_struct_with_skip() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
Struct { a: 1, b: 2, c: 0 },
|
|
|
|
&[
|
|
|
|
Token::Map { len: Some(3) },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::Str("a"),
|
|
|
|
Token::I32(1),
|
|
|
|
Token::Str("b"),
|
|
|
|
Token::I32(2),
|
|
|
|
Token::Str("c"),
|
|
|
|
Token::I32(3),
|
|
|
|
Token::Str("d"),
|
|
|
|
Token::I32(4),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::MapEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
Struct { a: 1, b: 2, c: 0 },
|
|
|
|
&[
|
|
|
|
Token::Map { len: Some(3) },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::U8(0),
|
|
|
|
Token::I32(1),
|
|
|
|
Token::U16(1),
|
|
|
|
Token::I32(2),
|
|
|
|
Token::U32(2),
|
|
|
|
Token::I32(3),
|
|
|
|
Token::U64(3),
|
|
|
|
Token::I32(4),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::MapEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
Struct { a: 1, b: 2, c: 0 },
|
|
|
|
&[
|
|
|
|
Token::Struct {
|
|
|
|
name: "Struct",
|
|
|
|
len: 2,
|
|
|
|
},
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::Str("a"),
|
|
|
|
Token::I32(1),
|
|
|
|
Token::Str("b"),
|
|
|
|
Token::I32(2),
|
|
|
|
Token::Str("c"),
|
|
|
|
Token::I32(3),
|
|
|
|
Token::Str("d"),
|
|
|
|
Token::I32(4),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::StructEnd,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_struct_skip_all() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
StructSkipAll { a: 0 },
|
|
|
|
&[
|
|
|
|
Token::Struct {
|
|
|
|
name: "StructSkipAll",
|
|
|
|
len: 0,
|
|
|
|
},
|
|
|
|
Token::StructEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
StructSkipAll { a: 0 },
|
|
|
|
&[
|
|
|
|
Token::Struct {
|
|
|
|
name: "StructSkipAll",
|
|
|
|
len: 0,
|
|
|
|
},
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::Str("a"),
|
2015-08-27 22:01:09 -05:00
|
|
|
Token::I32(1),
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::Str("b"),
|
|
|
|
Token::I32(2),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::StructEnd,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
2015-03-03 23:19:55 -06:00
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
#[test]
|
|
|
|
fn test_struct_skip_default() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
StructSkipDefault { a: 16 },
|
|
|
|
&[
|
|
|
|
Token::Struct {
|
|
|
|
name: "StructSkipDefault",
|
|
|
|
len: 0,
|
|
|
|
},
|
|
|
|
Token::StructEnd,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_struct_skip_all_deny_unknown() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
StructSkipAllDenyUnknown { a: 0 },
|
|
|
|
&[
|
|
|
|
Token::Struct {
|
|
|
|
name: "StructSkipAllDenyUnknown",
|
|
|
|
len: 0,
|
|
|
|
},
|
|
|
|
Token::StructEnd,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_struct_default() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
StructDefault {
|
|
|
|
a: 50,
|
|
|
|
b: "overwritten".to_string(),
|
|
|
|
},
|
|
|
|
&[
|
|
|
|
Token::Struct {
|
|
|
|
name: "StructDefault",
|
|
|
|
len: 2,
|
|
|
|
},
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::Str("a"),
|
|
|
|
Token::I32(50),
|
|
|
|
Token::Str("b"),
|
|
|
|
Token::String("overwritten"),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::StructEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
StructDefault {
|
|
|
|
a: 100,
|
|
|
|
b: "default".to_string(),
|
|
|
|
},
|
|
|
|
&[
|
|
|
|
Token::Struct {
|
|
|
|
name: "StructDefault",
|
|
|
|
len: 2,
|
|
|
|
},
|
|
|
|
Token::StructEnd,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_enum_unit() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
Enum::Unit,
|
|
|
|
&[Token::UnitVariant {
|
|
|
|
name: "Enum",
|
|
|
|
variant: "Unit",
|
|
|
|
}],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_enum_simple() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
Enum::Simple(1),
|
|
|
|
&[
|
|
|
|
Token::NewtypeVariant {
|
|
|
|
name: "Enum",
|
|
|
|
variant: "Simple",
|
|
|
|
},
|
|
|
|
Token::I32(1),
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_enum_simple_with_skipped() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
Enum::SimpleWithSkipped(NotDeserializable),
|
|
|
|
&[Token::UnitVariant {
|
|
|
|
name: "Enum",
|
|
|
|
variant: "SimpleWithSkipped",
|
|
|
|
}],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_enum_seq() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
Enum::Seq(1, 2, 3),
|
|
|
|
&[
|
|
|
|
Token::TupleVariant {
|
|
|
|
name: "Enum",
|
|
|
|
variant: "Seq",
|
|
|
|
len: 3,
|
|
|
|
},
|
2016-04-17 22:59:26 -05:00
|
|
|
Token::I32(1),
|
|
|
|
Token::I32(2),
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::I32(3),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::TupleVariantEnd,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_enum_map() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
Enum::Map { a: 1, b: 2, c: 3 },
|
|
|
|
&[
|
|
|
|
Token::StructVariant {
|
|
|
|
name: "Enum",
|
|
|
|
variant: "Map",
|
|
|
|
len: 3,
|
|
|
|
},
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::Str("a"),
|
|
|
|
Token::I32(1),
|
|
|
|
Token::Str("b"),
|
|
|
|
Token::I32(2),
|
|
|
|
Token::Str("c"),
|
|
|
|
Token::I32(3),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::StructVariantEnd,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_enum_unit_usize() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
Enum::Unit,
|
|
|
|
&[Token::Enum { name: "Enum" }, Token::U32(0), Token::Unit],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_enum_unit_bytes() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
Enum::Unit,
|
|
|
|
&[
|
|
|
|
Token::Enum { name: "Enum" },
|
|
|
|
Token::Bytes(b"Unit"),
|
|
|
|
Token::Unit,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_enum_other_unit() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
EnumOther::Unit,
|
|
|
|
&[
|
|
|
|
Token::Enum { name: "EnumOther" },
|
|
|
|
Token::Str("Unit"),
|
|
|
|
Token::Unit,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
EnumOther::Unit,
|
|
|
|
&[Token::Enum { name: "EnumOther" }, Token::U8(0), Token::Unit],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
EnumOther::Unit,
|
|
|
|
&[
|
|
|
|
Token::Enum { name: "EnumOther" },
|
|
|
|
Token::U16(0),
|
|
|
|
Token::Unit,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
EnumOther::Unit,
|
|
|
|
&[
|
|
|
|
Token::Enum { name: "EnumOther" },
|
|
|
|
Token::U32(0),
|
|
|
|
Token::Unit,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
EnumOther::Unit,
|
|
|
|
&[
|
|
|
|
Token::Enum { name: "EnumOther" },
|
|
|
|
Token::U64(0),
|
|
|
|
Token::Unit,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_enum_other() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
EnumOther::Other,
|
|
|
|
&[
|
|
|
|
Token::Enum { name: "EnumOther" },
|
|
|
|
Token::Str("Foo"),
|
|
|
|
Token::Unit,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
EnumOther::Other,
|
|
|
|
&[
|
|
|
|
Token::Enum { name: "EnumOther" },
|
|
|
|
Token::U8(42),
|
|
|
|
Token::Unit,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
EnumOther::Other,
|
|
|
|
&[
|
|
|
|
Token::Enum { name: "EnumOther" },
|
|
|
|
Token::U16(42),
|
|
|
|
Token::Unit,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
EnumOther::Other,
|
|
|
|
&[
|
|
|
|
Token::Enum { name: "EnumOther" },
|
|
|
|
Token::U32(42),
|
|
|
|
Token::Unit,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
EnumOther::Other,
|
|
|
|
&[
|
|
|
|
Token::Enum { name: "EnumOther" },
|
|
|
|
Token::U64(42),
|
|
|
|
Token::Unit,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_box() {
|
|
|
|
test(Box::new(0i32), &[Token::I32(0)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_boxed_slice() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
Box::new([0, 1, 2]),
|
|
|
|
&[
|
|
|
|
Token::Seq { len: Some(3) },
|
|
|
|
Token::I32(0),
|
|
|
|
Token::I32(1),
|
|
|
|
Token::I32(2),
|
|
|
|
Token::SeqEnd,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_duration() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
Duration::new(1, 2),
|
|
|
|
&[
|
|
|
|
Token::Struct {
|
|
|
|
name: "Duration",
|
|
|
|
len: 2,
|
|
|
|
},
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::Str("secs"),
|
|
|
|
Token::U64(1),
|
|
|
|
Token::Str("nanos"),
|
|
|
|
Token::U32(2),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::StructEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
Duration::new(1, 2),
|
|
|
|
&[
|
|
|
|
Token::Seq { len: Some(2) },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::I64(1),
|
|
|
|
Token::I64(2),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::SeqEnd,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_system_time() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
UNIX_EPOCH + Duration::new(1, 2),
|
|
|
|
&[
|
|
|
|
Token::Struct {
|
|
|
|
name: "SystemTime",
|
|
|
|
len: 2,
|
|
|
|
},
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::Str("secs_since_epoch"),
|
|
|
|
Token::U64(1),
|
|
|
|
Token::Str("nanos_since_epoch"),
|
|
|
|
Token::U32(2),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::StructEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
UNIX_EPOCH + Duration::new(1, 2),
|
|
|
|
&[
|
|
|
|
Token::Seq { len: Some(2) },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::I64(1),
|
|
|
|
Token::I64(2),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::SeqEnd,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_range() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
1u32..2u32,
|
|
|
|
&[
|
|
|
|
Token::Struct {
|
|
|
|
name: "Range",
|
|
|
|
len: 2,
|
|
|
|
},
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::Str("start"),
|
2017-10-31 11:32:58 -05:00
|
|
|
Token::U32(1),
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::Str("end"),
|
|
|
|
Token::U32(2),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::StructEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
1u32..2u32,
|
|
|
|
&[
|
|
|
|
Token::Seq { len: Some(2) },
|
2017-10-31 11:32:58 -05:00
|
|
|
Token::U64(1),
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::U64(2),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::SeqEnd,
|
|
|
|
],
|
|
|
|
);
|
2017-09-04 12:56:40 -05:00
|
|
|
}
|
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
#[test]
|
|
|
|
fn test_range_inclusive() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
1u32..=2u32,
|
|
|
|
&[
|
|
|
|
Token::Struct {
|
|
|
|
name: "RangeInclusive",
|
|
|
|
len: 2,
|
|
|
|
},
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::Str("start"),
|
|
|
|
Token::U32(1),
|
|
|
|
Token::Str("end"),
|
|
|
|
Token::U32(2),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::StructEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
1u32..=2u32,
|
|
|
|
&[
|
|
|
|
Token::Seq { len: Some(2) },
|
2022-01-20 19:51:41 -06:00
|
|
|
Token::U64(1),
|
|
|
|
Token::U64(2),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::SeqEnd,
|
|
|
|
],
|
|
|
|
);
|
2017-10-18 01:15:35 -05:00
|
|
|
}
|
|
|
|
|
2023-11-20 19:25:48 -06:00
|
|
|
#[test]
|
|
|
|
fn test_range_from() {
|
|
|
|
test(
|
|
|
|
1u32..,
|
|
|
|
&[
|
|
|
|
Token::Struct {
|
|
|
|
name: "RangeFrom",
|
|
|
|
len: 1,
|
|
|
|
},
|
|
|
|
Token::Str("start"),
|
|
|
|
Token::U32(1),
|
|
|
|
Token::StructEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
1u32..,
|
|
|
|
&[Token::Seq { len: Some(1) }, Token::U32(1), Token::SeqEnd],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_range_to() {
|
|
|
|
test(
|
|
|
|
..2u32,
|
|
|
|
&[
|
|
|
|
Token::Struct {
|
|
|
|
name: "RangeTo",
|
|
|
|
len: 1,
|
|
|
|
},
|
|
|
|
Token::Str("end"),
|
|
|
|
Token::U32(2),
|
|
|
|
Token::StructEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
..2u32,
|
|
|
|
&[Token::Seq { len: Some(1) }, Token::U32(2), Token::SeqEnd],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
#[test]
|
|
|
|
fn test_bound() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
Bound::Unbounded::<()>,
|
|
|
|
&[
|
|
|
|
Token::Enum { name: "Bound" },
|
|
|
|
Token::Str("Unbounded"),
|
|
|
|
Token::Unit,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
Bound::Included(0),
|
|
|
|
&[
|
|
|
|
Token::Enum { name: "Bound" },
|
|
|
|
Token::Str("Included"),
|
|
|
|
Token::U8(0),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
Bound::Excluded(0),
|
|
|
|
&[
|
|
|
|
Token::Enum { name: "Bound" },
|
|
|
|
Token::Str("Excluded"),
|
|
|
|
Token::U8(0),
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
2017-11-03 10:12:43 -05:00
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
#[test]
|
|
|
|
fn test_path() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
Path::new("/usr/local/lib"),
|
|
|
|
&[Token::BorrowedStr("/usr/local/lib")],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
Path::new("/usr/local/lib"),
|
|
|
|
&[Token::BorrowedBytes(b"/usr/local/lib")],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
2017-09-14 09:54:47 -05:00
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
#[test]
|
|
|
|
fn test_path_buf() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
PathBuf::from("/usr/local/lib"),
|
|
|
|
&[Token::Str("/usr/local/lib")],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
PathBuf::from("/usr/local/lib"),
|
|
|
|
&[Token::String("/usr/local/lib")],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
PathBuf::from("/usr/local/lib"),
|
|
|
|
&[Token::Bytes(b"/usr/local/lib")],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
PathBuf::from("/usr/local/lib"),
|
|
|
|
&[Token::ByteBuf(b"/usr/local/lib")],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
2017-09-11 08:54:49 -05:00
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
#[test]
|
|
|
|
fn test_boxed_path() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
PathBuf::from("/usr/local/lib").into_boxed_path(),
|
|
|
|
&[Token::Str("/usr/local/lib")],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
PathBuf::from("/usr/local/lib").into_boxed_path(),
|
|
|
|
&[Token::String("/usr/local/lib")],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
PathBuf::from("/usr/local/lib").into_boxed_path(),
|
|
|
|
&[Token::Bytes(b"/usr/local/lib")],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
PathBuf::from("/usr/local/lib").into_boxed_path(),
|
|
|
|
&[Token::ByteBuf(b"/usr/local/lib")],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
2017-09-11 08:54:49 -05:00
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
#[test]
|
|
|
|
fn test_cstring() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(CString::new("abc").unwrap(), &[Token::Bytes(b"abc")]);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
2017-09-14 09:54:47 -05:00
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
#[test]
|
|
|
|
fn test_rc() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(Rc::new(true), &[Token::Bool(true)]);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
2017-09-11 08:54:49 -05:00
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
#[test]
|
|
|
|
fn test_rc_weak_some() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
SkipPartialEq(RcWeak::<bool>::new()),
|
|
|
|
&[Token::Some, Token::Bool(true)],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
2017-09-11 08:54:49 -05:00
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
#[test]
|
|
|
|
fn test_rc_weak_none() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(SkipPartialEq(RcWeak::<bool>::new()), &[Token::None]);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
2017-09-11 08:54:49 -05:00
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
#[test]
|
|
|
|
fn test_arc() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(Arc::new(true), &[Token::Bool(true)]);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
2017-09-11 08:54:49 -05:00
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
#[test]
|
|
|
|
fn test_arc_weak_some() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
SkipPartialEq(ArcWeak::<bool>::new()),
|
|
|
|
&[Token::Some, Token::Bool(true)],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
2017-09-11 08:54:49 -05:00
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
#[test]
|
|
|
|
fn test_arc_weak_none() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(SkipPartialEq(ArcWeak::<bool>::new()), &[Token::None]);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
2017-09-11 08:54:49 -05:00
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
#[test]
|
|
|
|
fn test_wrapping() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(Wrapping(1usize), &[Token::U32(1)]);
|
|
|
|
test(Wrapping(1usize), &[Token::U64(1)]);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
2024-03-04 11:56:15 -06:00
|
|
|
#[test]
|
|
|
|
fn test_saturating() {
|
|
|
|
test(Saturating(1usize), &[Token::U32(1)]);
|
|
|
|
test(Saturating(1usize), &[Token::U64(1)]);
|
|
|
|
test(Saturating(0u8), &[Token::I8(0)]);
|
|
|
|
test(Saturating(0u16), &[Token::I16(0)]);
|
|
|
|
|
|
|
|
// saturate input values at the minimum or maximum value
|
|
|
|
test(Saturating(u8::MAX), &[Token::U16(u16::MAX)]);
|
|
|
|
test(Saturating(u8::MAX), &[Token::U16(u8::MAX as u16 + 1)]);
|
|
|
|
test(Saturating(u16::MAX), &[Token::U32(u32::MAX)]);
|
|
|
|
test(Saturating(u32::MAX), &[Token::U64(u64::MAX)]);
|
|
|
|
test(Saturating(u8::MIN), &[Token::I8(i8::MIN)]);
|
|
|
|
test(Saturating(u16::MIN), &[Token::I16(i16::MIN)]);
|
|
|
|
test(Saturating(u32::MIN), &[Token::I32(i32::MIN)]);
|
|
|
|
test(Saturating(i8::MIN), &[Token::I16(i16::MIN)]);
|
|
|
|
test(Saturating(i16::MIN), &[Token::I32(i32::MIN)]);
|
|
|
|
test(Saturating(i32::MIN), &[Token::I64(i64::MIN)]);
|
|
|
|
|
|
|
|
test(Saturating(u8::MIN), &[Token::I8(-1)]);
|
|
|
|
test(Saturating(u16::MIN), &[Token::I16(-1)]);
|
|
|
|
|
|
|
|
#[cfg(target_pointer_width = "64")]
|
|
|
|
{
|
|
|
|
test(Saturating(usize::MIN), &[Token::U64(u64::MIN)]);
|
|
|
|
test(Saturating(usize::MAX), &[Token::U64(u64::MAX)]);
|
|
|
|
test(Saturating(isize::MIN), &[Token::I64(i64::MIN)]);
|
|
|
|
test(Saturating(isize::MAX), &[Token::I64(i64::MAX)]);
|
|
|
|
test(Saturating(0usize), &[Token::I64(i64::MIN)]);
|
|
|
|
|
|
|
|
test(
|
|
|
|
Saturating(9_223_372_036_854_775_807usize),
|
|
|
|
&[Token::I64(i64::MAX)],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-20 19:51:41 -06:00
|
|
|
#[test]
|
|
|
|
fn test_rc_dst() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(Rc::<str>::from("s"), &[Token::Str("s")]);
|
|
|
|
test(
|
|
|
|
Rc::<[bool]>::from(&[true][..]),
|
|
|
|
&[
|
|
|
|
Token::Seq { len: Some(1) },
|
|
|
|
Token::Bool(true),
|
|
|
|
Token::SeqEnd,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_arc_dst() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(Arc::<str>::from("s"), &[Token::Str("s")]);
|
|
|
|
test(
|
|
|
|
Arc::<[bool]>::from(&[true][..]),
|
|
|
|
&[
|
|
|
|
Token::Seq { len: Some(1) },
|
|
|
|
Token::Bool(true),
|
|
|
|
Token::SeqEnd,
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_ignored_any() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(IgnoredAny, &[Token::Str("s")]);
|
|
|
|
test(
|
|
|
|
IgnoredAny,
|
|
|
|
&[
|
|
|
|
Token::Seq { len: Some(1) },
|
|
|
|
Token::Bool(true),
|
|
|
|
Token::SeqEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
IgnoredAny,
|
|
|
|
&[Token::Enum { name: "E" }, Token::Str("Rust"), Token::Unit],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_net_ipv4addr_readable() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
"1.2.3.4".parse::<net::Ipv4Addr>().unwrap().readable(),
|
|
|
|
&[Token::Str("1.2.3.4")],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_net_ipv6addr_readable() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
"::1".parse::<net::Ipv6Addr>().unwrap().readable(),
|
|
|
|
&[Token::Str("::1")],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_net_ipaddr_readable() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
"1.2.3.4".parse::<net::IpAddr>().unwrap().readable(),
|
|
|
|
&[Token::Str("1.2.3.4")],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_net_socketaddr_readable() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
"1.2.3.4:1234"
|
|
|
|
.parse::<net::SocketAddr>()
|
|
|
|
.unwrap()
|
|
|
|
.readable(),
|
|
|
|
&[Token::Str("1.2.3.4:1234")],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
"1.2.3.4:1234"
|
|
|
|
.parse::<net::SocketAddrV4>()
|
|
|
|
.unwrap()
|
|
|
|
.readable(),
|
|
|
|
&[Token::Str("1.2.3.4:1234")],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
"[::1]:1234"
|
|
|
|
.parse::<net::SocketAddrV6>()
|
|
|
|
.unwrap()
|
|
|
|
.readable(),
|
|
|
|
&[Token::Str("[::1]:1234")],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_net_ipv4addr_compact() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
net::Ipv4Addr::from(*b"1234").compact(),
|
|
|
|
&seq![
|
|
|
|
Token::Tuple { len: 4 },
|
2022-01-20 21:36:41 -06:00
|
|
|
b"1234".iter().copied().map(Token::U8),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::TupleEnd
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_net_ipv6addr_compact() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
net::Ipv6Addr::from(*b"1234567890123456").compact(),
|
|
|
|
&seq![
|
|
|
|
Token::Tuple { len: 4 },
|
2022-01-20 21:36:41 -06:00
|
|
|
b"1234567890123456".iter().copied().map(Token::U8),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::TupleEnd
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_net_ipaddr_compact() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
net::IpAddr::from(*b"1234").compact(),
|
|
|
|
&seq![
|
2022-01-20 21:25:06 -06:00
|
|
|
Token::NewtypeVariant {
|
|
|
|
name: "IpAddr",
|
|
|
|
variant: "V4"
|
|
|
|
},
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::Tuple { len: 4 },
|
2022-01-20 21:36:41 -06:00
|
|
|
b"1234".iter().copied().map(Token::U8),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::TupleEnd
|
|
|
|
],
|
|
|
|
);
|
2022-01-20 19:51:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_net_socketaddr_compact() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
net::SocketAddr::from((*b"1234567890123456", 1234)).compact(),
|
|
|
|
&seq![
|
2022-01-20 21:25:06 -06:00
|
|
|
Token::NewtypeVariant {
|
|
|
|
name: "SocketAddr",
|
|
|
|
variant: "V6"
|
|
|
|
},
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::Tuple { len: 2 },
|
|
|
|
Token::Tuple { len: 16 },
|
2022-01-20 21:36:41 -06:00
|
|
|
b"1234567890123456".iter().copied().map(Token::U8),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::TupleEnd,
|
|
|
|
Token::U16(1234),
|
|
|
|
Token::TupleEnd
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
net::SocketAddr::from((*b"1234", 1234)).compact(),
|
|
|
|
&seq![
|
2022-01-20 21:25:06 -06:00
|
|
|
Token::NewtypeVariant {
|
|
|
|
name: "SocketAddr",
|
|
|
|
variant: "V4"
|
|
|
|
},
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::Tuple { len: 2 },
|
|
|
|
Token::Tuple { len: 4 },
|
2022-01-20 21:36:41 -06:00
|
|
|
b"1234".iter().copied().map(Token::U8),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::TupleEnd,
|
|
|
|
Token::U16(1234),
|
|
|
|
Token::TupleEnd
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
net::SocketAddrV4::new(net::Ipv4Addr::from(*b"1234"), 1234).compact(),
|
|
|
|
&seq![
|
|
|
|
Token::Tuple { len: 2 },
|
|
|
|
Token::Tuple { len: 4 },
|
2022-01-20 21:36:41 -06:00
|
|
|
b"1234".iter().copied().map(Token::U8),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::TupleEnd,
|
|
|
|
Token::U16(1234),
|
|
|
|
Token::TupleEnd
|
|
|
|
],
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
net::SocketAddrV6::new(net::Ipv6Addr::from(*b"1234567890123456"), 1234, 0, 0).compact(),
|
|
|
|
&seq![
|
|
|
|
Token::Tuple { len: 2 },
|
|
|
|
Token::Tuple { len: 16 },
|
2022-01-20 21:36:41 -06:00
|
|
|
b"1234567890123456".iter().copied().map(Token::U8),
|
2022-01-20 21:24:35 -06:00
|
|
|
Token::TupleEnd,
|
|
|
|
Token::U16(1234),
|
|
|
|
Token::TupleEnd
|
|
|
|
],
|
|
|
|
);
|
2017-09-11 08:54:49 -05:00
|
|
|
}
|
|
|
|
|
2018-06-03 02:15:05 -05:00
|
|
|
#[cfg(feature = "unstable")]
|
2022-01-20 19:51:41 -06:00
|
|
|
#[test]
|
|
|
|
fn test_never_result() {
|
2022-01-20 21:24:35 -06:00
|
|
|
test(
|
|
|
|
Ok::<u8, !>(0),
|
|
|
|
&[
|
|
|
|
Token::NewtypeVariant {
|
|
|
|
name: "Result",
|
|
|
|
variant: "Ok",
|
|
|
|
},
|
|
|
|
Token::U8(0),
|
|
|
|
],
|
|
|
|
);
|
2018-06-03 02:15:05 -05:00
|
|
|
}
|
|
|
|
|
2017-03-27 11:15:22 -05:00
|
|
|
#[cfg(unix)]
|
|
|
|
#[test]
|
|
|
|
fn test_osstring() {
|
|
|
|
use std::os::unix::ffi::OsStringExt;
|
|
|
|
|
|
|
|
let value = OsString::from_vec(vec![1, 2, 3]);
|
|
|
|
let tokens = [
|
2017-04-19 15:06:31 -05:00
|
|
|
Token::Enum { name: "OsString" },
|
2017-03-27 11:15:22 -05:00
|
|
|
Token::Str("Unix"),
|
2017-04-19 15:06:31 -05:00
|
|
|
Token::Seq { len: Some(2) },
|
2017-04-13 14:28:23 -05:00
|
|
|
Token::U8(1),
|
|
|
|
Token::U8(2),
|
|
|
|
Token::U8(3),
|
2017-03-27 11:15:22 -05:00
|
|
|
Token::SeqEnd,
|
|
|
|
];
|
|
|
|
|
|
|
|
assert_de_tokens(&value, &tokens);
|
2017-10-18 01:09:50 -05:00
|
|
|
assert_de_tokens_ignore(&tokens);
|
2017-03-27 11:15:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(windows)]
|
|
|
|
#[test]
|
|
|
|
fn test_osstring() {
|
|
|
|
use std::os::windows::ffi::OsStringExt;
|
|
|
|
|
|
|
|
let value = OsString::from_wide(&[1, 2, 3]);
|
|
|
|
let tokens = [
|
2017-04-19 15:06:31 -05:00
|
|
|
Token::Enum { name: "OsString" },
|
2017-03-27 11:15:22 -05:00
|
|
|
Token::Str("Windows"),
|
2017-04-19 15:06:31 -05:00
|
|
|
Token::Seq { len: Some(2) },
|
2017-04-13 14:28:23 -05:00
|
|
|
Token::U16(1),
|
|
|
|
Token::U16(2),
|
|
|
|
Token::U16(3),
|
2017-03-27 11:15:22 -05:00
|
|
|
Token::SeqEnd,
|
|
|
|
];
|
|
|
|
|
|
|
|
assert_de_tokens(&value, &tokens);
|
2017-10-18 01:09:50 -05:00
|
|
|
assert_de_tokens_ignore(&tokens);
|
2017-03-27 11:15:22 -05:00
|
|
|
}
|
|
|
|
|
2017-03-08 22:13:28 -06:00
|
|
|
#[test]
|
|
|
|
fn test_cstr() {
|
2017-04-13 14:28:23 -05:00
|
|
|
assert_de_tokens::<Box<CStr>>(
|
|
|
|
&CString::new("abc").unwrap().into_boxed_c_str(),
|
|
|
|
&[Token::Bytes(b"abc")],
|
|
|
|
);
|
2017-03-08 22:13:28 -06:00
|
|
|
}
|
|
|
|
|
2019-07-16 11:16:50 -05:00
|
|
|
#[test]
|
|
|
|
fn test_atomics() {
|
2023-05-04 19:25:17 -05:00
|
|
|
fn test<L, A, T>(load: L, val: T)
|
2019-07-16 11:16:50 -05:00
|
|
|
where
|
|
|
|
L: Fn(&A, Ordering) -> T,
|
|
|
|
A: DeserializeOwned,
|
2023-05-04 19:25:17 -05:00
|
|
|
T: PartialEq + Debug + Copy + for<'de> IntoDeserializer<'de>,
|
2019-07-16 11:16:50 -05:00
|
|
|
{
|
2023-05-04 19:25:17 -05:00
|
|
|
match A::deserialize(val.into_deserializer()) {
|
2019-07-11 19:51:19 -05:00
|
|
|
Ok(v) => {
|
2021-12-23 13:42:41 -06:00
|
|
|
let loaded = load(&v, Ordering::Relaxed);
|
2019-07-16 11:16:50 -05:00
|
|
|
assert_eq!(val, loaded);
|
2019-07-16 09:32:13 -05:00
|
|
|
}
|
|
|
|
Err(e) => panic!("tokens failed to deserialize: {}", e),
|
2019-07-11 19:51:19 -05:00
|
|
|
}
|
2019-07-16 11:16:50 -05:00
|
|
|
}
|
2019-07-11 19:51:19 -05:00
|
|
|
|
2023-05-04 19:25:17 -05:00
|
|
|
test(AtomicBool::load, true);
|
|
|
|
test(AtomicI8::load, -127i8);
|
|
|
|
test(AtomicI16::load, -510i16);
|
|
|
|
test(AtomicI32::load, -131072i32);
|
|
|
|
test(AtomicIsize::load, -131072isize);
|
|
|
|
test(AtomicU8::load, 127u8);
|
|
|
|
test(AtomicU16::load, 510u16);
|
|
|
|
test(AtomicU32::load, 131072u32);
|
|
|
|
test(AtomicUsize::load, 131072usize);
|
2019-07-16 12:00:44 -05:00
|
|
|
|
2019-07-17 11:11:35 -05:00
|
|
|
#[cfg(target_arch = "x86_64")]
|
2019-07-16 12:00:44 -05:00
|
|
|
{
|
2023-05-04 19:25:17 -05:00
|
|
|
test(AtomicI64::load, -8589934592i64);
|
|
|
|
test(AtomicU64::load, 8589934592u64);
|
2019-07-16 12:00:44 -05:00
|
|
|
}
|
2019-07-11 19:51:19 -05:00
|
|
|
}
|