Merge pull request #2655 from dtolnay/rangestartend

Add RangeFrom and RangeTo tests
This commit is contained in:
David Tolnay 2023-11-20 17:33:42 -08:00 committed by GitHub
commit c706281df3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 72 additions and 0 deletions

View File

@ -1898,6 +1898,46 @@ fn test_range_inclusive() {
);
}
#[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],
);
}
#[test]
fn test_bound() {
test(

View File

@ -500,6 +500,38 @@ fn test_range_inclusive() {
);
}
#[test]
fn test_range_from() {
assert_ser_tokens(
&(1u32..),
&[
Token::Struct {
name: "RangeFrom",
len: 1,
},
Token::Str("start"),
Token::U32(1),
Token::StructEnd,
],
);
}
#[test]
fn test_range_to() {
assert_ser_tokens(
&(..2u32),
&[
Token::Struct {
name: "RangeTo",
len: 1,
},
Token::Str("end"),
Token::U32(2),
Token::StructEnd,
],
);
}
#[test]
fn test_bound() {
assert_ser_tokens(