Skip to content
This repository has been archived by the owner on Aug 15, 2021. It is now read-only.

Commit

Permalink
tests: Add zero-length byte strings into indefinite sequences
Browse files Browse the repository at this point in the history
Those are pointless to add in real data, but trigger code paths
otherwise less trod.
  • Loading branch information
chrysn committed Nov 21, 2018
1 parent 67c3b49 commit 6814cb9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ fn test_indefinite_list() {

#[test]
fn test_indefinite_string() {
let value: error::Result<Value> = de::from_slice(b"\x7f\x65Mary \x64Had \x62a \x67Little \x64Lamb\xff");
let value: error::Result<Value> = de::from_slice(b"\x7f\x65Mary \x64Had \x62a \x67Little \x60\x64Lamb\xff");
assert_eq!(value.unwrap(), Value::String("Mary Had a Little Lamb".to_owned()));
}

Expand All @@ -116,7 +116,7 @@ fn test_indefinite_byte_string() {
#[test]
fn test_multiple_indefinite_strings() {
// This assures that buffer rewinding in infinite buffers works as intended.
let value: error::Result<Value> = de::from_slice(b"\x82\x7f\x65Mary \x64Had \x62a \x67Little \x64Lamb\xff\x5f\x42\x01\x23\x42\x45\x67\xff");
let value: error::Result<Value> = de::from_slice(b"\x82\x7f\x65Mary \x64Had \x62a \x67Little \x60\x64Lamb\xff\x5f\x42\x01\x23\x42\x45\x67\xff");
assert_eq!(value.unwrap(), Value::Array(vec![
Value::String("Mary Had a Little Lamb".to_owned()),
Value::Bytes(b"\x01#Eg".to_vec())
Expand Down Expand Up @@ -245,7 +245,7 @@ fn stream_deserializer_eof() {

#[test]
fn stream_deserializer_eof_in_indefinite() {
let slice = b"\x7f\x65Mary \x64Had \x62a \x67Little \x64Lamb\xff";
let slice = b"\x7f\x65Mary \x64Had \x62a \x60\x67Little \x60\x64Lamb\xff";
let indices: &[usize] = &[
2, // announcement but no data
10, // mid-buffer EOF
Expand Down

0 comments on commit 6814cb9

Please sign in to comment.