Robot need to piouff some time :)
This commit is contained in:
		
							parent
							
								
									8cd7fdee02
								
							
						
					
					
						commit
						1ced716662
					
				
							
								
								
									
										23
									
								
								src/robot.rs
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								src/robot.rs
									
									
									
									
									
								
							@ -69,6 +69,14 @@ pub fn is_instructions(v: &Vec<char>) -> bool {
 | 
			
		||||
    true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Check if a robot is piouff.
 | 
			
		||||
pub fn is_piouff(r: &Robot) -> bool {
 | 
			
		||||
    if r.i.len() == 0 {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[cfg(test)]
 | 
			
		||||
mod tests {
 | 
			
		||||
    use super::*;
 | 
			
		||||
@ -121,4 +129,19 @@ mod tests {
 | 
			
		||||
        let v = vec!['F', 'R', 'L', 'Z'];
 | 
			
		||||
        assert!(is_instructions(&v));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    #[test]
 | 
			
		||||
    fn test_piouf() {
 | 
			
		||||
        let mut r: Robot = Robot::new(
 | 
			
		||||
            0,
 | 
			
		||||
            Orientation::N,
 | 
			
		||||
            Position { x: 1, y: 2 },
 | 
			
		||||
            vec!['R', 'F', 'L', 'F'],
 | 
			
		||||
        );
 | 
			
		||||
        r.i.pop();
 | 
			
		||||
        r.i.pop();
 | 
			
		||||
        r.i.pop();
 | 
			
		||||
        r.i.pop();
 | 
			
		||||
        assert!(is_piouff(&r));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user