Initial commit

This commit is contained in:
2024-02-14 15:55:36 -03:00
commit 25858413c5
30 changed files with 1209 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
package cl.carlost.kmpexcercises
class AndroidPlatform : Platform {
override val name: String = "Android ${android.os.Build.VERSION.SDK_INT}"
}
actual fun getPlatform(): Platform = AndroidPlatform()

View File

@@ -0,0 +1,12 @@
package cl.carlost.kmpexcercises
import org.junit.Assert.assertTrue
import org.junit.Test
class AndroidGreetingTest {
@Test
fun testExample() {
assertTrue("Check Android is mentioned", Greeting().greet().contains("Android"))
}
}

View File

@@ -0,0 +1,9 @@
package cl.carlost.kmpexcercises
class Greeting {
private val platform: Platform = getPlatform()
fun greet(): String {
return "Hello, ${platform.name}!"
}
}

View File

@@ -0,0 +1,7 @@
package cl.carlost.kmpexcercises
interface Platform {
val name: String
}
expect fun getPlatform(): Platform

View File

@@ -0,0 +1,12 @@
package cl.carlost.kmpexcercises
import kotlin.test.Test
import kotlin.test.assertTrue
class CommonGreetingTest {
@Test
fun testExample() {
assertTrue(Greeting().greet().contains("Hello"), "Check 'Hello' is mentioned")
}
}

View File

@@ -0,0 +1,9 @@
package cl.carlost.kmpexcercises
import platform.UIKit.UIDevice
class IOSPlatform: Platform {
override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion
}
actual fun getPlatform(): Platform = IOSPlatform()

View File

@@ -0,0 +1,12 @@
package cl.carlost.kmpexcercises
import kotlin.test.Test
import kotlin.test.assertTrue
class IosGreetingTest {
@Test
fun testExample() {
assertTrue(Greeting().greet().contains("iOS"), "Check iOS is mentioned")
}
}