diff --git a/exercises/practice/armstrong-numbers/test_armstrong_numbers.zig b/exercises/practice/armstrong-numbers/test_armstrong_numbers.zig index 4e8f05fe..99ba3432 100644 --- a/exercises/practice/armstrong-numbers/test_armstrong_numbers.zig +++ b/exercises/practice/armstrong-numbers/test_armstrong_numbers.zig @@ -3,54 +3,96 @@ const testing = std.testing; const isArmstrongNumber = @import("armstrong_numbers.zig").isArmstrongNumber; +// Adding "return error.SkipZigTest" to the top of each test results in a compiler error +// This wrapper function around error.SkipZigTest appeases the compiler +fn skipTest() !void { + return error.SkipZigTest; +} + test "zero is an armstrong number" { try testing.expect(isArmstrongNumber(0)); } test "single-digit numbers are armstrong numbers" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(isArmstrongNumber(5)); } test "there are no two-digit armstrong numbers" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(!isArmstrongNumber(10)); } test "three-digit number that is an armstrong number" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(isArmstrongNumber(153)); } test "three-digit number that is not an armstrong number" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(!isArmstrongNumber(100)); } test "four-digit number that is an armstrong number" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(isArmstrongNumber(9_474)); } test "four-digit number that is not an armstrong number" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(!isArmstrongNumber(9_475)); } test "seven-digit number that is an armstrong number" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(isArmstrongNumber(9_926_315)); } test "seven-digit number that is not an armstrong number" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(!isArmstrongNumber(9_926_314)); } test "33-digit number that is an armstrong number" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(isArmstrongNumber(186_709_961_001_538_790_100_634_132_976_990)); } test "38-digit number that is not an armstrong number" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(!isArmstrongNumber(99_999_999_999_999_999_999_999_999_999_999_999_999)); } test "the largest and last armstrong number" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(isArmstrongNumber(115_132_219_018_763_992_565_095_597_973_971_522_401)); } test "the largest 128-bit unsigned integer value is not an armstrong number" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(!isArmstrongNumber(340_282_366_920_938_463_463_374_607_431_768_211_455)); } diff --git a/exercises/practice/binary-search/test_binary_search.zig b/exercises/practice/binary-search/test_binary_search.zig index 5c9800c8..78be456d 100644 --- a/exercises/practice/binary-search/test_binary_search.zig +++ b/exercises/practice/binary-search/test_binary_search.zig @@ -5,6 +5,12 @@ const binary_search = @import("binary_search.zig"); const binarySearch = binary_search.binarySearch; const SearchError = binary_search.SearchError; +// Adding "return error.SkipZigTest" to the top of each test results in a compiler error +// This wrapper function around error.SkipZigTest appeases the compiler +fn skipTest() !void { + return error.SkipZigTest; +} + test "finds a value in an array with one element" { const expected: usize = 0; const actual = try binarySearch(i4, 6, &[_]i4{6}); @@ -12,51 +18,81 @@ test "finds a value in an array with one element" { } test "finds a value in the middle of an array" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 3; const actual = try binarySearch(u4, 6, &[_]u4{ 1, 3, 4, 6, 8, 9, 11 }); try testing.expectEqual(expected, actual); } test "finds a value at the beginning of an array" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 0; const actual = try binarySearch(i8, 1, &[_]i8{ 1, 3, 4, 6, 8, 9, 11 }); try testing.expectEqual(expected, actual); } test "finds a value at the end of an array" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 6; const actual = try binarySearch(u8, 11, &[_]u8{ 1, 3, 4, 6, 8, 9, 11 }); try testing.expectEqual(expected, actual); } test "finds a value in an array of odd length" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 5; const actual = try binarySearch(i16, 21, &[_]i16{ 1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 634 }); try testing.expectEqual(expected, actual); } test "finds a value in an array of even length" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 5; const actual = try binarySearch(u16, 21, &[_]u16{ 1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377 }); try testing.expectEqual(expected, actual); } test "identifies that a value is not included in the array" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expectError(SearchError.ValueAbsent, binarySearch(i32, 7, &[_]i32{ 1, 3, 4, 6, 8, 9, 11 })); } test "a value smaller than the array's smallest value is not found" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expectError(SearchError.ValueAbsent, binarySearch(u32, 0, &[_]u32{ 1, 3, 4, 6, 8, 9, 11 })); } test "a value larger than the array's largest value is not found" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expectError(SearchError.ValueAbsent, binarySearch(i64, 13, &[_]i64{ 1, 3, 4, 6, 8, 9, 11 })); } test "nothing is found in an empty array" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expectError(SearchError.EmptyBuffer, binarySearch(u64, 13, &[_]u64{})); } test "nothing is found when the left and right bounds cross" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expectError(SearchError.ValueAbsent, binarySearch(isize, 13, &[_]isize{ 1, 2 })); } diff --git a/exercises/practice/collatz-conjecture/test_collatz_conjecture.zig b/exercises/practice/collatz-conjecture/test_collatz_conjecture.zig index d87b5ba9..97ee8381 100644 --- a/exercises/practice/collatz-conjecture/test_collatz_conjecture.zig +++ b/exercises/practice/collatz-conjecture/test_collatz_conjecture.zig @@ -4,6 +4,12 @@ const testing = std.testing; const collatz_conjecture = @import("collatz_conjecture.zig"); const ComputationError = collatz_conjecture.ComputationError; +// Adding "return error.SkipZigTest" to the top of each test results in a compiler error +// This wrapper function around error.SkipZigTest appeases the compiler +fn skipTest() !void { + return error.SkipZigTest; +} + test "zero steps for one" { const expected: usize = 0; const actual = try collatz_conjecture.steps(1); @@ -11,24 +17,36 @@ test "zero steps for one" { } test "divide if even" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 4; const actual = try collatz_conjecture.steps(16); try testing.expectEqual(expected, actual); } test "even and odd steps" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 9; const actual = try collatz_conjecture.steps(12); try testing.expectEqual(expected, actual); } test "large number of even and odd steps" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 152; const actual = try collatz_conjecture.steps(1_000_000); try testing.expectEqual(expected, actual); } test "zero is an error" { + // Delete or comment out below line to run test + try skipTest(); + const expected = ComputationError.IllegalArgument; const actual = collatz_conjecture.steps(0); try testing.expectError(expected, actual); diff --git a/exercises/practice/darts/test_darts.zig b/exercises/practice/darts/test_darts.zig index f62e8c7d..f82c1947 100644 --- a/exercises/practice/darts/test_darts.zig +++ b/exercises/practice/darts/test_darts.zig @@ -3,6 +3,12 @@ const testing = std.testing; const darts = @import("darts.zig"); +// Adding "return error.SkipZigTest" to the top of each test results in a compiler error +// This wrapper function around error.SkipZigTest appeases the compiler +fn skipTest() !void { + return error.SkipZigTest; +} + test "missed target" { const expected: usize = 0; const coordinate = darts.Coordinate.init(-9.0, 9.0); @@ -11,6 +17,9 @@ test "missed target" { } test "on the outer circle" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 1; const coordinate = darts.Coordinate.init(0.0, 10.0); const actual = coordinate.score(); @@ -18,6 +27,9 @@ test "on the outer circle" { } test "on the middle circle" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 5; const coordinate = darts.Coordinate.init(-5.0, 0.0); const actual = coordinate.score(); @@ -25,6 +37,9 @@ test "on the middle circle" { } test "on the inner circle" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 10; const coordinate = darts.Coordinate.init(0.0, -1.0); const actual = coordinate.score(); @@ -32,6 +47,9 @@ test "on the inner circle" { } test "exactly on center" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 10; const coordinate = darts.Coordinate.init(0.0, 0.0); const actual = coordinate.score(); @@ -39,6 +57,9 @@ test "exactly on center" { } test "near the center" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 10; const coordinate = darts.Coordinate.init(-0.1, -0.1); const actual = coordinate.score(); @@ -46,6 +67,9 @@ test "near the center" { } test "just within the inner circle" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 10; const coordinate = darts.Coordinate.init(0.7, 0.7); const actual = coordinate.score(); @@ -53,6 +77,9 @@ test "just within the inner circle" { } test "just outside the inner circle" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 5; const coordinate = darts.Coordinate.init(0.8, -0.8); const actual = coordinate.score(); @@ -60,6 +87,9 @@ test "just outside the inner circle" { } test "just within the middle circle" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 5; const coordinate = darts.Coordinate.init(3.5, -3.5); const actual = coordinate.score(); @@ -67,6 +97,9 @@ test "just within the middle circle" { } test "just outside the middle circle" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 1; const coordinate = darts.Coordinate.init(-3.6, -3.6); const actual = coordinate.score(); @@ -74,6 +107,9 @@ test "just outside the middle circle" { } test "just within the outer circle" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 1; const coordinate = darts.Coordinate.init(-7.0, 7.0); const actual = coordinate.score(); @@ -81,6 +117,9 @@ test "just within the outer circle" { } test "just outside the outer circle" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 0; const coordinate = darts.Coordinate.init(7.1, -7.1); const actual = coordinate.score(); @@ -88,6 +127,9 @@ test "just outside the outer circle" { } test "asymmetric position between the inner and middle circles" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 5; const coordinate = darts.Coordinate.init(0.5, -4.0); const actual = coordinate.score(); diff --git a/exercises/practice/difference-of-squares/test_difference_of_squares.zig b/exercises/practice/difference-of-squares/test_difference_of_squares.zig index 4138571a..4c965f22 100644 --- a/exercises/practice/difference-of-squares/test_difference_of_squares.zig +++ b/exercises/practice/difference-of-squares/test_difference_of_squares.zig @@ -3,6 +3,12 @@ const testing = std.testing; const difference_of_squares = @import("difference_of_squares.zig"); +// Adding "return error.SkipZigTest" to the top of each test results in a compiler error +// This wrapper function around error.SkipZigTest appeases the compiler +fn skipTest() !void { + return error.SkipZigTest; +} + test "square of sum up to 1" { const expected: usize = 1; const actual = difference_of_squares.squareOfSum(1); @@ -10,48 +16,72 @@ test "square of sum up to 1" { } test "square of sum up to 5" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 225; const actual = difference_of_squares.squareOfSum(5); try testing.expectEqual(expected, actual); } test "square of sum up to 100" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 25_502_500; const actual = difference_of_squares.squareOfSum(100); try testing.expectEqual(expected, actual); } test "sum of squares up to 1" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 1; const actual = difference_of_squares.sumOfSquares(1); try testing.expectEqual(expected, actual); } test "sum of squares up to 5" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 55; const actual = difference_of_squares.sumOfSquares(5); try testing.expectEqual(expected, actual); } test "sum of squares up to 100" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 338_350; const actual = difference_of_squares.sumOfSquares(100); try testing.expectEqual(expected, actual); } test "difference of squares up to 1" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 0; const actual = difference_of_squares.differenceOfSquares(1); try testing.expectEqual(expected, actual); } test "difference of squares up to 5" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 170; const actual = difference_of_squares.differenceOfSquares(5); try testing.expectEqual(expected, actual); } test "difference of squares up to 100" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 25_164_150; const actual = difference_of_squares.differenceOfSquares(100); try testing.expectEqual(expected, actual); diff --git a/exercises/practice/grains/test_grains.zig b/exercises/practice/grains/test_grains.zig index 37f2df64..64f0c6f7 100644 --- a/exercises/practice/grains/test_grains.zig +++ b/exercises/practice/grains/test_grains.zig @@ -4,6 +4,12 @@ const testing = std.testing; const grains = @import("grains.zig"); const ChessboardError = grains.ChessboardError; +// Adding "return error.SkipZigTest" to the top of each test results in a compiler error +// This wrapper function around error.SkipZigTest appeases the compiler +fn skipTest() !void { + return error.SkipZigTest; +} + test "grains on square 1" { const expected: u64 = 1; const actual = try grains.square(1); @@ -11,54 +17,81 @@ test "grains on square 1" { } test "grains on square 2" { + // Delete or comment out below line to run test + try skipTest(); + const expected: u64 = 2; const actual = try grains.square(2); try testing.expectEqual(expected, actual); } test "grains on square 3" { + // Delete or comment out below line to run test + try skipTest(); + const expected: u64 = 4; const actual = try grains.square(3); try testing.expectEqual(expected, actual); } test "grains on square 4" { + // Delete or comment out below line to run test + try skipTest(); + const expected: u64 = 8; const actual = try grains.square(4); try testing.expectEqual(expected, actual); } test "grains on square 16" { + // Delete or comment out below line to run test + try skipTest(); + const expected: u64 = 32_768; const actual = try grains.square(16); try testing.expectEqual(expected, actual); } test "grains on square 32" { + // Delete or comment out below line to run test + try skipTest(); + const expected: u64 = 2_147_483_648; const actual = try grains.square(32); try testing.expectEqual(expected, actual); } test "grains on square 64" { + // Delete or comment out below line to run test + try skipTest(); + const expected: u64 = 9_223_372_036_854_775_808; const actual = try grains.square(64); try testing.expectEqual(expected, actual); } test "square 0 produces an error" { + // Delete or comment out below line to run test + try skipTest(); + const expected = ChessboardError.IndexOutOfBounds; const actual = grains.square(0); try testing.expectError(expected, actual); } test "square greater than 64 produces an error" { + // Delete or comment out below line to run test + try skipTest(); + const expected = ChessboardError.IndexOutOfBounds; const actual = grains.square(65); try testing.expectError(expected, actual); } test "returns the total number of grains on the board" { + // Delete or comment out below line to run test + try skipTest(); + const expected: u64 = 18_446_744_073_709_551_615; const actual = grains.total(); try testing.expectEqual(expected, actual); diff --git a/exercises/practice/hamming/test_hamming.zig b/exercises/practice/hamming/test_hamming.zig index d5729c32..b7f1724c 100644 --- a/exercises/practice/hamming/test_hamming.zig +++ b/exercises/practice/hamming/test_hamming.zig @@ -4,6 +4,12 @@ const testing = std.testing; const hamming = @import("hamming.zig"); const DnaError = hamming.DnaError; +// Adding "return error.SkipZigTest" to the top of each test results in a compiler error +// This wrapper function around error.SkipZigTest appeases the compiler +fn skipTest() !void { + return error.SkipZigTest; +} + test "empty strands" { const expected = DnaError.EmptyDnaStrands; const actual = hamming.compute("", ""); @@ -11,48 +17,72 @@ test "empty strands" { } test "single letter identical strands" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 0; const actual = try hamming.compute("A", "A"); try testing.expectEqual(expected, actual); } test "single letter different strands" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 1; const actual = try hamming.compute("G", "T"); try testing.expectEqual(expected, actual); } test "long identical strands" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 0; const actual = try hamming.compute("GGACTGAAATCTG", "GGACTGAAATCTG"); try testing.expectEqual(expected, actual); } test "long different strands" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 9; const actual = try hamming.compute("GGACGGATTCTG", "AGGACGGATTCT"); try testing.expectEqual(expected, actual); } test "disallow first strand longer" { + // Delete or comment out below line to run test + try skipTest(); + const expected = DnaError.UnequalDnaStrands; const actual = hamming.compute("AATG", "AAA"); try testing.expectError(expected, actual); } test "disallow second strand longer" { + // Delete or comment out below line to run test + try skipTest(); + const expected = DnaError.UnequalDnaStrands; const actual = hamming.compute("ATA", "AGTG"); try testing.expectError(expected, actual); } test "disallow left empty strand" { + // Delete or comment out below line to run test + try skipTest(); + const expected = DnaError.EmptyDnaStrands; const actual = hamming.compute("", "G"); try testing.expectError(expected, actual); } test "disallow right empty strand" { + // Delete or comment out below line to run test + try skipTest(); + const expected = DnaError.EmptyDnaStrands; const actual = hamming.compute("G", ""); try testing.expectError(expected, actual); diff --git a/exercises/practice/isogram/test_isogram.zig b/exercises/practice/isogram/test_isogram.zig index 8f7c219d..75fc5388 100644 --- a/exercises/practice/isogram/test_isogram.zig +++ b/exercises/practice/isogram/test_isogram.zig @@ -3,58 +3,103 @@ const testing = std.testing; const isogram = @import("isogram.zig"); +// Adding "return error.SkipZigTest" to the top of each test results in a compiler error +// This wrapper function around error.SkipZigTest appeases the compiler +fn skipTest() !void { + return error.SkipZigTest; +} + test "empty string" { try testing.expect(isogram.isIsogram("")); } test "isogram with only lower case characters" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(isogram.isIsogram("isogram")); } test "word with one duplicated character" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(!isogram.isIsogram("eleven")); } test "word with one duplicated character from the end of the alphabet" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(!isogram.isIsogram("zzyzx")); } test "longest reported english isogram" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(isogram.isIsogram("subdermatoglyphic")); } test "word with duplicated character in mixed case" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(!isogram.isIsogram("Alphabet")); } test "word with duplicated character in mixed case, lowercase first" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(!isogram.isIsogram("alphAbet")); } test "hypothetical isogrammic word with hyphen" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(isogram.isIsogram("thumbscrew-japingly")); } test "hypothetical word with duplicated character following hyphen" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(!isogram.isIsogram("thumbscrew-jappingly")); } test "isogram with duplicated hyphen" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(isogram.isIsogram("six-year-old")); } test "made-up name that is an isogram" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(isogram.isIsogram("Emily Jung Schwartzkopf")); } test "duplicated character in the middle" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(!isogram.isIsogram("accentor")); } test "same first and last characters" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(!isogram.isIsogram("angola")); } test "word with duplicated character and with two hyphens" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(!isogram.isIsogram("up-to-date")); } diff --git a/exercises/practice/leap/test_leap.zig b/exercises/practice/leap/test_leap.zig index 3ac91d3f..6b7c816a 100644 --- a/exercises/practice/leap/test_leap.zig +++ b/exercises/practice/leap/test_leap.zig @@ -3,38 +3,68 @@ const testing = std.testing; const leap = @import("leap.zig"); +// Adding "return error.SkipZigTest" to the top of each test results in a compiler error +// This wrapper function around error.SkipZigTest appeases the compiler +fn skipTest() !void { + return error.SkipZigTest; +} + test "year not divisible by 4 in common year" { try testing.expect(!leap.isLeapYear(2015)); } test "year divisible by 2, not divisible by 4 in common year" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(!leap.isLeapYear(1970)); } test "year divisible by 4, not divisible by 100 in leap year" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(leap.isLeapYear(1996)); } test "year divisible by 4 and 5 is still a leap year" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(leap.isLeapYear(1960)); } test "year divisible by 100, not divisible by 400 in common year" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(!leap.isLeapYear(2100)); } test "year divisible by 100 but not by 3 is still not a leap year" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(!leap.isLeapYear(1900)); } test "year divisible by 400 is leap year" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(leap.isLeapYear(2000)); } test "year divisible by 400 but not by 125 is still a leap year" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(leap.isLeapYear(2400)); } test "year divisible by 200, not divisible by 400 in common year" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(!leap.isLeapYear(1800)); } diff --git a/exercises/practice/pangram/test_pangram.zig b/exercises/practice/pangram/test_pangram.zig index f1aac706..6bd7f01f 100644 --- a/exercises/practice/pangram/test_pangram.zig +++ b/exercises/practice/pangram/test_pangram.zig @@ -3,42 +3,75 @@ const testing = std.testing; const pangram = @import("pangram.zig"); +// Adding "return error.SkipZigTest" to the top of each test results in a compiler error +// This wrapper function around error.SkipZigTest appeases the compiler +fn skipTest() !void { + return error.SkipZigTest; +} + test "empty sentence" { try testing.expect(!pangram.isPangram("")); } test "perfect lower case" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(pangram.isPangram("abcdefghijklmnopqrstuvwxyz")); } test "only lower case" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(pangram.isPangram("the quick brown fox jumps over the lazy dog")); } test "missing the letter 'x'" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(!pangram.isPangram("a quick movement of the enemy will jeopardize five gunboats")); } test "missing the letter 'h'" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(!pangram.isPangram("five boxing wizards jump quickly at it")); } test "with underscores" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(pangram.isPangram("the_quick_brown_fox_jumps_over_the_lazy_dog")); } test "with numbers" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(pangram.isPangram("the 1 quick brown fox jumps over the 2 lazy dogs")); } test "missing letters replaced by numbers" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(!pangram.isPangram("7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog")); } test "mixed case and punctuation" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(pangram.isPangram("\"Five quacking Zephyrs jolt my wax bed.\"")); } test "a-m and A-M are 26 different characters but not a pangram" { + // Delete or comment out below line to run test + try skipTest(); + try testing.expect(!pangram.isPangram("abcdefghijklm ABCDEFGHIJKLM")); } diff --git a/exercises/practice/proverb/test_proverb.zig b/exercises/practice/proverb/test_proverb.zig index e612c28f..e9c565b9 100644 --- a/exercises/practice/proverb/test_proverb.zig +++ b/exercises/practice/proverb/test_proverb.zig @@ -3,6 +3,12 @@ const testing = std.testing; const proverb = @import("proverb.zig"); +// Adding "return error.SkipZigTest" to the top of each test results in a compiler error +// This wrapper function around error.SkipZigTest appeases the compiler +fn skipTest() !void { + return error.SkipZigTest; +} + test "zero pieces" { const array_long = [_][]const u8{}; const input_slice = &array_long; @@ -21,6 +27,9 @@ test "zero pieces" { } test "one piece" { + // Delete or comment out below line to run test + try skipTest(); + const first_input = "nail".*; const first_slice = &first_input; const input_array = [_][]const u8{first_slice}; @@ -44,6 +53,9 @@ test "one piece" { } test "two pieces" { + // Delete or comment out below line to run test + try skipTest(); + const first_input = "nail".*; const first_slice = &first_input; const second_input = "shoe".*; @@ -71,6 +83,9 @@ test "two pieces" { } test "three pieces" { + // Delete or comment out below line to run test + try skipTest(); + const first_input = "nail".*; const first_slice = &first_input; const second_input = "shoe".*; @@ -102,6 +117,9 @@ test "three pieces" { } test "full proverb" { + // Delete or comment out below line to run test + try skipTest(); + const first_input = "nail".*; const first_slice = &first_input; const second_input = "shoe".*; @@ -149,6 +167,9 @@ test "full proverb" { } test "four pieces modernized" { + // Delete or comment out below line to run test + try skipTest(); + const first_input = "pin".*; const first_slice = &first_input; const second_input = "gun".*; diff --git a/exercises/practice/queen-attack/test_queen_attack.zig b/exercises/practice/queen-attack/test_queen_attack.zig index 5511811a..7a90fb1d 100644 --- a/exercises/practice/queen-attack/test_queen_attack.zig +++ b/exercises/practice/queen-attack/test_queen_attack.zig @@ -4,11 +4,20 @@ const testing = std.testing; const queen_attack = @import("queen_attack.zig"); const QueenError = queen_attack.QueenError; +// Adding "return error.SkipZigTest" to the top of each test results in a compiler error +// This wrapper function around error.SkipZigTest appeases the compiler +fn skipTest() !void { + return error.SkipZigTest; +} + test "queen has exactly two fields" { try testing.expectEqual(2, std.meta.fields(queen_attack.Queen).len); } test "queen with a valid position" { + // Delete or comment out below line to run test + try skipTest(); + const queen = try queen_attack.Queen.init(2, 2); // Allow the fields to have any name. const fields = std.meta.fields(@TypeOf(queen)); @@ -20,68 +29,104 @@ test "queen with a valid position" { } test "queen must have positive row" { + // Delete or comment out below line to run test + try skipTest(); + const queen = queen_attack.Queen.init(-2, 2); try testing.expectError(QueenError.InitializationFailure, queen); } test "queen must have row on board" { + // Delete or comment out below line to run test + try skipTest(); + const queen = queen_attack.Queen.init(8, 4); try testing.expectError(QueenError.InitializationFailure, queen); } test "queen must have positive column" { + // Delete or comment out below line to run test + try skipTest(); + const queen = queen_attack.Queen.init(2, -2); try testing.expectError(QueenError.InitializationFailure, queen); } test "queen must have column on board" { + // Delete or comment out below line to run test + try skipTest(); + const queen = queen_attack.Queen.init(4, 8); try testing.expectError(QueenError.InitializationFailure, queen); } test "cannot attack" { + // Delete or comment out below line to run test + try skipTest(); + const white = try queen_attack.Queen.init(2, 4); const black = try queen_attack.Queen.init(6, 6); try testing.expect(!try white.canAttack(black)); } test "can attack on same row" { + // Delete or comment out below line to run test + try skipTest(); + const white = try queen_attack.Queen.init(2, 4); const black = try queen_attack.Queen.init(2, 6); try testing.expect(try white.canAttack(black)); } test "can attack on same column" { + // Delete or comment out below line to run test + try skipTest(); + const white = try queen_attack.Queen.init(4, 5); const black = try queen_attack.Queen.init(2, 5); try testing.expect(try white.canAttack(black)); } test "can attack on first diagonal" { + // Delete or comment out below line to run test + try skipTest(); + const white = try queen_attack.Queen.init(2, 2); const black = try queen_attack.Queen.init(0, 4); try testing.expect(try white.canAttack(black)); } test "can attack on second diagonal" { + // Delete or comment out below line to run test + try skipTest(); + const white = try queen_attack.Queen.init(2, 2); const black = try queen_attack.Queen.init(3, 1); try testing.expect(try white.canAttack(black)); } test "can attack on third diagonal" { + // Delete or comment out below line to run test + try skipTest(); + const white = try queen_attack.Queen.init(2, 2); const black = try queen_attack.Queen.init(1, 1); try testing.expect(try white.canAttack(black)); } test "can attack on fourth diagonal" { + // Delete or comment out below line to run test + try skipTest(); + const white = try queen_attack.Queen.init(1, 7); const black = try queen_attack.Queen.init(0, 6); try testing.expect(try white.canAttack(black)); } test "cannot attack if falling diagonals are only the same when reflected across the longest falling diagonal" { + // Delete or comment out below line to run test + try skipTest(); + const white = try queen_attack.Queen.init(4, 1); const black = try queen_attack.Queen.init(2, 5); try testing.expect(!try white.canAttack(black)); diff --git a/exercises/practice/resistor-color-duo/test_resistor_color_duo.zig b/exercises/practice/resistor-color-duo/test_resistor_color_duo.zig index 11fa0788..c7692925 100644 --- a/exercises/practice/resistor-color-duo/test_resistor_color_duo.zig +++ b/exercises/practice/resistor-color-duo/test_resistor_color_duo.zig @@ -4,6 +4,12 @@ const testing = std.testing; const resistor_color_duo = @import("resistor_color_duo.zig"); const ColorBand = resistor_color_duo.ColorBand; +// Adding "return error.SkipZigTest" to the top of each test results in a compiler error +// This wrapper function around error.SkipZigTest appeases the compiler +fn skipTest() !void { + return error.SkipZigTest; +} + test "brown and black" { const array = [_]ColorBand{ .brown, .black }; const expected: usize = 10; @@ -12,6 +18,9 @@ test "brown and black" { } test "blue and grey" { + // Delete or comment out below line to run test + try skipTest(); + const array = [_]ColorBand{ .blue, .grey }; const expected: usize = 68; const actual = resistor_color_duo.colorCode(array); @@ -19,6 +28,9 @@ test "blue and grey" { } test "yellow and violet" { + // Delete or comment out below line to run test + try skipTest(); + const array = [_]ColorBand{ .yellow, .violet }; const expected: usize = 47; const actual = resistor_color_duo.colorCode(array); @@ -26,6 +38,9 @@ test "yellow and violet" { } test "white and red" { + // Delete or comment out below line to run test + try skipTest(); + const array = [_]ColorBand{ .white, .red }; const expected: usize = 92; const actual = resistor_color_duo.colorCode(array); @@ -33,6 +48,9 @@ test "white and red" { } test "orange and orange" { + // Delete or comment out below line to run test + try skipTest(); + const array = [_]ColorBand{ .orange, .orange }; const expected: usize = 33; const actual = resistor_color_duo.colorCode(array); @@ -40,6 +58,9 @@ test "orange and orange" { } test "black and brown, one-digit" { + // Delete or comment out below line to run test + try skipTest(); + const array = [_]ColorBand{ .black, .brown }; const expected: usize = 1; const actual = resistor_color_duo.colorCode(array); diff --git a/exercises/practice/resistor-color/test_resistor_color.zig b/exercises/practice/resistor-color/test_resistor_color.zig index eb0e0838..4cd8f3fa 100644 --- a/exercises/practice/resistor-color/test_resistor_color.zig +++ b/exercises/practice/resistor-color/test_resistor_color.zig @@ -4,6 +4,12 @@ const testing = std.testing; const resistor_color = @import("resistor_color.zig"); const ColorBand = resistor_color.ColorBand; +// Adding "return error.SkipZigTest" to the top of each test results in a compiler error +// This wrapper function around error.SkipZigTest appeases the compiler +fn skipTest() !void { + return error.SkipZigTest; +} + test "black" { const expected: usize = 0; const actual = resistor_color.colorCode(.black); @@ -11,18 +17,27 @@ test "black" { } test "white" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 9; const actual = resistor_color.colorCode(.white); try testing.expectEqual(expected, actual); } test "orange" { + // Delete or comment out below line to run test + try skipTest(); + const expected: usize = 3; const actual = resistor_color.colorCode(.orange); try testing.expectEqual(expected, actual); } test "colors" { + // Delete or comment out below line to run test + try skipTest(); + const expected = &[_]ColorBand{ .black, .brown, .red, .orange, .yellow, .green, .blue, .violet, .grey, .white, diff --git a/exercises/practice/rna-transcription/test_rna_transcription.zig b/exercises/practice/rna-transcription/test_rna_transcription.zig index 8d13c6bc..da2a44f3 100644 --- a/exercises/practice/rna-transcription/test_rna_transcription.zig +++ b/exercises/practice/rna-transcription/test_rna_transcription.zig @@ -11,26 +11,47 @@ fn testTranscription(dna: []const u8, expected: []const u8) !void { testing.allocator.free(rna); } +// Adding "return error.SkipZigTest" to the top of each test results in a compiler error +// This wrapper function around error.SkipZigTest appeases the compiler +fn skipTest() !void { + return error.SkipZigTest; +} + test "empty rna sequence" { try testTranscription("", ""); } test "rna complement of cytosine is guanine" { + // Delete or comment out below line to run test + try skipTest(); + try testTranscription("C", "G"); } test "rna complement of guanine is cytosine" { + // Delete or comment out below line to run test + try skipTest(); + try testTranscription("G", "C"); } test "rna complement of thymine is adenine" { + // Delete or comment out below line to run test + try skipTest(); + try testTranscription("T", "A"); } test "rna complement of adenine is uracil" { + // Delete or comment out below line to run test + try skipTest(); + try testTranscription("A", "U"); } test "rna complement" { + // Delete or comment out below line to run test + try skipTest(); + try testTranscription("ACGTGGTCTTAA", "UGCACCAGAAUU"); } diff --git a/exercises/practice/secret-handshake/test_secret_handshake.zig b/exercises/practice/secret-handshake/test_secret_handshake.zig index f15a5844..fd94d8d2 100644 --- a/exercises/practice/secret-handshake/test_secret_handshake.zig +++ b/exercises/practice/secret-handshake/test_secret_handshake.zig @@ -3,6 +3,12 @@ const testing = std.testing; const secret_handshake = @import("secret_handshake.zig"); +// Adding "return error.SkipZigTest" to the top of each test results in a compiler error +// This wrapper function around error.SkipZigTest appeases the compiler +fn skipTest() !void { + return error.SkipZigTest; +} + test "wink for 1" { const expected = &[_]secret_handshake.Signal{.wink}; const actual = try secret_handshake.calculateHandshake(testing.allocator, 1); @@ -11,6 +17,9 @@ test "wink for 1" { } test "double blink for 10" { + // Delete or comment out below line to run test + try skipTest(); + const expected = &[_]secret_handshake.Signal{.double_blink}; const actual = try secret_handshake.calculateHandshake(testing.allocator, 2); defer testing.allocator.free(actual); @@ -18,6 +27,9 @@ test "double blink for 10" { } test "close your eyes for 100" { + // Delete or comment out below line to run test + try skipTest(); + const expected = &[_]secret_handshake.Signal{.close_your_eyes}; const actual = try secret_handshake.calculateHandshake(testing.allocator, 4); defer testing.allocator.free(actual); @@ -25,6 +37,9 @@ test "close your eyes for 100" { } test "jump for 1000" { + // Delete or comment out below line to run test + try skipTest(); + const expected = &[_]secret_handshake.Signal{.jump}; const actual = try secret_handshake.calculateHandshake(testing.allocator, 8); defer testing.allocator.free(actual); @@ -32,6 +47,9 @@ test "jump for 1000" { } test "combine two actions" { + // Delete or comment out below line to run test + try skipTest(); + const expected = &[_]secret_handshake.Signal{ .wink, .double_blink }; const actual = try secret_handshake.calculateHandshake(testing.allocator, 3); defer testing.allocator.free(actual); @@ -39,6 +57,9 @@ test "combine two actions" { } test "reverse two actions" { + // Delete or comment out below line to run test + try skipTest(); + const expected = &[_]secret_handshake.Signal{ .double_blink, .wink }; const actual = try secret_handshake.calculateHandshake(testing.allocator, 19); defer testing.allocator.free(actual); @@ -46,6 +67,9 @@ test "reverse two actions" { } test "reversing one action gives the same action" { + // Delete or comment out below line to run test + try skipTest(); + const expected = &[_]secret_handshake.Signal{.jump}; const actual = try secret_handshake.calculateHandshake(testing.allocator, 24); defer testing.allocator.free(actual); @@ -53,6 +77,9 @@ test "reversing one action gives the same action" { } test "reversing no actions still gives no actions" { + // Delete or comment out below line to run test + try skipTest(); + const expected = &[_]secret_handshake.Signal{}; const actual = try secret_handshake.calculateHandshake(testing.allocator, 16); defer testing.allocator.free(actual); @@ -60,6 +87,9 @@ test "reversing no actions still gives no actions" { } test "all possible actions" { + // Delete or comment out below line to run test + try skipTest(); + const expected = &[_]secret_handshake.Signal{ .wink, .double_blink, .close_your_eyes, .jump }; const actual = try secret_handshake.calculateHandshake(testing.allocator, 15); defer testing.allocator.free(actual); @@ -67,6 +97,9 @@ test "all possible actions" { } test "reverse all possible actions" { + // Delete or comment out below line to run test + try skipTest(); + const expected = &[_]secret_handshake.Signal{ .jump, .close_your_eyes, .double_blink, .wink }; const actual = try secret_handshake.calculateHandshake(testing.allocator, 31); defer testing.allocator.free(actual); @@ -74,6 +107,9 @@ test "reverse all possible actions" { } test "do nothing for zero" { + // Delete or comment out below line to run test + try skipTest(); + const expected = &[_]secret_handshake.Signal{}; const actual = try secret_handshake.calculateHandshake(testing.allocator, 0); defer testing.allocator.free(actual); diff --git a/exercises/practice/space-age/test_space_age.zig b/exercises/practice/space-age/test_space_age.zig index 918879ee..a4ac1eb8 100644 --- a/exercises/practice/space-age/test_space_age.zig +++ b/exercises/practice/space-age/test_space_age.zig @@ -10,34 +10,61 @@ fn testAge(planet: Planet, seconds: usize, expected_age_in_earth_years: f64) !vo try expectApproxEqAbs(expected_age_in_earth_years, actual, tolerance); } +// Adding "return error.SkipZigTest" to the top of each test results in a compiler error +// This wrapper function around error.SkipZigTest appeases the compiler +fn skipTest() !void { + return error.SkipZigTest; +} + test "age on earth" { try testAge(Planet.earth, 1_000_000_000, 31.69); } test "age on mercury" { + // Delete or comment out below line to run test + try skipTest(); + try testAge(Planet.mercury, 2_134_835_688, 280.88); } test "age on venus" { + // Delete or comment out below line to run test + try skipTest(); + try testAge(Planet.venus, 189_839_836, 9.78); } test "age on mars" { + // Delete or comment out below line to run test + try skipTest(); + try testAge(Planet.mars, 2_129_871_239, 35.88); } test "age on jupiter" { + // Delete or comment out below line to run test + try skipTest(); + try testAge(Planet.jupiter, 901_876_382, 2.41); } test "age on saturn" { + // Delete or comment out below line to run test + try skipTest(); + try testAge(Planet.saturn, 2_000_000_000, 2.15); } test "age on uranus" { + // Delete or comment out below line to run test + try skipTest(); + try testAge(Planet.uranus, 1_210_123_456, 0.46); } test "age on neptune" { + // Delete or comment out below line to run test + try skipTest(); + try testAge(Planet.neptune, 1_821_023_456, 0.35); } diff --git a/exercises/practice/triangle/test_triangle.zig b/exercises/practice/triangle/test_triangle.zig index 5508de80..be62c70b 100644 --- a/exercises/practice/triangle/test_triangle.zig +++ b/exercises/practice/triangle/test_triangle.zig @@ -3,107 +3,173 @@ const testing = std.testing; const triangle = @import("triangle.zig"); +// Adding "return error.SkipZigTest" to the top of each test results in a compiler error +// This wrapper function around error.SkipZigTest appeases the compiler +fn skipTest() !void { + return error.SkipZigTest; +} + test "equilateral all sides are equal" { const actual = try triangle.Triangle.init(2, 2, 2); try testing.expect(actual.isEquilateral()); } test "equilateral any side is unequal" { + // Delete or comment out below line to run test + try skipTest(); + const actual = try triangle.Triangle.init(2, 3, 2); try testing.expect(!actual.isEquilateral()); } test "equilateral no sides are equal" { + // Delete or comment out below line to run test + try skipTest(); + const actual = try triangle.Triangle.init(5, 4, 6); try testing.expect(!actual.isEquilateral()); } test "equilateral all zero sides is not a triangle" { + // Delete or comment out below line to run test + try skipTest(); + const actual = triangle.Triangle.init(0, 0, 0); try testing.expectError(triangle.TriangleError.Degenerate, actual); } test "equilateral sides may be floats" { + // Delete or comment out below line to run test + try skipTest(); + const actual = try triangle.Triangle.init(0.5, 0.5, 0.5); try testing.expect(actual.isEquilateral()); } test "isosceles last two sides are equal" { + // Delete or comment out below line to run test + try skipTest(); + const actual = try triangle.Triangle.init(3, 4, 4); try testing.expect(actual.isIsosceles()); } test "isosceles first two sides are equal" { + // Delete or comment out below line to run test + try skipTest(); + const actual = try triangle.Triangle.init(4, 4, 3); try testing.expect(actual.isIsosceles()); } test "isosceles first and last sides are equal" { + // Delete or comment out below line to run test + try skipTest(); + const actual = try triangle.Triangle.init(4, 3, 4); try testing.expect(actual.isIsosceles()); } test "equilateral triangles are also isosceles" { + // Delete or comment out below line to run test + try skipTest(); + const actual = try triangle.Triangle.init(4, 3, 4); try testing.expect(actual.isIsosceles()); } test "isosceles no sides are equal" { + // Delete or comment out below line to run test + try skipTest(); + const actual = try triangle.Triangle.init(2, 3, 4); try testing.expect(!actual.isIsosceles()); } test "isosceles first triangle inequality violation" { + // Delete or comment out below line to run test + try skipTest(); + const actual = triangle.Triangle.init(1, 1, 3); try testing.expectError(triangle.TriangleError.InvalidInequality, actual); } test "isosceles second triangle inequality violation" { + // Delete or comment out below line to run test + try skipTest(); + const actual = triangle.Triangle.init(1, 3, 1); try testing.expectError(triangle.TriangleError.InvalidInequality, actual); } test "isosceles third triangle inequality violation" { + // Delete or comment out below line to run test + try skipTest(); + const actual = triangle.Triangle.init(3, 1, 1); try testing.expectError(triangle.TriangleError.InvalidInequality, actual); } test "isosceles sides may be floats" { + // Delete or comment out below line to run test + try skipTest(); + const actual = try triangle.Triangle.init(0.5, 0.4, 0.5); try testing.expect(actual.isIsosceles()); } test "scalene no sides are equal" { + // Delete or comment out below line to run test + try skipTest(); + const actual = try triangle.Triangle.init(5, 4, 6); try testing.expect(actual.isScalene()); } test "scalene all sides are equal" { + // Delete or comment out below line to run test + try skipTest(); + const actual = try triangle.Triangle.init(4, 4, 4); try testing.expect(!actual.isScalene()); } test "scalene first and second sides are equal" { + // Delete or comment out below line to run test + try skipTest(); + const actual = try triangle.Triangle.init(4, 4, 3); try testing.expect(!actual.isScalene()); } test "scalene first and third sides are equal" { + // Delete or comment out below line to run test + try skipTest(); + const actual = try triangle.Triangle.init(3, 4, 3); try testing.expect(!actual.isScalene()); } test "scalene second and third sides are equal" { + // Delete or comment out below line to run test + try skipTest(); + const actual = try triangle.Triangle.init(4, 3, 3); try testing.expect(!actual.isScalene()); } test "scalene may not violate triangle inequality" { + // Delete or comment out below line to run test + try skipTest(); + const actual = triangle.Triangle.init(7, 3, 2); try testing.expectError(triangle.TriangleError.InvalidInequality, actual); } test "scalene sides may be floats" { + // Delete or comment out below line to run test + try skipTest(); + const actual = try triangle.Triangle.init(0.5, 0.4, 0.6); try testing.expect(actual.isScalene()); } diff --git a/exercises/practice/two-fer/test_two_fer.zig b/exercises/practice/two-fer/test_two_fer.zig index cba8ad17..cccaf1ce 100644 --- a/exercises/practice/two-fer/test_two_fer.zig +++ b/exercises/practice/two-fer/test_two_fer.zig @@ -5,6 +5,12 @@ const two_fer = @import("two_fer.zig"); const buffer_size = 100; +// Adding "return error.SkipZigTest" to the top of each test results in a compiler error +// This wrapper function around error.SkipZigTest appeases the compiler +fn skipTest() !void { + return error.SkipZigTest; +} + test "no name given" { var response: [buffer_size]u8 = undefined; const expected = "One for you, one for me."; @@ -13,6 +19,9 @@ test "no name given" { } test "a name given" { + // Delete or comment out below line to run test + try skipTest(); + var response: [buffer_size]u8 = undefined; const expected = "One for Alice, one for me."; const actual = try two_fer.twoFer(&response, "Alice"); @@ -20,6 +29,9 @@ test "a name given" { } test "another name given" { + // Delete or comment out below line to run test + try skipTest(); + var response: [buffer_size]u8 = undefined; const expected = "One for Bob, one for me."; const actual = try two_fer.twoFer(&response, "Bob");