There was an error while loading. Please reload this page.
1 parent 7c6287d commit c94a891Copy full SHA for c94a891
src/Basic.test.js
@@ -0,0 +1,22 @@
1
+function rectangle_area(width, height) {
2
+ if (width <= 0 || height <= 0) {
3
+ return 0;
4
+ }
5
+ return width * height;
6
+}
7
+
8
+test('Normal rectangle area, width > 0 and height > 0', () => {
9
+ const rect1 = rectangle_area(8, 6);
10
+ expect(rect1).toBe(48);
11
+});
12
13
+test('Zero rectangle area, width <= 0 or height <= 0', () => {
14
+ const rect1 = rectangle_area(-4, 6);
15
+ expect(rect1).toBe(0);
16
17
+ const rect2 = rectangle_area(4, -6);
18
+ expect(rect2).toBe(0);
19
20
+ const rect3 = rectangle_area(-4, -6);
21
+ expect(rect3).toBe(0);
22
0 commit comments