fix error message, add test

This commit is contained in:
Vinzenz Schroeter 2024-10-11 21:38:47 +02:00
parent 03f7495695
commit 942968fcf4
2 changed files with 16 additions and 3 deletions

View file

@ -80,3 +80,16 @@ impl Connection {
} }
} }
} }
#[cfg(test)]
mod tests {
use super::*;
use crate::packet::*;
#[test]
fn send_fake() {
let data: &[u8] = &[0u8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let packet = Packet::try_from(data).unwrap();
Connection::Fake.send(packet).unwrap()
}
}

View file

@ -79,12 +79,12 @@ pub trait Grid<T> {
assert!( assert!(
x < self.width(), x < self.width(),
"cannot access index [{x}, {y}] because x is outside of bounds 0..{}", "cannot access index [{x}, {y}] because x is outside of bounds 0..{}",
self.width() self.width() - 1
); );
assert!( assert!(
y < self.height(), y < self.height(),
"cannot access byte [{x}, {y}] because y is outside of bounds 0..{}", "cannot access index [{x}, {y}] because y is outside of bounds 0..{}",
self.height() self.height() - 1
); );
} }
} }