|
@@ -1,5 +1,118 @@
|
|
1
|
+import org.junit.Assert;
|
|
2
|
+import org.junit.Before;
|
|
3
|
+import org.junit.Test;
|
|
4
|
+
|
1
|
5
|
import static org.junit.Assert.*;
|
2
|
6
|
|
3
|
7
|
public class ArrazTest {
|
|
8
|
+ Arraz arraz = new Arraz();
|
|
9
|
+
|
|
10
|
+ @Before
|
|
11
|
+ public void setUp(){
|
|
12
|
+
|
|
13
|
+ }
|
|
14
|
+
|
|
15
|
+ @Test
|
|
16
|
+ public void test1sumValuesOfArray(){
|
|
17
|
+ //GIVEN
|
|
18
|
+ int[] arr = {1, 2, 3, 4, 5};
|
|
19
|
+
|
|
20
|
+ //WHEN
|
|
21
|
+ int expected = 15;
|
|
22
|
+ int actual = arraz.sumValuesOfArray(arr);
|
|
23
|
+
|
|
24
|
+ //THEN
|
|
25
|
+ Assert.assertEquals(expected, actual);
|
|
26
|
+ }
|
|
27
|
+
|
|
28
|
+ @Test
|
|
29
|
+ public void test2sumValuesOfArray(){
|
|
30
|
+ //GIVEN
|
|
31
|
+ int[] arr = {1, 2, 3, 4, 5, 100};
|
|
32
|
+
|
|
33
|
+ //WHEN
|
|
34
|
+ int expected = 115;
|
|
35
|
+ int actual = arraz.sumValuesOfArray(arr);
|
|
36
|
+
|
|
37
|
+ //THEN
|
|
38
|
+ Assert.assertEquals(expected, actual);
|
|
39
|
+ }
|
|
40
|
+
|
|
41
|
+ @Test
|
|
42
|
+ public void test1sumDoublesOfArray(){
|
|
43
|
+ //GIVEN
|
|
44
|
+ double[] arr = {1, 2, 3, 4, 5.5};
|
|
45
|
+
|
|
46
|
+ //WHEN
|
|
47
|
+ double expected = 15.5;
|
|
48
|
+ double actual = arraz.sumDoublesOfArray(arr);
|
|
49
|
+
|
|
50
|
+ //THEN
|
|
51
|
+ Assert.assertEquals(expected, actual);
|
|
52
|
+ }
|
|
53
|
+
|
|
54
|
+ @Test
|
|
55
|
+ public void test2sumDoublesOfArray(){
|
|
56
|
+ //GIVEN
|
|
57
|
+ double[] arr = {1.999, 2, 3, 4, 5, 100};
|
|
58
|
+
|
|
59
|
+ //WHEN
|
|
60
|
+ double expected = 115.999;
|
|
61
|
+ double actual = arraz.sumDoublesOfArray(arr);
|
|
62
|
+
|
|
63
|
+ //THEN
|
|
64
|
+ Assert.assertEquals(expected, actual);
|
|
65
|
+ }
|
|
66
|
+
|
|
67
|
+ @Test
|
|
68
|
+ public void test1averageOfArray(){
|
|
69
|
+ //GIVEN
|
|
70
|
+ int[] arr = {1, 2, 3, 4, 5};
|
|
71
|
+
|
|
72
|
+ //WHEN
|
|
73
|
+ int expected = 3;
|
|
74
|
+ int actual = arraz.averageOfArray(arr);
|
|
75
|
+
|
|
76
|
+ //THEN
|
|
77
|
+ Assert.assertEquals(expected, actual);
|
|
78
|
+ }
|
|
79
|
+
|
|
80
|
+ @Test
|
|
81
|
+ public void test2averageOfArray(){
|
|
82
|
+ //GIVEN
|
|
83
|
+ int[] arr = {1, 2, 3, 4, 5, 6};
|
|
84
|
+
|
|
85
|
+ //WHEN
|
|
86
|
+ int expected = 3;
|
|
87
|
+ int actual = arraz.averageOfArray(arr);
|
|
88
|
+
|
|
89
|
+ //THEN
|
|
90
|
+ Assert.assertEquals(expected, actual);
|
|
91
|
+ }
|
|
92
|
+
|
|
93
|
+ @Test
|
|
94
|
+ public void test1doubleAverageOfArray(){
|
|
95
|
+ //GIVEN
|
|
96
|
+ double[] arr = {.75, 2, 3, 4, 5.25};
|
|
97
|
+
|
|
98
|
+ //WHEN
|
|
99
|
+ double expected = 3;
|
|
100
|
+ double actual = arraz.doubleAverageOfArray(arr);
|
|
101
|
+
|
|
102
|
+ //THEN
|
|
103
|
+ Assert.assertEquals(expected, actual);
|
|
104
|
+ }
|
|
105
|
+
|
|
106
|
+ @Test
|
|
107
|
+ public void test2doubleAverageOfArray(){
|
|
108
|
+ //GIVEN
|
|
109
|
+ double[] arr = {.001, 2, 3.141, 4, 5, 6.999};
|
|
110
|
+
|
|
111
|
+ //WHEN
|
|
112
|
+ double expected = 3.5235;
|
|
113
|
+ double actual = arraz.doubleAverageOfArray(arr);
|
4
|
114
|
|
|
115
|
+ //THEN
|
|
116
|
+ Assert.assertEquals(expected, actual);
|
|
117
|
+ }
|
5
|
118
|
}
|