Skip to content

Commit

Permalink
fix: update some of the Kotlin code to be more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
cmgriffing committed Mar 10, 2024
1 parent cc0adf6 commit feece74
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 25 deletions.
2 changes: 1 addition & 1 deletion clients/kotlin/src/main/kotlin/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Client(
is SelectiveFeature -> {
when (feature) {
is SelectiveStringFeature -> feature.value.contains(instanceId)
else -> throw Error("should function must only be called for features with a valueType of 'string'. Try shouldInt, shouldLong, shouldFloat, or shouldDouble")
else -> throw Error("should function must only be called for features with a valueType of 'string'. Try shouldCustomInt, shouldCustomLong, shouldCustomFloat, or shouldCustomDouble")
}
}

Expand Down
10 changes: 0 additions & 10 deletions clients/kotlin/src/main/kotlin/Types.kt
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,3 @@ data class Group(
val environments: Map<String, Environment>,
val features: Map<String, Feature>
)

data class FooGroup(
val id: String = "Foo",
val name: String = "Bar",

) {
enum class Features(val FeatureName: String) {
FEATURE_1("feature_is_akshjdfgajkshfg"),
}
}
28 changes: 14 additions & 14 deletions clients/kotlin/src/test/kotlin/HasherTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,36 @@ class HasherTest {

private val uuid = "b7e91cc5-ec76-4ec3-9c1c-075032a13a1a";

private val nonWorkingSeed = 0.22;
private val workingSeed = 0.11;
private val seedA = 0.11; // Working for string test
private val seedB = 0.22; // Non-working for string test

@Test
fun `should hash a string get a value under threshold for a working seed`() {
assertTrue(Hasher.hashString(this.uuid, this.workingSeed) <= 0.40)
fun `should hash a string and get a value under threshold for seed A`() {
assertTrue(Hasher.hashString(this.uuid, this.seedA) <= 0.40)
}

@Test
fun `should hash a string get a value above threshold for a non working seed`() {
assertTrue(Hasher.hashString(this.uuid, this.nonWorkingSeed) > 0.40)
fun `should hash a string and get a value above threshold for seed B`() {
assertTrue(Hasher.hashString(this.uuid, this.seedB) > 0.40)
}

@Test
fun `should hash a int get a value above threshold for a non working seed`() {
assertTrue(Hasher.hashInt(42, this.nonWorkingSeed) > 0.40)
fun `should hash a int and get a value above threshold for seed B`() {
assertTrue(Hasher.hashInt(42, this.seedB) > 0.40)
}

@Test
fun `should hash a long get a value above threshold for a non working seed`() {
assertTrue(Hasher.hashLong(42, this.nonWorkingSeed) > 0.40)
fun `should hash a long and get a value above threshold for seed B`() {
assertTrue(Hasher.hashLong(42, this.seedB) > 0.40)
}

@Test
fun `should hash a float get a value under threshold for a non working seed`() {
assertTrue(Hasher.hashFloat(42.42.toFloat(), this.nonWorkingSeed) < 0.40)
fun `should hash a float and get a value under threshold for seed B`() {
assertTrue(Hasher.hashFloat(42.42.toFloat(), this.seedB) <= 0.40)
}

@Test
fun `should hash a double get a value under threshold for a non working seed`() {
assertTrue(Hasher.hashDouble(42.42, this.nonWorkingSeed) < 0.40)
fun `should hash a double and get a value under threshold for a seed B`() {
assertTrue(Hasher.hashDouble(42.42, this.seedB) <= 0.40)
}
}

0 comments on commit feece74

Please sign in to comment.