Fixed the tests to be correct.

There is now a random test for all the primitive number types.

Also, I fixed my errors with the tests that should panic. I kept thinking
that they should run fine and it was throwing off how I was writing
the code.
This commit is contained in:
Jason Travis Smith
2016-01-03 03:22:21 -05:00
parent e6f1fbb229
commit 010abeff7c
2 changed files with 165 additions and 13 deletions

View File

@ -36,7 +36,10 @@ macro_rules! read_bytes
({
use std::$returnType;
assert!($buffer.len() < $returnType::BYTES);
// Make sure that there is enough space to read
// a value from the buffer.
assert!($buffer.len() == $returnType::BYTES);
unsafe
{
(*($buffer.as_ptr() as *const $returnType)).$convertFunc()
@ -52,7 +55,8 @@ macro_rules! write_bytes
({
use std::$valueType;
assert!($buffer.len() < $valueType::BYTES);
assert!($buffer.len() >= $valueType::BYTES,
"Not enough room in the buffer to write to.");
unsafe
{
let size: usize;