Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grains error message and test cases updated #67

Merged
merged 6 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions exercises/practice/grains/.docs/instructions.append.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Independent of other languages

However, the king ran out of grains to give the servant after day 31 since 1,073,741,824 grains is approximately 54 metric tons.
As a 32-bit language, Batch can't represent the number of grains past this point.
6 changes: 3 additions & 3 deletions exercises/practice/grains/.meta/Example.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ setlocal EnableDelayedExpansion
set "input=%~1"

if %input% LSS 1 (
echo square must be between 1 and 64
echo square must be between 1 and 31
exit /b 1
)

if %input% GTR 64 (
echo square must be between 1 and 64
if %input% GTR 31 (
echo square must be between 1 and 31
exit /b 1
)

Expand Down
5 changes: 5 additions & 0 deletions exercises/practice/grains/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ description = "returns the number of grains on the square -> grains on square 16

[acd81b46-c2ad-4951-b848-80d15ed5a04f]
description = "returns the number of grains on the square -> grains on square 32"
include = false
comment = "Batch is 32-bit so square 31 is maximum possible"

[c73b470a-5efb-4d53-9ac6-c5f6487f227b]
description = "returns the number of grains on the square -> grains on square 64"
include = false
comment = "Batch is 32-bit so square 31 is maximum possible"

[1d47d832-3e85-4974-9466-5bd35af484e3]
description = "returns the number of grains on the square -> square 0 is invalid"
Expand All @@ -39,6 +42,8 @@ description = "returns the number of grains on the square -> negative square is

[a95e4374-f32c-45a7-a10d-ffec475c012f]
description = "returns the number of grains on the square -> square greater than 64 is invalid"
include = false
comment = "Batch is 32-bit so the test description, input, and expected value all were changed"

[6eb07385-3659-4b45-a6be-9dc474222750]
description = "returns the total number of grains on the board"
Expand Down
8 changes: 4 additions & 4 deletions exercises/practice/grains/GrainsTest.bat
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ if "%1" == "test-runner" (
set "if_failed=Test failed: grains on square 31."
CALL :Assert "31"

set "expected=square must be between 1 and 64"
set "expected=square must be between 1 and 31"
set "if_success=Test passed"
set "if_failed=Test failed: square 0 is invalid."
CALL :Assert "0"

set "expected=square must be between 1 and 64"
set "expected=square must be between 1 and 31"
set "if_success=Test passed"
set "if_failed=Test failed: negative square is invalid."
CALL :Assert "-1"

set "expected=square must be between 1 and 64"
set "expected=square must be between 1 and 31"
set "if_success=Test passed"
set "if_failed=Test failed: square greater than 64 is invalid."
set "if_failed=Test failed: square greater than 31 is invalid."
CALL :Assert "65"

REM --------------------
Expand Down