Skip to content

Commit b55d1f2

Browse files
Add tests for performanceLevel mapping
Co-authored-by: alvin000009238 <107313913+alvin000009238@users.noreply.github.com>
1 parent fd03a1f commit b55d1f2

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

android/app/src/main/java/com/clhs/score/data/GradeAnalysis.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ private fun summaryText(
485485
.plus("")
486486
}
487487

488-
private fun performanceLevel(topPercent: Int): String = when {
488+
internal fun performanceLevel(topPercent: Int): String = when {
489489
topPercent <= 25 -> "班級前段"
490490
topPercent <= 50 -> "中上"
491491
topPercent <= 75 -> "中段"

android/app/src/test/java/com/clhs/score/data/GradeAnalysisTest.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,18 @@ class GradeAnalysisTest {
357357
)
358358
}
359359

360+
@Test
361+
fun performanceLevelMapsTopPercentCorrectly() {
362+
assertEquals("班級前段", performanceLevel(1))
363+
assertEquals("班級前段", performanceLevel(25))
364+
assertEquals("中上", performanceLevel(26))
365+
assertEquals("中上", performanceLevel(50))
366+
assertEquals("中段", performanceLevel(51))
367+
assertEquals("中段", performanceLevel(75))
368+
assertEquals("需要加強", performanceLevel(76))
369+
assertEquals("需要加強", performanceLevel(100))
370+
}
371+
360372
@Test
361373
fun localInsightsDoNotEstimateRankWhenRankDataMissing() {
362374
val current = MockGradeSystem.generateReport(customClassRank = null)

0 commit comments

Comments
 (0)