From 4ac3b8222a142a5676ebbedaa897ef334d686e6c Mon Sep 17 00:00:00 2001 From: Ben Brumm Date: Tue, 2 Jul 2024 10:45:26 +1000 Subject: [PATCH] Added more tests --- courses/course_effective_plsql/69_more.sql | 87 ++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 courses/course_effective_plsql/69_more.sql diff --git a/courses/course_effective_plsql/69_more.sql b/courses/course_effective_plsql/69_more.sql new file mode 100644 index 0000000..f71d481 --- /dev/null +++ b/courses/course_effective_plsql/69_more.sql @@ -0,0 +1,87 @@ +CREATE OR REPLACE PACKAGE test_dividetwonumbers AS + --%suite(Divide Two Numbers) + + --%test(Returns a number from a simple calculation) + PROCEDURE basic_calc; + + --%test(Another test for calculating a division) + PROCEDURE another_calc; +END; + +CREATE OR REPLACE PACKAGE BODY test_dividetwonumbers AS + PROCEDURE basic_calc AS + v_actual NUMBER; + v_expected NUMBER; + BEGIN + v_expected := 3; + DivideTwoNumbers(15, 5, v_actual); + ut.expect(v_actual).to_equal(v_expected); + END; + + PROCEDURE another_calc AS + v_actual NUMBER; + v_expected NUMBER; + BEGIN + v_expected := 70; + DivideTwoNumbers(14, 2, v_actual); + ut.expect(v_actual).to_equal(v_expected); + END; +END; + + + +BEGIN + ut.run('test_dividetwonumbers'); +END; + +/* +Add test of divide by zero +*/ + + +CREATE OR REPLACE PACKAGE test_dividetwonumbers AS + --%suite(Divide Two Numbers) + + --%test(Returns a number from a simple calculation) + PROCEDURE basic_calc; + + --%test(Another test for calculating a division) + PROCEDURE another_calc; + + --%test(Divide by zero) + PROCEDURE divide_by_zero; +END; + +CREATE OR REPLACE PACKAGE BODY test_dividetwonumbers AS + PROCEDURE basic_calc AS + v_actual NUMBER; + v_expected NUMBER; + BEGIN + v_expected := 3; + DivideTwoNumbers(15, 5, v_actual); + ut.expect(v_actual).to_equal(v_expected); + END; + + PROCEDURE another_calc AS + v_actual NUMBER; + v_expected NUMBER; + BEGIN + v_expected := 7; + DivideTwoNumbers(14, 2, v_actual); + ut.expect(v_actual).to_equal(v_expected); + END; + + PROCEDURE divide_by_zero AS + v_actual NUMBER; + v_expected NUMBER; + BEGIN + v_expected := 0; + DivideTwoNumbers(11, 0, v_actual); + ut.expect(v_actual).to_equal(v_expected); + END; +END; + + +BEGIN + ut.run('test_dividetwonumbers'); +END;