Skip to content

Commit

Permalink
fix tests that were not being run
Browse files Browse the repository at this point in the history
  • Loading branch information
bluejekyll authored and djc committed Apr 16, 2024
1 parent d596781 commit 3b733ba
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions crates/proto/src/serialize/binary/decoder.rs
Expand Up @@ -245,7 +245,7 @@ impl<'a> BinDecoder<'a> {
}
}

#[cfg(tests)]
#[cfg(test)]
mod tests {
use super::*;

Expand All @@ -255,13 +255,13 @@ mod tests {
let mut decoder = BinDecoder::new(deadbeef);

let read = decoder.read_slice(4).expect("failed to read dead");
assert_eq!(read, "dead");
assert_eq!(&read.unverified(), b"dead");

let read = decoder.read_slice(2).expect("failed to read be");
assert_eq!(read, "be");
assert_eq!(&read.unverified(), b"be");

let read = decoder.read_slice(0).expect("failed to read nothing");
assert_eq!(read, "");
assert_eq!(&read.unverified(), b"");

// this should fail
assert!(decoder.read_slice(3).is_err());
Expand All @@ -272,20 +272,19 @@ mod tests {
let deadbeef = b"deadbeef";
let mut decoder = BinDecoder::new(deadbeef);

decoder.read_slice_from(4).expect("failed to read dead");
decoder.read_slice(4).expect("failed to read dead");
let read = decoder.slice_from(0).expect("failed to get slice");
assert_eq!(read, "dead");
assert_eq!(&read, b"dead");

decoder.read_slice(2).expect("failed to read be");
let read = decoder.slice_from(4).expect("failed to get slice");
assert_eq!(read, "be");
assert_eq!(&read, b"be");

decoder.read_slice(0).expect("failed to read nothing");
let read = decoder.slice_from(4).expect("failed to get slice");
assert_eq!(read, "be");
assert_eq!(&read, b"be");

// this should fail
assert!(decoder.slice_from(6).is_err());
assert!(decoder.slice_from(10).is_err());
}
}

0 comments on commit 3b733ba

Please sign in to comment.