fix error message, add test
This commit is contained in:
		
							parent
							
								
									03f7495695
								
							
						
					
					
						commit
						942968fcf4
					
				
					 2 changed files with 16 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -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()
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -79,12 +79,12 @@ pub trait Grid<T> {
 | 
			
		|||
        assert!(
 | 
			
		||||
            x < self.width(),
 | 
			
		||||
            "cannot access index [{x}, {y}] because x is outside of bounds 0..{}",
 | 
			
		||||
            self.width()
 | 
			
		||||
            self.width() - 1
 | 
			
		||||
        );
 | 
			
		||||
        assert!(
 | 
			
		||||
            y < self.height(),
 | 
			
		||||
            "cannot access byte [{x}, {y}] because y is outside of bounds 0..{}",
 | 
			
		||||
            self.height()
 | 
			
		||||
            "cannot access index [{x}, {y}] because y is outside of bounds 0..{}",
 | 
			
		||||
            self.height() - 1
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue