mirror of https://github.com/sunface/rust-course
				
				
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					26 lines
				
				547 B
			
		
		
			
		
	
	
					26 lines
				
				547 B
			| 
								 
											4 years ago
										 
									 | 
							
								// tests3.rs
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								// 这个测试不是在测试我们的函数——想些方法让它的返回值可以通过测试。
							 | 
						||
| 
								 | 
							
								// 在第二个测试判断调用 `is_even(5)` 是否得到了预期的结果。
							 | 
						||
| 
								 | 
							
								// 执行 `rustlings hint tests3` 获取提示 :)
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								// I AM NOT DONE
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								pub fn is_even(num: i32) -> bool {
							 | 
						||
| 
								 | 
							
								    num % 2 == 0
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#[cfg(test)]
							 | 
						||
| 
								 | 
							
								mod tests {
							 | 
						||
| 
								 | 
							
								    use super::*;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    #[test]
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								    fn is_true_when_even() {// 偶数将返回 true
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								        assert!();
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    #[test]
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								    fn is_false_when_odd() {// 奇数将返回 false
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								        assert!();
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								}
							 |