Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ private fun summaryText(
.plus("。")
}

private fun performanceLevel(topPercent: Int): String = when {
internal fun performanceLevel(topPercent: Int): String = when {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When relaxing the visibility of a private function to internal for testing purposes, it is highly recommended to annotate it with @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE). This clearly documents the intent that the function's visibility was only increased for testing, and prevents other parts of the codebase from accidentally relying on this internal implementation detail. Note that you may need to import androidx.annotation.VisibleForTesting.

Suggested change
internal fun performanceLevel(topPercent: Int): String = when {
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
internal fun performanceLevel(topPercent: Int): String = when {

topPercent <= 25 -> "班級前段"
topPercent <= 50 -> "中上"
topPercent <= 75 -> "中段"
Expand Down
12 changes: 12 additions & 0 deletions android/app/src/test/java/com/clhs/score/data/GradeAnalysisTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,18 @@ class GradeAnalysisTest {
)
}

@Test
fun performanceLevelMapsTopPercentCorrectly() {
assertEquals("班級前段", performanceLevel(1))
assertEquals("班級前段", performanceLevel(25))
assertEquals("中上", performanceLevel(26))
assertEquals("中上", performanceLevel(50))
assertEquals("中段", performanceLevel(51))
assertEquals("中段", performanceLevel(75))
assertEquals("需要加強", performanceLevel(76))
assertEquals("需要加強", performanceLevel(100))
}

@Test
fun localInsightsDoNotEstimateRankWhenRankDataMissing() {
val current = MockGradeSystem.generateReport(customClassRank = null)
Expand Down
Loading