Skip to content

Commit 4bcf815

Browse files
committed
Start Test Implementation
1 parent 6e6316b commit 4bcf815

File tree

6 files changed

+46
-83
lines changed

6 files changed

+46
-83
lines changed

Codex/build.gradle.kts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
alias(libs.plugins.android.library)
33
alias(libs.plugins.kotlin.android)
4+
id("de.mannodermaus.android-junit5") version "1.10.0.0"
45
}
56

67
android {
@@ -37,7 +38,10 @@ dependencies {
3738
implementation(libs.androidx.core.ktx)
3839
implementation(libs.androidx.appcompat)
3940
implementation(libs.material)
40-
testImplementation(libs.junit)
41+
42+
testImplementation("org.junit.jupiter:junit-jupiter:5.13.4")
43+
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.13.4")
44+
4145
androidTestImplementation(libs.androidx.junit)
4246
androidTestImplementation(libs.androidx.espresso.core)
4347
}

Codex/src/androidTest/java/org/operatorfoundation/codex/ExampleInstrumentedTest.kt

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package org.operatorfoundation.codex
2+
3+
import org.junit.jupiter.api.Test
4+
import org.junit.jupiter.api.Assertions.*
5+
import org.operatorfoundation.codex.symbols.*
6+
import java.math.BigInteger
7+
8+
class EncoderDecoderTest
9+
{
10+
@Test
11+
fun testByteEncodingDecoding()
12+
{
13+
// Create decoder with 4 byte symbols
14+
val bytesDecoder = Decoder(listOf(Byte(), Byte(), Byte(), Byte()))
15+
16+
// Create "Test" as bytes
17+
val testBytes = "Test".toByteArray()
18+
val testByteArrays = testBytes.map { byteArrayOf(it) }
19+
20+
// Decode to integer
21+
val decodedInteger = bytesDecoder.decode(testByteArrays)
22+
println("@ i: $decodedInteger")
23+
24+
// Verify the decoded value matches Python output
25+
// In Python: b'Test' decodes to 1415934836
26+
assertEquals(BigInteger.valueOf(1415934836), decodedInteger)
27+
28+
// Create encoder and encode back
29+
val bytesEncoder = bytesDecoder.encoder()
30+
val encodedBytes = bytesEncoder.encode(decodedInteger)
31+
32+
// Convert back to string for verification
33+
val reconstructedBytes = encodedBytes.map { it[0] }.toByteArray()
34+
val reconstructedString = String(reconstructedBytes)
35+
36+
println("% bs: ${encodedBytes.map { it[0].toInt() and 0xFF }}, str: $reconstructedString")
37+
38+
assertEquals("Test", reconstructedString)
39+
}
40+
41+
}

Codex/src/test/java/org/operatorfoundation/codex/ExampleUnitTest.kt

Lines changed: 0 additions & 17 deletions
This file was deleted.

app/src/androidTest/java/org/operatorfoundation/codexkotlin/ExampleInstrumentedTest.kt

Lines changed: 0 additions & 24 deletions
This file was deleted.

app/src/test/java/org/operatorfoundation/codexkotlin/ExampleUnitTest.kt

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)