Skip to content

Commit

Permalink
add player functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ssadat-guscheh-aimit committed Feb 3, 2024
1 parent 130c518 commit c575894
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/main/kotlin/com/bitkid/itsfranking/ITSFData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ data class ITSFPlayer(
fun hasFemaleRanking(): Boolean {
return rankings[Categories.womenDoubles] != null || rankings[Categories.womenSingles] != null
}

fun hasJuniorRankings(): Boolean {
return rankings[Categories.juniorDoubles] != null || rankings[Categories.juniorSingles] != null || rankings[Categories.classicJunior] != null
}

fun hasSeniorRankings(): Boolean {
return rankings[Categories.seniorDoubles] != null || rankings[Categories.seniorSingles] != null || rankings[Categories.classicSenior] != null
}
}

data class PlayerNameWithResults(val playerName: String, val results: List<ITSFPlayer>)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ import org.apache.commons.codec.language.bm.RuleType
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import strikt.api.expectThat
import strikt.assertions.hasSize
import strikt.assertions.isEqualTo
import strikt.assertions.isGreaterThan
import strikt.assertions.isTrue
import strikt.assertions.*
import java.io.File

class ITSFPlayerDatabaseReaderTest {
Expand Down Expand Up @@ -44,4 +41,17 @@ class ITSFPlayerDatabaseReaderTest {
expectThat(players.matchesName(engine.encode(simon.name), engine.encode("varos").split("|"))).isTrue()
expectThat(players.find("varos").size).isGreaterThan(1)
}

@Test
fun `player tests`() {
expectThat(players.find("pintilii").single().hasFemaleRanking()).isTrue()
expectThat(players.find("pintilii").single().hasJuniorRankings()).isFalse()
expectThat(players.find("pintilii").single().hasSeniorRankings()).isFalse()

expectThat(players.find("guscheh").single().hasSeniorRankings()).isFalse()
expectThat(players.find("guscheh").single().hasJuniorRankings()).isFalse()
expectThat(players.find("guscheh").single().hasFemaleRanking()).isFalse()

expectThat(players.find("bentivoglio").single().hasSeniorRankings()).isTrue()
}
}

0 comments on commit c575894

Please sign in to comment.