diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml new file mode 100644 index 0000000..2f46684 --- /dev/null +++ b/.gitea/workflows/ci.yaml @@ -0,0 +1,92 @@ +on: + push: + branches: [ develop, main ] + pull_request: + branches: [ main ] + +jobs: + test: + runs-on: linux + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Java + uses: actions/setup-java@v4 + with: + java-version: '24' + distribution: 'temurin' + + - name: Cache Gradle + uses: actions/cache@v4 + with: + key: gradle-${{ hashFiles('**/libs.versions.toml') }} + restore-keys: gradle- + path: | + ~/.gradle/caches/ + ~/.gradle/wrapper/ + + - name: Cache Konan + uses: actions/cache@v4 + with: + key: konan-${{ hashFiles('**/libs.versions.toml') }} + restore-keys: konan- + path: | + ~/.konan/ + + - name: Cache Node + uses: actions/cache@v4 + with: + key: node-${{ hashFiles('**/libs.versions.toml') }} + restore-keys: node- + path: | + ~/.gradle/nodejs + ~/.gradle/yarn + + - name: Test + run: ./gradlew allTests + + publish: + if: ${{ github.event_name == 'push' && github.ref_name == 'main' }} + needs: test + runs-on: linux + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Java + uses: actions/setup-java@v4 + with: + java-version: '24' + distribution: 'temurin' + + - name: Cache Gradle + uses: actions/cache@v4 + with: + key: gradle-${{ hashFiles('**/libs.versions.toml') }} + restore-keys: gradle- + path: | + ~/.gradle/caches/ + ~/.gradle/wrapper/ + + - name: Cache Konan + uses: actions/cache@v4 + with: + key: konan-${{ hashFiles('**/libs.versions.toml') }} + restore-keys: konan- + path: | + ~/.konan/ + + - name: Cache Node + uses: actions/cache@v4 + with: + key: node-${{ hashFiles('**/libs.versions.toml') }} + restore-keys: node- + path: | + ~/.gradle/nodejs + ~/.gradle/yarn + + - name: Publish + run: ./gradlew publish + env: + INFENDRO__TOKEN: ${{ secrets.TOKEN }} diff --git a/.gitea/workflows/main.yaml b/.gitea/workflows/main.yaml deleted file mode 100644 index 4885477..0000000 --- a/.gitea/workflows/main.yaml +++ /dev/null @@ -1,36 +0,0 @@ -on: - push: - branches: - - main - -env: - INFENDRO__TOKEN: ${{ secrets.TOKEN }} - -jobs: - publish: - runs-on: linux - steps: - - uses: actions/checkout@v4 - - - uses: actions/cache/restore@v4 - with: - key: gradle - path: | - ~/.gradle/caches/ - ~/.gradle/wrapper/ - ~/.konan/ - - - uses: actions/setup-java@v4 - with: - java-version: '24' - distribution: 'temurin' - - - run: ./gradlew publish - - - uses: actions/cache/save@v4 - with: - key: gradle - path: | - ~/.gradle/caches/ - ~/.gradle/wrapper/ - ~/.konan/ diff --git a/src/commonTest/kotlin/com/infendro/bytearray/Conversion.kt b/src/commonTest/kotlin/com/infendro/bytearray/Conversion.kt index 21b7eff..6d47817 100644 --- a/src/commonTest/kotlin/com/infendro/bytearray/Conversion.kt +++ b/src/commonTest/kotlin/com/infendro/bytearray/Conversion.kt @@ -7,7 +7,7 @@ import kotlin.test.assertEquals class `Conversion Test` { @Test - fun `ByteArray - toInt()`() { + fun `ByteArray toInt`() { val expected = 0x12345678 val actual = arrayOf( byteArrayOf(0x12, 0x34, 0x56, 0x78).toInt(), @@ -18,7 +18,7 @@ class `Conversion Test` { } @Test - fun `UByteArray - toInt()`() { + fun `UByteArray toInt`() { val expected = 0x12345678 val actual = arrayOf( ubyteArrayOf(0x12U, 0x34U, 0x56U, 0x78U).toInt(), @@ -29,7 +29,7 @@ class `Conversion Test` { } @Test - fun `ByteArray - toUInt()`() { + fun `ByteArray toUInt`() { val expected = 0x12345678U val actual = arrayOf( byteArrayOf(0x12, 0x34, 0x56, 0x78).toUInt(), @@ -40,7 +40,7 @@ class `Conversion Test` { } @Test - fun `UByteArray - toUInt()`() { + fun `UByteArray toUInt`() { val expected = 0x12345678U val actual = arrayOf( ubyteArrayOf(0x12U, 0x34U, 0x56U, 0x78U).toUInt(), @@ -51,7 +51,7 @@ class `Conversion Test` { } @Test - fun `ByteArray - toIntArray()`() { + fun `ByteArray toIntArray`() { val expected = intArrayOf(0x12345678, 0x12345678) val actual = arrayOf( byteArrayOf( @@ -68,7 +68,7 @@ class `Conversion Test` { } @Test - fun `UByteArray - toIntArray()`() { + fun `UByteArray toIntArray`() { val expected = intArrayOf(0x12345678, 0x12345678) val actual = arrayOf( ubyteArrayOf( @@ -85,7 +85,7 @@ class `Conversion Test` { } @Test - fun `ByteArray - toUIntArray()`() { + fun `ByteArray toUIntArray`() { val expected = uintArrayOf(0x12345678U, 0x12345678U) val actual = arrayOf( byteArrayOf( @@ -102,7 +102,7 @@ class `Conversion Test` { } @Test - fun `UByteArray - toUIntArray()`() { + fun `UByteArray toUIntArray`() { val expected = uintArrayOf(0x12345678U, 0x12345678U) val actual = arrayOf( ubyteArrayOf( @@ -119,7 +119,7 @@ class `Conversion Test` { } @Test - fun `Int - toByteArray()`() { + fun `Int toByteArray`() { val expected = arrayOf( byteArrayOf(0x12, 0x34, 0x56, 0x78), byteArrayOf(0x78, 0x56, 0x34, 0x12), @@ -134,7 +134,7 @@ class `Conversion Test` { } @Test - fun `UInt - toByteArray()`() { + fun `UInt toByteArray`() { val expected = arrayOf( byteArrayOf(0x12, 0x34, 0x56, 0x78), byteArrayOf(0x78, 0x56, 0x34, 0x12), @@ -149,7 +149,7 @@ class `Conversion Test` { } @Test - fun `Int - toUByteArray()`() { + fun `Int toUByteArray`() { val expected = arrayOf( ubyteArrayOf(0x12U, 0x34U, 0x56U, 0x78U), ubyteArrayOf(0x78U, 0x56U, 0x34U, 0x12U), @@ -164,7 +164,7 @@ class `Conversion Test` { } @Test - fun `UInt - toUByteArray()`() { + fun `UInt toUByteArray`() { val expected = arrayOf( ubyteArrayOf(0x12U, 0x34U, 0x56U, 0x78U), ubyteArrayOf(0x78U, 0x56U, 0x34U, 0x12U), @@ -179,7 +179,7 @@ class `Conversion Test` { } @Test - fun `IntArray - toByteArray()`() { + fun `IntArray toByteArray`() { val expected = arrayOf( byteArrayOf( 0x12, 0x34, 0x56, 0x78, @@ -206,7 +206,7 @@ class `Conversion Test` { } @Test - fun `UIntArray - toByteArray()`() { + fun `UIntArray toByteArray`() { val expected = arrayOf( byteArrayOf( 0x12, 0x34, 0x56, 0x78, @@ -233,7 +233,7 @@ class `Conversion Test` { } @Test - fun `IntArray - toUByteArray()`() { + fun `IntArray toUByteArray`() { val expected = arrayOf( ubyteArrayOf( 0x12U, 0x34U, 0x56U, 0x78U, @@ -260,7 +260,7 @@ class `Conversion Test` { } @Test - fun `UIntArray - toUByteArray()`() { + fun `UIntArray toUByteArray`() { val expected = arrayOf( ubyteArrayOf( 0x12U, 0x34U, 0x56U, 0x78U, @@ -287,7 +287,7 @@ class `Conversion Test` { } @Test - fun `ByteArray - toLong()`() { + fun `ByteArray toLong`() { val expected = 0x1234567812345678L val actual = arrayOf( byteArrayOf(0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78).toLong(), @@ -298,7 +298,7 @@ class `Conversion Test` { } @Test - fun `UByteArray - toULong()`() { + fun `UByteArray toULong`() { val expected = 0x1234567812345678UL val actual = arrayOf( ubyteArrayOf(0x12U, 0x34U, 0x56U, 0x78U, 0x12U, 0x34U, 0x56U, 0x78U).toULong(), @@ -309,7 +309,7 @@ class `Conversion Test` { } @Test - fun `UByteArray - toLong()`() { + fun `UByteArray toLong`() { val expected = 0x1234567812345678L val actual = arrayOf( ubyteArrayOf(0x12U, 0x34U, 0x56U, 0x78U, 0x12U, 0x34U, 0x56U, 0x78U).toLong(), @@ -320,7 +320,7 @@ class `Conversion Test` { } @Test - fun `ByteArray - toULong()`() { + fun `ByteArray toULong`() { val expected = 0x1234567812345678UL val actual = arrayOf( byteArrayOf(0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78).toULong(), @@ -331,7 +331,7 @@ class `Conversion Test` { } @Test - fun `ByteArray - toLongArray()`() { + fun `ByteArray toLongArray`() { val expected = longArrayOf(0x1234567812345678L, 0x1234567812345678L) val actual = arrayOf( byteArrayOf( @@ -348,7 +348,7 @@ class `Conversion Test` { } @Test - fun `UByteArray - toLongArray()`() { + fun `UByteArray toLongArray`() { val expected = longArrayOf(0x1234567812345678L, 0x1234567812345678L) val actual = arrayOf( ubyteArrayOf( @@ -365,7 +365,7 @@ class `Conversion Test` { } @Test - fun `ByteArray - toULongArray()`() { + fun `ByteArray toULongArray`() { val expected = ulongArrayOf(0x1234567812345678UL, 0x1234567812345678UL) val actual = arrayOf( byteArrayOf( @@ -382,7 +382,7 @@ class `Conversion Test` { } @Test - fun `UByteArray - toULongArray()`() { + fun `UByteArray toULongArray`() { val expected = ulongArrayOf(0x1234567812345678UL, 0x1234567812345678UL) val actual = arrayOf( ubyteArrayOf( @@ -399,7 +399,7 @@ class `Conversion Test` { } @Test - fun `Long - toByteArray()`() { + fun `Long toByteArray`() { val expected = arrayOf( byteArrayOf(0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78), byteArrayOf(0x78, 0x56, 0x34, 0x12, 0x78, 0x56, 0x34, 0x12), @@ -414,7 +414,7 @@ class `Conversion Test` { } @Test - fun `ULong - toByteArray()`() { + fun `ULong toByteArray`() { val expected = arrayOf( byteArrayOf(0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78), byteArrayOf(0x78, 0x56, 0x34, 0x12, 0x78, 0x56, 0x34, 0x12), @@ -429,7 +429,7 @@ class `Conversion Test` { } @Test - fun `Long - toUByteArray()`() { + fun `Long toUByteArray`() { val expected = arrayOf( ubyteArrayOf(0x12U, 0x34U, 0x56U, 0x78U, 0x12U, 0x34U, 0x56U, 0x78U), ubyteArrayOf(0x78U, 0x56U, 0x34U, 0x12U, 0x78U, 0x56U, 0x34U, 0x12U), @@ -444,7 +444,7 @@ class `Conversion Test` { } @Test - fun `ULong - toUByteArray()`() { + fun `ULong toUByteArray`() { val expected = arrayOf( ubyteArrayOf(0x12U, 0x34U, 0x56U, 0x78U, 0x12U, 0x34U, 0x56U, 0x78U), ubyteArrayOf(0x78U, 0x56U, 0x34U, 0x12U, 0x78U, 0x56U, 0x34U, 0x12U), @@ -459,7 +459,7 @@ class `Conversion Test` { } @Test - fun `LongArray - toByteArray()`() { + fun `LongArray toByteArray`() { val expected = arrayOf( byteArrayOf( 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, @@ -486,7 +486,7 @@ class `Conversion Test` { } @Test - fun `ULongArray - toByteArray()`() { + fun `ULongArray toByteArray`() { val expected = arrayOf( byteArrayOf( 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, @@ -513,7 +513,7 @@ class `Conversion Test` { } @Test - fun `LongArray - toUByteArray()`() { + fun `LongArray toUByteArray`() { val expected = arrayOf( ubyteArrayOf( 0x12U, 0x34U, 0x56U, 0x78U, 0x12U, 0x34U, 0x56U, 0x78U, @@ -540,7 +540,7 @@ class `Conversion Test` { } @Test - fun `ULongArray - toUByteArray()`() { + fun `ULongArray toUByteArray`() { val expected = arrayOf( ubyteArrayOf( 0x12U, 0x34U, 0x56U, 0x78U, 0x12U, 0x34U, 0x56U, 0x78U, diff --git a/src/commonTest/kotlin/com/infendro/bytearray/Modification.kt b/src/commonTest/kotlin/com/infendro/bytearray/Modification.kt index 65282e6..d82e8c6 100644 --- a/src/commonTest/kotlin/com/infendro/bytearray/Modification.kt +++ b/src/commonTest/kotlin/com/infendro/bytearray/Modification.kt @@ -6,7 +6,7 @@ import kotlin.test.assertEquals class `Modification Test` { @Test - fun `ByteArray - padStart()`() { + fun `ByteArray padStart`() { val expected = byteArrayOf(0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02) val actual = byteArrayOf(0x02, 0x02).padStart(8, 0x01) assertEquals(8, actual.size) @@ -14,7 +14,7 @@ class `Modification Test` { } @Test - fun `ByteArray - padStart() - unchanged`() { + fun `ByteArray padStart - unchanged`() { val expected = byteArrayOf(0x02, 0x02) val actual = byteArrayOf(0x02, 0x02).padStart(2, 0x01) assertEquals(2, actual.size) @@ -22,7 +22,7 @@ class `Modification Test` { } @Test - fun `UByteArray - padStart()`() { + fun `UByteArray padStart`() { val expected = ubyteArrayOf(0x01U, 0x01U, 0x01U, 0x01U, 0x01U, 0x01U, 0x02U, 0x02U) val actual = ubyteArrayOf(0x02U, 0x02U).padStart(8, 0x01U) assertEquals(8, actual.size) @@ -30,7 +30,7 @@ class `Modification Test` { } @Test - fun `UByteArray - padStart() - unchanged`() { + fun `UByteArray padStart - unchanged`() { val expected = ubyteArrayOf(0x02U, 0x02U) val actual = ubyteArrayOf(0x02U, 0x02U).padStart(2, 0x01U) assertEquals(2, actual.size) @@ -38,7 +38,7 @@ class `Modification Test` { } @Test - fun `ByteArray - padEnd()`() { + fun `ByteArray padEnd`() { val expected = byteArrayOf(0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01) val actual = byteArrayOf(0x02, 0x02).padEnd(8, 0x01) assertEquals(8, actual.size) @@ -46,7 +46,7 @@ class `Modification Test` { } @Test - fun `ByteArray - padEnd() - unchanged`() { + fun `ByteArray padEnd - unchanged`() { val expected = byteArrayOf(0x02, 0x02) val actual = byteArrayOf(0x02, 0x02).padEnd(2, 0x01) assertEquals(2, actual.size) @@ -54,7 +54,7 @@ class `Modification Test` { } @Test - fun `UByteArray - padEnd()`() { + fun `UByteArray padEnd`() { val expected = ubyteArrayOf(0x02U, 0x02U, 0x01U, 0x01U, 0x01U, 0x01U, 0x01U, 0x01U) val actual = ubyteArrayOf(0x02U, 0x02U).padEnd(8, 0x01U) assertEquals(8, actual.size) @@ -62,7 +62,7 @@ class `Modification Test` { } @Test - fun `UByteArray - padEnd() - unchanged`() { + fun `UByteArray padEnd - unchanged`() { val expected = ubyteArrayOf(0x02U, 0x02U) val actual = ubyteArrayOf(0x02U, 0x02U).padEnd(2, 0x01U) assertEquals(2, actual.size) diff --git a/src/commonTest/kotlin/com/infendro/bytearray/Operators.kt b/src/commonTest/kotlin/com/infendro/bytearray/Operators.kt index c00494b..9eeadb0 100644 --- a/src/commonTest/kotlin/com/infendro/bytearray/Operators.kt +++ b/src/commonTest/kotlin/com/infendro/bytearray/Operators.kt @@ -6,7 +6,7 @@ import kotlin.test.assertFails class `Operators Test` { @Test - fun `ByteArray - and() - size`() { + fun `ByteArray and - size`() { assertFails { byteArrayOf() and byteArrayOf(0x00) } @@ -16,14 +16,14 @@ class `Operators Test` { } @Test - fun `ByteArray - and()`() { + fun `ByteArray and`() { val expected = byteArrayOf(0x18, 0x00) val actual = byteArrayOf(0x5C, 0x70) and byteArrayOf(0x3A, 0x0F) assertContentEquals(expected, actual) } @Test - fun `UByteArray - and() - size`() { + fun `UByteArray and - size`() { assertFails { ubyteArrayOf() and ubyteArrayOf(0x00U) } @@ -33,14 +33,14 @@ class `Operators Test` { } @Test - fun `UByteArray - and()`() { + fun `UByteArray and`() { val expected = ubyteArrayOf(0x18U, 0x00U) val actual = ubyteArrayOf(0x5CU, 0x70U) and ubyteArrayOf(0x3AU, 0x0FU) assertContentEquals(expected, actual) } @Test - fun `ByteArray - or() - size`() { + fun `ByteArray or - size`() { assertFails { byteArrayOf() or byteArrayOf(0x00) } @@ -50,14 +50,14 @@ class `Operators Test` { } @Test - fun `ByteArray - or()`() { + fun `ByteArray or`() { val expected = byteArrayOf(0x7E, 0x7F) val actual = byteArrayOf(0x5C, 0x70) or byteArrayOf(0x3A, 0x0F) assertContentEquals(expected, actual) } @Test - fun `UByteArray - or() - size`() { + fun `UByteArray or - size`() { assertFails { ubyteArrayOf() or ubyteArrayOf(0x00U) } @@ -67,14 +67,14 @@ class `Operators Test` { } @Test - fun `UByteArray - or()`() { + fun `UByteArray or`() { val expected = ubyteArrayOf(0x7EU, 0x7FU) val actual = ubyteArrayOf(0x5CU, 0x70U) or ubyteArrayOf(0x3AU, 0x0FU) assertContentEquals(expected, actual) } @Test - fun `ByteArray - xor() - size`() { + fun `ByteArray xor - size`() { assertFails { byteArrayOf() xor byteArrayOf(0x00) } @@ -84,14 +84,14 @@ class `Operators Test` { } @Test - fun `ByteArray - xor()`() { + fun `ByteArray xor`() { val expected = byteArrayOf(0x66, 0x7F) val actual = byteArrayOf(0x5C, 0x70) xor byteArrayOf(0x3A, 0x0F) assertContentEquals(expected, actual) } @Test - fun `UByteArray - xor() - size`() { + fun `UByteArray xor - size`() { assertFails { ubyteArrayOf() xor ubyteArrayOf(0x00U) } @@ -101,7 +101,7 @@ class `Operators Test` { } @Test - fun `UByteArray - xor()`() { + fun `UByteArray xor`() { val expected = ubyteArrayOf(0x66U, 0x7FU) val actual = ubyteArrayOf(0x5CU, 0x70U) xor ubyteArrayOf(0x3AU, 0x0FU) assertContentEquals(expected, actual) diff --git a/src/commonTest/kotlin/com/infendro/bytearray/String.kt b/src/commonTest/kotlin/com/infendro/bytearray/String.kt index 9db7a40..1f830bd 100644 --- a/src/commonTest/kotlin/com/infendro/bytearray/String.kt +++ b/src/commonTest/kotlin/com/infendro/bytearray/String.kt @@ -6,14 +6,14 @@ import kotlin.test.assertEquals class `String Test` { @Test - fun `encodeToUByteArray()`() { + fun `UByteArray encodeToUByteArray`() { val expected = ubyteArrayOf(0x50U, 0x41U, 0x53U, 0x53U, 0x57U, 0x4FU, 0x52U, 0x44U) val actual = "PASSWORD".encodeToUByteArray() assertContentEquals(expected, actual) } @Test - fun `decodeToString()`() { + fun `UByteArray decodeToString`() { val expected = "PASSWORD" val actual = ubyteArrayOf(0x50U, 0x41U, 0x53U, 0x53U, 0x57U, 0x4FU, 0x52U, 0x44U).decodeToString() assertEquals(expected, actual)