Skip to content

Commit 3a928f5

Browse files
committed
feat: add more test for gaugeapi and some.
1 parent d825814 commit 3a928f5

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package be4rjp.sclat.api
2+
3+
import io.kotest.core.spec.style.StringSpec
4+
import io.kotest.matchers.shouldBe
5+
import org.bukkit.ChatColor
6+
7+
class GaugeAPITest :
8+
StringSpec({
9+
"GaugeAPI should generate correct gauge string" {
10+
val gaugeString = GaugeAPI.toGauge(5, 10, ChatColor.GREEN.toString(), ChatColor.RED.toString())
11+
gaugeString shouldBe "${ChatColor.RESET}${ChatColor.GREEN}|||||${ChatColor.RED}|||||${ChatColor.RESET}"
12+
}
13+
14+
"GaugeAPI should handle zero value correctly" {
15+
val gaugeString = GaugeAPI.toGauge(0, 10, ChatColor.GREEN.toString(), ChatColor.RED.toString())
16+
gaugeString shouldBe "${ChatColor.RESET}${ChatColor.GREEN}${ChatColor.RED}||||||||||${ChatColor.RESET}"
17+
}
18+
19+
"GaugeAPI should handle max value correctly" {
20+
val gaugeString = GaugeAPI.toGauge(10, 10, ChatColor.GREEN.toString(), ChatColor.RED.toString())
21+
gaugeString shouldBe "${ChatColor.RESET}${ChatColor.GREEN}||||||||||${ChatColor.RED}${ChatColor.RESET}"
22+
}
23+
})

src/test/kotlin/be4rjp/sclat/util/LargeUnitTests.kt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,39 @@ class LargeUnitTests :
6161
(2 + 2) shouldBe 4
6262
(10 * 5) shouldBe 50
6363
}
64+
65+
// Additional tests for SclatUtil
66+
"isNumber edge case: large integer" {
67+
val largeInt = Int.MAX_VALUE.toString()
68+
SclatUtil.isNumber(largeInt) shouldBe true
69+
}
70+
71+
"isNumber edge case: negative large integer" {
72+
val largeNegativeInt = Int.MIN_VALUE.toString()
73+
SclatUtil.isNumber(largeNegativeInt) shouldBe true
74+
}
75+
76+
"isNumber edge case: empty string" {
77+
SclatUtil.isNumber("") shouldBe false
78+
}
79+
80+
// Additional string manipulation tests
81+
"string repeat with empty string" {
82+
val s = "".repeat(5)
83+
s shouldBe ""
84+
}
85+
86+
"string repeat with special characters" {
87+
val s = "@".repeat(3)
88+
s shouldBe "@@@"
89+
}
90+
91+
// Additional math sanity checks
92+
"math division by non-zero" {
93+
(10 / 2) shouldBe 5
94+
}
95+
96+
"math modulo operation" {
97+
(10 % 3) shouldBe 1
98+
}
6499
})

0 commit comments

Comments
 (0)