From a1e19a0ac507e72e9131e22b60df14b089bc4906 Mon Sep 17 00:00:00 2001 From: Brenda Anderson Date: Tue, 11 Jun 2019 13:23:06 +1200 Subject: [PATCH] update caesar checks for new requirements Add two more tests for caesar per the changes to the spec for 2018, namely * if the user provides no command-line arguments, or two or more, it prints Usage: ./caesar key. * checks to make sure that each character of that command line argument is a decimal digit (i.e., 0, 1, 2, etc.) and, if any of them are not, terminates (with a return code of 1) after printing the message Usage: ./caesar key. --- cs50/2019/x/caesar/check50/__init__.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cs50/2019/x/caesar/check50/__init__.py b/cs50/2019/x/caesar/check50/__init__.py index 2e463d8..7a647a9 100644 --- a/cs50/2019/x/caesar/check50/__init__.py +++ b/cs50/2019/x/caesar/check50/__init__.py @@ -47,3 +47,15 @@ def checks_for_handling_non_alpha(self): def handles_no_argv(self): """handles lack of argv[1]""" self.spawn("./caesar").exit(1) + + @check("compiles") + def toomanyargs(self): + """handles argc > 2""" + self.spawn("./caesar 1 2 3").exit(1) + + @check("compiles") + def rejects_non_numeric(self): + """rejects non-numeric argv[1]""" + self.spawn("./caesar 2a!").exit(1) + +