Skip to content

Commit

Permalink
autotests
Browse files Browse the repository at this point in the history
  • Loading branch information
be4dev committed Dec 30, 2023
1 parent c8a213a commit 1070db2
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "master" branch
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
run_tests:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Set up JDK 19
uses: actions/setup-java@v1
with:
java-version: 19
- name: Cache Gradlew packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
- name: Run tests with Gradle
run: ./gradlew test
78 changes: 78 additions & 0 deletions src/test/kotlin/MainTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import kotlin.test.Test

internal class Test {
@Test
fun test() {
val examplePos = Position(
2, mutableListOf(
Line(byteArrayOf(8, 7, 6, 5, 0, 0, 0, 0)),
Line(byteArrayOf(0, 0, 0, 0, 0, 0, 0, 0)),
Line(byteArrayOf(4, 3, 2, 1, 0, 0, 0, 0))
)
)
val solveResult = solve(examplePos)
assert(solveResult.first.size == 16)
assert(solveResult.second < 300L)
occurredPositions.clear()
}

@Test
fun test1() {
val examplePos = Position(
2, mutableListOf(
Line(byteArrayOf(8, 7, 6, 0, 0, 0, 0, 0)),
Line(byteArrayOf(0, 0, 0, 0, 0, 0, 0, 0)),
Line(byteArrayOf(5, 4, 3, 2, 1, 0, 0, 0))
)
)
val solveResult = solve(examplePos)
assert(solveResult.first.size == 32)
assert(solveResult.second < 300L)
occurredPositions.clear()
}

@Test
fun test2() {
val examplePos = Position(
2, mutableListOf(
Line(byteArrayOf(8, 7, 0, 0, 0, 0, 0, 0)),
Line(byteArrayOf(0, 0, 0, 0, 0, 0, 0, 0)),
Line(byteArrayOf(6, 5, 4, 3, 2, 1, 0, 0))
)
)
val solveResult = solve(examplePos)
assert(solveResult.first.size == 64)
assert(solveResult.second < 1000L)
occurredPositions.clear()
}

@Test
fun test3() {
val examplePos = Position(
2, mutableListOf(
Line(byteArrayOf(8, 0, 0, 0, 0, 0, 0, 0)),
Line(byteArrayOf(0, 0, 0, 0, 0, 0, 0, 0)),
Line(byteArrayOf(7, 6, 5, 4, 3, 2, 1, 0))
)
)
val solveResult = solve(examplePos)
assert(solveResult.first.size == 128)
assert(solveResult.second < 2500L)
occurredPositions.clear()
}

@Test
fun test4() {
val examplePos = Position(
2, mutableListOf(
Line(byteArrayOf(0, 0, 0, 0, 0, 0, 0, 0)),
Line(byteArrayOf(0, 0, 0, 0, 0, 0, 0, 0)),
Line(byteArrayOf(8, 7, 6, 5, 4, 3, 2, 1))
)
)
val solveResult = solve(examplePos)
assert(solveResult.first.size == 256)
assert(solveResult.second < 5000L)
occurredPositions.clear()
}
}

0 comments on commit 1070db2

Please sign in to comment.