mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-12 13:11:02 +00:00
Newtype: move up the test with tag only
This commit is contained in:
@@ -305,6 +305,26 @@ mod unit {
|
|||||||
mod newtype {
|
mod newtype {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn map_tag_only() {
|
||||||
|
// optional newtype with no content field
|
||||||
|
assert_de_tokens(
|
||||||
|
&AdjacentlyTagged::Newtype::<Option<u8>>(None),
|
||||||
|
&[
|
||||||
|
Token::Struct {
|
||||||
|
name: "AdjacentlyTagged",
|
||||||
|
len: 1,
|
||||||
|
},
|
||||||
|
Token::Str("t"),
|
||||||
|
Token::UnitVariant {
|
||||||
|
name: "AdjacentlyTagged",
|
||||||
|
variant: "Newtype",
|
||||||
|
},
|
||||||
|
Token::StructEnd,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn map_tag_content() {
|
fn map_tag_content() {
|
||||||
let value = AdjacentlyTagged::Newtype::<u8>(1);
|
let value = AdjacentlyTagged::Newtype::<u8>(1);
|
||||||
@@ -348,26 +368,6 @@ mod newtype {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn map_tag_only() {
|
|
||||||
// optional newtype with no content field
|
|
||||||
assert_de_tokens(
|
|
||||||
&AdjacentlyTagged::Newtype::<Option<u8>>(None),
|
|
||||||
&[
|
|
||||||
Token::Struct {
|
|
||||||
name: "AdjacentlyTagged",
|
|
||||||
len: 1,
|
|
||||||
},
|
|
||||||
Token::Str("t"),
|
|
||||||
Token::UnitVariant {
|
|
||||||
name: "AdjacentlyTagged",
|
|
||||||
variant: "Newtype",
|
|
||||||
},
|
|
||||||
Token::StructEnd,
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn seq() {
|
fn seq() {
|
||||||
let value = AdjacentlyTagged::Newtype::<u8>(1);
|
let value = AdjacentlyTagged::Newtype::<u8>(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user