File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
main/java/com/examplehub/maths
test/java/com/examplehub/maths Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .examplehub .maths ;
2+
3+ public class Floor {
4+ public static int floor (double number ) {
5+ return number - (int ) number >= 0 ? (int ) number : (int ) number - 1 ;
6+ }
7+ }
Original file line number Diff line number Diff line change 1+ package com .examplehub .maths ;
2+
3+ import org .junit .jupiter .api .Test ;
4+
5+ import static org .junit .jupiter .api .Assertions .*;
6+
7+ class FloorTest {
8+ @ Test
9+ void testFloor () {
10+ assertEquals (Math .floor (123.45 ), Floor .floor (123.45 ));
11+ assertEquals (Math .floor (3.14 ), Floor .floor (3.14 ));
12+ assertEquals (Math .floor (1 ), Floor .floor (1 ));
13+ assertEquals (Math .floor (0 ), Floor .floor (0 ));
14+ assertEquals (Math .floor (-3.14 ), Floor .floor (-3.14 ));
15+ assertEquals (Math .floor (-3.14 ), Floor .floor (-3.14 ));
16+ assertEquals (Math .floor (-3 ), Floor .floor (-3 ));
17+ assertEquals (Math .floor (-123.45 ), Floor .floor (-123.45 ));
18+ }
19+ }
You can’t perform that action at this time.
0 commit comments