Skip to content

Commit

Permalink
finish tests
Browse files Browse the repository at this point in the history
  • Loading branch information
julientregoat committed Oct 11, 2020
1 parent 665ee5c commit 43cacda
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/samples_formats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ unsafe impl Sample for u16 {
}

fn to_i32(&self) -> i32 {
(*self).into()
self.to_i16() as i32
}

#[inline]
Expand Down Expand Up @@ -259,11 +259,10 @@ mod test {

#[test]
fn i16_to_i32() {
// TODO
// assert_eq!(0i16.to_i16(), 0);
// assert_eq!((-467i16).to_i16(), -467);
// assert_eq!(32767i16.to_i16(), 32767);
// assert_eq!((-32768i16).to_i16(), -32768);
assert_eq!(0i16.to_i32(), 0);
assert_eq!((-467i16).to_i32(), -467);
assert_eq!(std::i16::MAX.to_i32(), std::i16::MAX as i32);
assert_eq!(std::i16::MIN.to_i32(), std::i16::MIN as i32);
}

#[test]
Expand Down Expand Up @@ -291,12 +290,12 @@ mod test {
assert_eq!(0u16.to_i16(), -32768);
}

#[test]
fn u16_to_i32() {
// TODO
// assert_eq!(32768u16.to_i16(), 0);
// assert_eq!(16384u16.to_i16(), -16384);
// assert_eq!(65535u16.to_i16(), 32767);
// assert_eq!(0u16.to_i16(), -32768);
assert_eq!(32768u16.to_i32(), 0);
assert_eq!(16384u16.to_i32(), -16384);
assert_eq!(65535u16.to_i32(), std::i16::MAX as i32);
assert_eq!(0u16.to_i32(), std::i16::MIN as i32);
}

#[test]
Expand Down

0 comments on commit 43cacda

Please sign in to comment.