Skip to content

Commit 5e791c5

Browse files
committed
removed unneccessary folder
1 parent 8cfa575 commit 5e791c5

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.baeldung.modulo;
2+
3+
import org.junit.Test;
4+
import static org.assertj.core.api.Java6Assertions.*;
5+
6+
public class ModuloUnitTest {
7+
8+
@Test
9+
public void whenIntegerDivision_thenLosesRemainder(){
10+
assertThat(11 / 4).isEqualTo(2);
11+
}
12+
13+
@Test
14+
public void whenDoubleDivision_thenKeepsRemainder(){
15+
assertThat(11 / 4.0).isEqualTo(2.75);
16+
}
17+
18+
@Test
19+
public void whenModulo_thenReturnsRemainder(){
20+
assertThat(11 % 4).isEqualTo(3);
21+
}
22+
23+
@Test(expected = ArithmeticException.class)
24+
public void whenDivisionByZero_thenArithmeticException(){
25+
double result = 1 / 0;
26+
}
27+
28+
@Test(expected = ArithmeticException.class)
29+
public void whenModuloByZero_thenArithmeticException(){
30+
double result = 1 % 0;
31+
}
32+
33+
@Test
34+
public void whenDivisorIsOddAndModulusIs2_thenResultIs1(){
35+
assertThat(3 % 2).isEqualTo(1);
36+
}
37+
38+
@Test
39+
public void whenDivisorIsEvenAndModulusIs2_thenResultIs0(){
40+
assertThat(4 % 2).isEqualTo(0);
41+
}
42+
43+
@Test
44+
public void whenItemsIsAddedToCircularQueue_thenNoArrayIndexOutOfBounds(){
45+
int QUEUE_CAPACITY= 10;
46+
int[] circularQueue = new int[QUEUE_CAPACITY];
47+
int itemsInserted = 0;
48+
for (int value = 0; value < 1000; value++) {
49+
int writeIndex = ++itemsInserted % QUEUE_CAPACITY;
50+
circularQueue[writeIndex] = value;
51+
}
52+
}
53+
54+
}

0 commit comments

Comments
 (0)