Fixed the uint and int system types to not require num_bytes.

This also fixes the tests for buffer overflow to now work for all
primitive types.
This commit is contained in:
Jason Travis Smith
2016-01-02 23:16:39 -05:00
parent 7617ddb16a
commit e6f1fbb229
4 changed files with 48 additions and 9 deletions

View File

@ -62,7 +62,7 @@ macro_rules! overflow_impl
let mut buffer: [u8; $numBytes];
buffer = [0u8; $numBytes];
LittleEndian::$write_func(&mut buffer, $T::zero());
LittleEndian::$write_func(&mut buffer, $T::zero());
}
};
}
@ -96,12 +96,14 @@ macro_rules! test_buffer_overflow
test_buffer_overflow!(overflow_u16, u16, bytes_to_u16, u16_to_bytes);
test_buffer_overflow!(overflow_u32, u32, bytes_to_u32, u32_to_bytes);
test_buffer_overflow!(overflow_u64, u64, bytes_to_u64, u64_to_bytes);
//test_buffer_overflow!(overflow_usize, usize, bytes_to_usize, usize_to_bytes);
test_buffer_overflow!(overflow_usize, usize,
bytes_to_usize, usize_to_bytes, 9);
test_buffer_overflow!(overflow_i16, i16, bytes_to_i16, i16_to_bytes);
test_buffer_overflow!(overflow_i32, i32, bytes_to_i32, i32_to_bytes);
test_buffer_overflow!(overflow_i64, i64, bytes_to_i64, i64_to_bytes);
//test_buffer_overflow!(overflow_isize, isize, bytes_to_isize, isize_to_bytes);
test_buffer_overflow!(overflow_isize, isize,
bytes_to_isize, isize_to_bytes, 9);
test_buffer_overflow!(overflow_f32, f32, bytes_to_f32, f32_to_bytes, 4);
test_buffer_overflow!(overflow_f64, f64, bytes_to_f64, f64_to_bytes, 8);