Skip to content

Commit 85eb7c3

Browse files
committed
starting tests finally \o/
1 parent c9dd1a3 commit 85eb7c3

File tree

2 files changed

+219
-3
lines changed

2 files changed

+219
-3
lines changed

build.gradle.kts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,18 @@ subprojects {
4040
}
4141

4242
dependencies {
43-
compileOnly(kotlin("stdlib"))
44-
compileOnly(kotlin("reflect"))
43+
api(kotlin("stdlib"))
44+
api(kotlin("reflect"))
4545

46-
compileOnly("org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT")
46+
api("org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT")
47+
48+
testRuntime("org.junit.platform:junit-platform-launcher:1.3.2")
49+
testRuntime("org.junit.jupiter:junit-jupiter-engine:5.3.2")
50+
testRuntime("org.junit.vintage:junit-vintage-engine:5.3.2")
51+
}
52+
53+
tasks.withType<Test> {
54+
useJUnitPlatform()
4755
}
4856

4957
kotlin {
Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
package br.com.devsrsouza.kotlinbukkitapi.utils
2+
3+
import br.com.devsrsouza.kotlinbukkitapi.utils.time.*
4+
import org.junit.Assert
5+
import org.junit.Test
6+
7+
class TimeUtilsTest {
8+
9+
@Test
10+
fun `should convert correctly milliseconds to milliseconds`() {
11+
val time = 300L
12+
val millisecond = 300L
13+
14+
Assert.assertEquals(millisecond, time.millisecond.toMillisecond())
15+
}
16+
17+
@Test
18+
fun `should convert correctly milliseconds to ticks`() {
19+
val time = 250L
20+
val tick = 5L
21+
22+
Assert.assertEquals(tick, time.millisecond.toTick())
23+
}
24+
25+
@Test
26+
fun `should convert correctly milliseconds to seconds`() {
27+
val time = 5000L
28+
val second = 5
29+
30+
Assert.assertEquals(second, time.millisecond.toSecond())
31+
}
32+
33+
@Test
34+
fun `should convert correctly milliseconds to minutes`() {
35+
val time = 60_000L
36+
val minute = 1
37+
38+
Assert.assertEquals(minute, time.millisecond.toMinute())
39+
}
40+
41+
@Test
42+
fun `should convert correctly milliseconds to hours`() {
43+
val time = 7_200_000L
44+
val hour = 2
45+
46+
Assert.assertEquals(hour, time.millisecond.toHour())
47+
}
48+
49+
@Test
50+
fun `should convert correctly ticks to milliseconds`() {
51+
val time = 20L
52+
val millisecond = 1000L
53+
54+
Assert.assertEquals(millisecond, time.tick.toMillisecond())
55+
}
56+
57+
@Test
58+
fun `should convert correctly ticks to ticks`() {
59+
val time = 20L
60+
val tick = 20L
61+
62+
Assert.assertEquals(tick, time.tick.toTick())
63+
}
64+
65+
@Test
66+
fun `should convert correctly ticks to seconds`() {
67+
val time = 20L
68+
val second = 1
69+
70+
Assert.assertEquals(second, time.tick.toSecond())
71+
}
72+
73+
@Test
74+
fun `should convert correctly ticks to minutes`() {
75+
val time = 2_400L
76+
val minute = 2
77+
78+
Assert.assertEquals(minute, time.tick.toMinute())
79+
}
80+
81+
@Test
82+
fun `should convert correctly ticks to hours`() {
83+
val time = 144_000L
84+
val hour = 2
85+
86+
Assert.assertEquals(hour, time.tick.toHour())
87+
}
88+
89+
@Test
90+
fun `should convert correctly seconds to milliseconds`() {
91+
val time = 8
92+
val millisecond = 8000L
93+
94+
Assert.assertEquals(millisecond, time.second.toMillisecond())
95+
}
96+
97+
@Test
98+
fun `should convert correctly seconds to ticks`() {
99+
val time = 2
100+
val tick = 40L
101+
102+
Assert.assertEquals(tick, time.second.toTick())
103+
}
104+
105+
@Test
106+
fun `should convert correctly seconds to seconds`() {
107+
val time = 20
108+
val second = 20
109+
110+
Assert.assertEquals(second, time.second.toSecond())
111+
}
112+
113+
@Test
114+
fun `should convert correctly seconds to minutes`() {
115+
val time = 120
116+
val minute = 2
117+
118+
Assert.assertEquals(minute, time.second.toMinute())
119+
}
120+
121+
@Test
122+
fun `should convert correctly seconds to hours`() {
123+
val time = 7_200
124+
val hour = 2
125+
126+
Assert.assertEquals(hour, time.second.toHour())
127+
}
128+
129+
@Test
130+
fun `should convert correctly minutes to milliseconds`() {
131+
val time = 1
132+
val millisecond = 60_000L
133+
134+
Assert.assertEquals(millisecond, time.minute.toMillisecond())
135+
}
136+
137+
@Test
138+
fun `should convert correctly minutes to ticks`() {
139+
val time = 1
140+
val tick = 1_200L
141+
142+
Assert.assertEquals(tick, time.minute.toTick())
143+
}
144+
145+
@Test
146+
fun `should convert correctly minutes to seconds`() {
147+
val time = 1
148+
val second = 60
149+
150+
Assert.assertEquals(second, time.minute.toSecond())
151+
}
152+
153+
@Test
154+
fun `should convert correctly minutes to minutes`() {
155+
val time = 25
156+
val minute = 25
157+
158+
Assert.assertEquals(minute, time.minute.toMinute())
159+
}
160+
161+
@Test
162+
fun `should convert correctly minutes to hours`() {
163+
val time = 120
164+
val hour = 2
165+
166+
Assert.assertEquals(hour, time.minute.toHour())
167+
}
168+
169+
@Test
170+
fun `should convert correctly hours to milliseconds`() {
171+
val time = 1
172+
val millisecond = 3_600_000L
173+
174+
Assert.assertEquals(millisecond, time.hour.toMillisecond())
175+
}
176+
177+
@Test
178+
fun `should convert correctly hours to ticks`() {
179+
val time = 2
180+
val tick = 144_000L
181+
182+
Assert.assertEquals(tick, time.hour.toTick())
183+
}
184+
185+
@Test
186+
fun `should convert correctly hours to seconds`() {
187+
val time = 3
188+
val second = 10_800
189+
190+
Assert.assertEquals(second, time.hour.toSecond())
191+
}
192+
193+
@Test
194+
fun `should convert correctly hours to minutes`() {
195+
val time = 3
196+
val minute = 180
197+
198+
Assert.assertEquals(minute, time.hour.toMinute())
199+
}
200+
201+
@Test
202+
fun `should convert correctly hours to hours`() {
203+
val time = 3
204+
val hour = 3
205+
206+
Assert.assertEquals(hour, time.hour.toHour())
207+
}
208+
}

0 commit comments

Comments
 (0)