-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add LabelHome test and move extension function
- Loading branch information
1 parent
796b764
commit 70a74e0
Showing
3 changed files
with
43 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,18 @@ | ||
package info.mking.k2zpl.command | ||
|
||
import info.mking.k2zpl.builder.ZplBuilder | ||
import info.mking.k2zpl.builder.command | ||
|
||
internal data class LabelHome(val x: Int, val y: Int) : ZplCommand { | ||
override val command: CharSequence = "^LH" | ||
override val parameters: LinkedHashMap<CharSequence, Any?> = linkedMapOf("x" to x, "y" to y) | ||
} | ||
|
||
/** | ||
* Sets the label home position. | ||
* @param x The x-coordinate of the label home. | ||
* @param y The y-coordinate of the label home. | ||
*/ | ||
fun ZplBuilder.labelHome(x: Int, y: Int) { | ||
command(LabelHome(x = x, y = y)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package info.mking.k2zpl.command | ||
|
||
import info.mking.k2zpl.k2zpl | ||
import info.mking.k2zpl.testBuildString | ||
import io.kotest.core.spec.IsolationMode | ||
import io.kotest.core.spec.style.DescribeSpec | ||
import io.kotest.matchers.shouldBe | ||
|
||
class LabelHomeTest : DescribeSpec({ | ||
|
||
isolationMode = IsolationMode.InstancePerLeaf | ||
|
||
val labelHome = LabelHome( | ||
x = 10, | ||
y = 10 | ||
) | ||
|
||
describe("LabelHome") { | ||
it("outputs the correct command") { | ||
labelHome.testBuildString() shouldBe "^LH10,10" | ||
} | ||
} | ||
describe("labelHome extension function") { | ||
it("outputs the correct command") { | ||
val result = k2zpl { | ||
labelHome(x = 0, y = 100) | ||
} | ||
result shouldBe "^LH0,100\n" | ||
} | ||
} | ||
}) |