Skip to content

Commit 2364414

Browse files
committed
Add Tests, Update group Value
1 parent 7e51cd7 commit 2364414

File tree

7 files changed

+133
-1
lines changed

7 files changed

+133
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# levelz-cli
22

3+
![GitHub License](https://img.shields.io/github/license/LevelZ-File/cli)
4+
![GitHub Issues or Pull Requests](https://img.shields.io/github/issues/LevelZ-File/cli)
5+
![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/LevelZ-File/cli/total)
6+
37
This is the CLI version of the LevelZ File Format, powered by the [levelz-kt](https://github.com/LevelZ-File/kotlin-bindings) and [Clikt](https://github.com/ajalt/clikt).
48

59
The tool is available on Windows, macOS, and Linux.

build.gradle.kts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ plugins {
88

99
val v = "0.1.0"
1010

11-
group = "xyz.calcugames.levelz.cli"
11+
group = "xyz.calcugames"
1212
version = if (project.hasProperty("snapshot")) "$v-SNAPSHOT" else v
1313
description = "The official CLI for the LevelZ File Format"
1414

@@ -23,6 +23,8 @@ dependencies {
2323
commonMainImplementation("com.github.ajalt.clikt:clikt:4.4.0")
2424
commonMainImplementation("xyz.calcugames:levelz-kt:0.2.4")
2525
commonMainImplementation("com.soywiz:korlibs-io:6.0.1")
26+
27+
commonTestImplementation(kotlin("test"))
2628
}
2729

2830
kotlin {
@@ -45,6 +47,27 @@ kotlin {
4547
}
4648
}
4749

50+
tasks {
51+
register("copyTestResources", Copy::class) {
52+
from("src/commonTest/resources")
53+
into(layout.buildDirectory.dir("bin/test-resources"))
54+
}
55+
56+
named("allTests") {
57+
dependsOn("copyTestResources")
58+
}
59+
60+
withType<Test> {
61+
dependsOn("copyTestResources")
62+
63+
useJUnitPlatform()
64+
testLogging {
65+
events("passed", "skipped", "failed")
66+
showStandardStreams = true
67+
}
68+
}
69+
}
70+
4871
publishing {
4972
publications {
5073
getByName<MavenPublication>("kotlinMultiplatform") {
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package xyz.calcugames.levelz.cli
2+
3+
import com.github.ajalt.clikt.testing.test
4+
import kotlin.test.Test
5+
import kotlin.test.assertTrue
6+
7+
class TestCreate {
8+
9+
@Test
10+
fun testCreate2D() {
11+
val command = Create()
12+
val result = command.test("-d 2 -h spawn [-1,1] -h scroll vertical-up -b grass [0,0] -b grass [0,1]")
13+
println(result.stdout)
14+
15+
assertTrue(result.stdout.contains("@type 2"))
16+
assertTrue(result.stdout.contains("@spawn [-1,1]"))
17+
assertTrue(result.stdout.contains("@scroll vertical-up"))
18+
assertTrue(result.stdout.contains("grass: [0, 0]*[0, 1]"))
19+
}
20+
21+
@Test
22+
fun testCreate3D() {
23+
val command = Create()
24+
val result = command.test("-d 3 -h spawn [-3,-4,5.5] -b grass [0,0,0] -b grass [0,1,0] -b grass [0,0,1]")
25+
println(result.stdout)
26+
27+
assertTrue(result.stdout.contains("@type 3"))
28+
assertTrue(result.stdout.contains("@spawn [-3,-4,5.5]"))
29+
assertTrue(result.stdout.contains("grass: [0, 0, 0]*[0, 1, 0]*[0, 0, 1]"))
30+
}
31+
32+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package xyz.calcugames.levelz.cli
2+
3+
import com.github.ajalt.clikt.testing.test
4+
import kotlin.test.Test
5+
import kotlin.test.assertTrue
6+
7+
class TestEdit {
8+
9+
@Test
10+
fun testEdit2D() {
11+
val command = Edit()
12+
val result = command.test("../../test-resources/input-2D.lvlz -h spawn [2,3] -h scroll horizontal-left -b grass [-1,0] -b grass [1,1]")
13+
println(result.output)
14+
15+
assertTrue(result.stdout.contains("@type 2"))
16+
assertTrue(result.stdout.contains("@spawn [2,3]"))
17+
assertTrue(result.stdout.contains("@scroll horizontal-left"))
18+
assertTrue(result.stdout.contains("grass: [0, 0]*[0, 1]*[-1, 0]*[1, 1]"))
19+
}
20+
21+
@Test
22+
fun testEdit3D() {
23+
val command = Edit()
24+
val result = command.test("../../test-resources/input-3D.lvlz -h spawn [2,6.75,1] -b grass [2.5,0,0] -b grass [0,1,0] -b grass [0,0,1]")
25+
println(result.output)
26+
27+
assertTrue(result.stdout.contains("@type 3"))
28+
assertTrue(result.stdout.contains("@spawn [2,6.75,1]"))
29+
}
30+
31+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package xyz.calcugames.levelz.cli
2+
3+
import com.github.ajalt.clikt.testing.test
4+
import kotlin.test.Test
5+
import kotlin.test.assertEquals
6+
7+
class TestValidate {
8+
9+
@Test
10+
fun testValidate2D() {
11+
val command = Validate()
12+
val result = command.test("../../test-resources/input-2D.lvlz -d 2 -mb 5 -sp [2,2]")
13+
println(result.output)
14+
15+
assertEquals(0, result.statusCode)
16+
}
17+
18+
@Test
19+
fun testValidate3D() {
20+
val command = Validate()
21+
val result = command.test("../../test-resources/input-3D.lvlz -d 3 -mb 5 -sp [-3,4,5]")
22+
println(result.output)
23+
24+
assertEquals(0, result.statusCode)
25+
}
26+
27+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@type 2
2+
@spawn [2, 2]
3+
@scroll vertical-up
4+
---
5+
grass: [0, 0]*[0, 1]
6+
stone: (-5, 5, 0, 0)^[0, 0]
7+
magma: (-5, 5, 0, 0)^[0, -1]
8+
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@type 3
2+
@spawn [-3, 4, 5]
3+
---
4+
grass: [0, 0, 0]*[0, 1, 0]
5+
grass: [0, 0, -1]*[2, 1, 7.5]
6+
stone: (0, 0, 0, 4, 0, 4)^[7, 0, 0]
7+
end

0 commit comments

Comments
 (0)