Skip to content

Commit

Permalink
Added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Brumm committed Jul 2, 2024
1 parent 9780d35 commit 4ac3b82
Showing 1 changed file with 87 additions and 0 deletions.
87 changes: 87 additions & 0 deletions courses/course_effective_plsql/69_more.sql
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 4ac3b82

Please sign in to comment.