-
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.
- Loading branch information
1 parent
e48c1a1
commit ddc0f0b
Showing
5 changed files
with
39 additions
and
10 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
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,17 @@ | ||
package info.mking.k2zpl.command | ||
|
||
import info.mking.k2zpl.builder.ZplBuilder | ||
import info.mking.k2zpl.builder.command | ||
|
||
internal data class FieldData(val data: String) : ZplCommand { | ||
override val command: CharSequence = "^FD" | ||
override val parameters: LinkedHashMap<CharSequence, Any?> = linkedMapOf("d" to data) | ||
} | ||
|
||
/** | ||
* Adds field data. | ||
* @param data The data to be added to the field. | ||
*/ | ||
fun ZplBuilder.fieldData(data: String) { | ||
command(FieldData(data)) | ||
} |
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,27 @@ | ||
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 FieldDataTest : DescribeSpec({ | ||
isolationMode = IsolationMode.InstancePerLeaf | ||
|
||
val fieldData = FieldData("some-data") | ||
|
||
describe("FieldData") { | ||
it("outputs correct command") { | ||
fieldData.testBuildString() shouldBe "^FDsome-data" | ||
} | ||
} | ||
describe("fieldData extension function") { | ||
it("outputs correct command") { | ||
val result = k2zpl { | ||
fieldData("some-other-data") | ||
} | ||
result shouldBe "^FDsome-other-data\n" | ||
} | ||
} | ||
}) |