Skip to content
Merged
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
2 changes: 2 additions & 0 deletions chartLib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ dependencies {
implementation("androidx.activity:activity-ktx:1.12.2")
implementation("com.github.AppDevNext.Logcat:LogcatCoreLib:3.4")
testImplementation("junit:junit:4.13.2")
testImplementation("org.mockito:mockito-core:5.21.0")
testImplementation("org.mockito:mockito-inline:5.2.0")
}

tasks.register<Jar>("androidSourcesJar") {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package info.appdev.charting.data

class EntryDouble(val xDouble: Double, y: Float) : Entry(xDouble.toFloat(), y)
31 changes: 31 additions & 0 deletions chartLib/src/test/kotlin/info/appdev/charting/test/FloatTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package info.appdev.charting.test

import org.junit.Assert
import org.junit.Test

class FloatTest {


@Test
fun testFloatConversion() {
val timestamp: Long = System.currentTimeMillis()

// 2) Cast to Float and back
val asFloat: Float = timestamp.toFloat()
val roundTripFromFloat: Long = asFloat.toLong()

// 3) Cast to Double and back
val asDouble: Double = timestamp.toDouble()
val roundTripFromDouble: Long = asDouble.toLong()

println("Original timestamp: $timestamp")
println("→ as Float: $asFloat")
println("→ back to Long (Float): $roundTripFromFloat")
println()
println("→ as Double: $asDouble")
println("→ back to Long (Double): $roundTripFromDouble")
println()
Assert.assertNotEquals(timestamp, roundTripFromFloat)
Assert.assertEquals(timestamp, roundTripFromDouble)
}
}
Loading