From de5aff6c33e696116e65e67809ef0e7c299abe7d Mon Sep 17 00:00:00 2001 From: ee7 <45465154+ee7@users.noreply.github.com> Date: Fri, 3 Mar 2023 14:25:43 +0100 Subject: [PATCH] exercises(collatz-conjecture): remove test for negative input (#209) --- exercises/practice/collatz-conjecture/.meta/config.json | 3 +++ exercises/practice/collatz-conjecture/.meta/example.zig | 4 ++-- exercises/practice/collatz-conjecture/.meta/tests.toml | 1 + .../practice/collatz-conjecture/collatz_conjecture.zig | 2 +- .../practice/collatz-conjecture/test_collatz_conjecture.zig | 6 ------ 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/exercises/practice/collatz-conjecture/.meta/config.json b/exercises/practice/collatz-conjecture/.meta/config.json index 8bf7738d..442e62e9 100644 --- a/exercises/practice/collatz-conjecture/.meta/config.json +++ b/exercises/practice/collatz-conjecture/.meta/config.json @@ -2,6 +2,9 @@ "authors": [ "massivelivefun" ], + "contributors": [ + "ee7" + ], "files": { "solution": [ "collatz_conjecture.zig" diff --git a/exercises/practice/collatz-conjecture/.meta/example.zig b/exercises/practice/collatz-conjecture/.meta/example.zig index 42698576..fc849d41 100644 --- a/exercises/practice/collatz-conjecture/.meta/example.zig +++ b/exercises/practice/collatz-conjecture/.meta/example.zig @@ -2,8 +2,8 @@ pub const ComputationError = error{ IllegalArgument, }; -pub fn steps(start: isize) ComputationError!usize { - if (start <= 0) { +pub fn steps(start: usize) ComputationError!usize { + if (start == 0) { return ComputationError.IllegalArgument; } var number = start; diff --git a/exercises/practice/collatz-conjecture/.meta/tests.toml b/exercises/practice/collatz-conjecture/.meta/tests.toml index cc34e168..45bf122e 100644 --- a/exercises/practice/collatz-conjecture/.meta/tests.toml +++ b/exercises/practice/collatz-conjecture/.meta/tests.toml @@ -36,3 +36,4 @@ include = false [ec11f479-56bc-47fd-a434-bcd7a31a7a2e] description = "negative value is an error" reimplements = "c6c795bf-a288-45e9-86a1-841359ad426d" +include = false diff --git a/exercises/practice/collatz-conjecture/collatz_conjecture.zig b/exercises/practice/collatz-conjecture/collatz_conjecture.zig index e336208b..21ffc04c 100644 --- a/exercises/practice/collatz-conjecture/collatz_conjecture.zig +++ b/exercises/practice/collatz-conjecture/collatz_conjecture.zig @@ -1,4 +1,4 @@ -pub fn steps(number: isize) anyerror!usize { +pub fn steps(number: usize) anyerror!usize { _ = number; @compileError("please implement the steps function"); } diff --git a/exercises/practice/collatz-conjecture/test_collatz_conjecture.zig b/exercises/practice/collatz-conjecture/test_collatz_conjecture.zig index fe0e31b0..4cf1414e 100644 --- a/exercises/practice/collatz-conjecture/test_collatz_conjecture.zig +++ b/exercises/practice/collatz-conjecture/test_collatz_conjecture.zig @@ -33,9 +33,3 @@ test "zero is an error" { const actual = comptime collatz_conjecture.steps(0); try testing.expectError(expected, actual); } - -test "negative value is an error" { - const expected = ComputationError.IllegalArgument; - const actual = comptime collatz_conjecture.steps(-15); - try testing.expectError(expected, actual); -}