Skip to content

Commit

Permalink
exercises(collatz-conjecture): remove test for negative input (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
ee7 authored Mar 3, 2023
1 parent b7cd99f commit de5aff6
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
3 changes: 3 additions & 0 deletions exercises/practice/collatz-conjecture/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"authors": [
"massivelivefun"
],
"contributors": [
"ee7"
],
"files": {
"solution": [
"collatz_conjecture.zig"
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/collatz-conjecture/.meta/example.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions exercises/practice/collatz-conjecture/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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");
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit de5aff6

Please sign in to comment.