add tests for is_valid() method
				
					
				
			This commit is contained in:
		
							parent
							
								
									62433b0fd2
								
							
						
					
					
						commit
						9d0dd5e6f7
					
				
							
								
								
									
										23
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								src/main.rs
									
									
									
									
									
								
							@ -294,4 +294,27 @@ mod tests {
 | 
				
			|||||||
        w.create();
 | 
					        w.create();
 | 
				
			||||||
        assert!(w.empty_position(Position { x: 0, y: 0 }));
 | 
					        assert!(w.empty_position(Position { x: 0, y: 0 }));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #[test]
 | 
				
			||||||
 | 
					    fn test_valid_position() {
 | 
				
			||||||
 | 
					        let p: Position = Position { x: 1, y: 1 };
 | 
				
			||||||
 | 
					        let w: World = World {
 | 
				
			||||||
 | 
					            x: 5,
 | 
				
			||||||
 | 
					            y: 5,
 | 
				
			||||||
 | 
					            map: Vec::new(),
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					        assert!(p.is_valid(w).is_ok());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #[test]
 | 
				
			||||||
 | 
					    #[should_panic]
 | 
				
			||||||
 | 
					    fn test_invalid_position() {
 | 
				
			||||||
 | 
					        let p: Position = Position { x: -1, y: 1 };
 | 
				
			||||||
 | 
					        let w: World = World {
 | 
				
			||||||
 | 
					            x: 5,
 | 
				
			||||||
 | 
					            y: 5,
 | 
				
			||||||
 | 
					            map: Vec::new(),
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					        assert!(p.is_valid(w).is_ok());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user