grains: Renamed the test suite functions
This commit renames the test suite functions to
conform to the "test_{case_description}" style.
The commit also introduces a separate square property function.
use grains;
+fn process_square_case(input: u32, expected: u64) {
+ assert_eq!(grains::square(input), expected);
+}
+
#[test]
-fn square_one() {
- assert_eq!(grains::square(1), 1);
+/// 1
+fn test_1() {
+ process_square_case(1, 1);
}
#[test]
#[ignore]
-fn square_two() {
- assert_eq!(grains::square(2), 2);
+/// 2
+fn test_2() {
+ process_square_case(2, 2);
}
#[test]
#[ignore]
-fn square_three() {
- assert_eq!(grains::square(3), 4);
+/// 3
+fn test_3() {
+ process_square_case(3, 4);
}
#[test]
#[ignore]
-fn square_four() {
- assert_eq!(grains::square(4), 8);
+/// 4
+fn test_4() {
+ process_square_case(4, 8);
}
+//NEW
#[test]
#[ignore]
-fn square_sixteen() {
- assert_eq!(grains::square(16), 32_768);
+/// 16
+fn test_16() {
+ process_square_case(16, 32_768);
}
#[test]
#[ignore]
-fn square_thirty_two() {
- assert_eq!(grains::square(32), 2_147_483_648);
+/// 32
+fn test_32() {
+ process_square_case(32, 2_147_483_648);
}
#[test]
#[ignore]
-fn square_sixty_four() {
- assert_eq!(grains::square(64), 9_223_372_036_854_775_808);
+/// 64
+fn test_64() {
+ process_square_case(64, 9_223_372_036_854_775_808);
}
#[test]
#[ignore]
#[should_panic(expected = "Square must be between 1 and 64")]
-fn square_zero_panics() {
+fn test_square_0_raises_an_exception() {
grains::square(0);
}
#[test]
#[ignore]
#[should_panic(expected = "Square must be between 1 and 64")]
-fn square_sixty_five_panics() {
+fn test_square_greater_than_64_raises_an_exception() {
grains::square(65);
}
#[test]
#[ignore]
-fn total_sums_all_squares() {
+fn test_returns_the_total_number_of_grains_on_the_board() {
assert_eq!(grains::total(), 18_446_744_073_709_551_615);
}
