From d172a5a5b933c149ecf1c62ae35db3bb6c8b9519 Mon Sep 17 00:00:00 2001 From: Brenda Anderson Date: Mon, 19 Feb 2018 16:54:06 +1300 Subject: [PATCH] add resize factor checks Add checks for negative, zero, and >100 resize arguments. --- cs50/2017/fall/resize/less/check50/__init__.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cs50/2017/fall/resize/less/check50/__init__.py b/cs50/2017/fall/resize/less/check50/__init__.py index 110cae7..e169021 100644 --- a/cs50/2017/fall/resize/less/check50/__init__.py +++ b/cs50/2017/fall/resize/less/check50/__init__.py @@ -81,6 +81,21 @@ def exists(self): def compiles(self): """resize.c compiles.""" self.spawn("clang -std=c11 -o resize resize.c -lm -lcs50").exit(0) + + @check("compiles") + def negfactor(self): + """rejects a negative factor""" + self.spawn("./resize -1 small.bmp outfile.bmp").exit(1) + + @check("compiles") + def zerofactor(self): + """rejects a factor of zero""" + self.spawn("./resize 0 small.bmp outfile.bmp").exit(1) + + @check("compiles") + def toolargefactor(self): + """rejects a factor > 100""" + self.spawn("./resize 101 small.bmp outfile.bmp").exit(1) @check("compiles") def small_1(self):