From 99e83b59d101e644a16fa2aa27d31eb9df6495a0 Mon Sep 17 00:00:00 2001 From: Matt King Date: Fri, 20 Sep 2024 10:59:03 +0100 Subject: [PATCH] [#15] Use `addParameters` in tests as well, and update missed usages. --- src/main/kotlin/com/sainsburys/k2zpl/command/Font.kt | 2 +- .../kotlin/com/sainsburys/k2zpl/command/GraphicBox.kt | 2 +- src/main/kotlin/com/sainsburys/k2zpl/command/MediaMode.kt | 2 +- .../kotlin/com/sainsburys/k2zpl/command/ZplCommand.kt | 2 +- .../kotlin/com/sainsburys/k2zpl/command/ZplCommandTest.kt | 8 ++++---- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/com/sainsburys/k2zpl/command/Font.kt b/src/main/kotlin/com/sainsburys/k2zpl/command/Font.kt index 7fc104d..11e6708 100644 --- a/src/main/kotlin/com/sainsburys/k2zpl/command/Font.kt +++ b/src/main/kotlin/com/sainsburys/k2zpl/command/Font.kt @@ -18,7 +18,7 @@ internal data class Font( override val command: CharSequence = "^A${font}" override val parameters: Map = - linkedMapOf("o" to orientation, "h" to height, "w" to width) + addParameters("o" to orientation, "h" to height, "w" to width) } diff --git a/src/main/kotlin/com/sainsburys/k2zpl/command/GraphicBox.kt b/src/main/kotlin/com/sainsburys/k2zpl/command/GraphicBox.kt index ec9be03..092318c 100644 --- a/src/main/kotlin/com/sainsburys/k2zpl/command/GraphicBox.kt +++ b/src/main/kotlin/com/sainsburys/k2zpl/command/GraphicBox.kt @@ -19,7 +19,7 @@ internal data class GraphicBox( override val command: CharSequence = "^GB" override val parameters: Map = - linkedMapOf( + addParameters( "w" to width, "h" to height, "t" to thickness, "c" to color.code, diff --git a/src/main/kotlin/com/sainsburys/k2zpl/command/MediaMode.kt b/src/main/kotlin/com/sainsburys/k2zpl/command/MediaMode.kt index d845a86..15d7e4d 100644 --- a/src/main/kotlin/com/sainsburys/k2zpl/command/MediaMode.kt +++ b/src/main/kotlin/com/sainsburys/k2zpl/command/MediaMode.kt @@ -11,7 +11,7 @@ internal data class MediaMode( ) : ZplCommand { override val command: CharSequence = "^MM" override val parameters: Map = - linkedMapOf("m" to mediaMode, "p" to prePeelSelect) + addParameters("m" to mediaMode, "p" to prePeelSelect) } /** diff --git a/src/main/kotlin/com/sainsburys/k2zpl/command/ZplCommand.kt b/src/main/kotlin/com/sainsburys/k2zpl/command/ZplCommand.kt index 3bfd5f5..ec45921 100644 --- a/src/main/kotlin/com/sainsburys/k2zpl/command/ZplCommand.kt +++ b/src/main/kotlin/com/sainsburys/k2zpl/command/ZplCommand.kt @@ -2,7 +2,7 @@ package com.sainsburys.k2zpl.command interface ZplCommand { val command: CharSequence - val parameters: Map get() = linkedMapOf() + val parameters: Map get() = addParameters() fun build(stringBuilder: StringBuilder) = stringBuilder.apply { append(command) with(parameters.values.iterator()) { diff --git a/src/test/kotlin/com/sainsburys/k2zpl/command/ZplCommandTest.kt b/src/test/kotlin/com/sainsburys/k2zpl/command/ZplCommandTest.kt index 8e8f80d..0046bb5 100644 --- a/src/test/kotlin/com/sainsburys/k2zpl/command/ZplCommandTest.kt +++ b/src/test/kotlin/com/sainsburys/k2zpl/command/ZplCommandTest.kt @@ -33,14 +33,14 @@ class ZplCommandWithoutParameters : ZplCommand { class ZplCommandWithOneParameter : ZplCommand { override val command = "^ZCP" - override val parameters: Map = linkedMapOf( + override val parameters: Map = addParameters( "param-one" to "value-one" ) } class ZplCommandWithMultipleParameters : ZplCommand { override val command = "^ZCPS" - override val parameters: Map = linkedMapOf( + override val parameters: Map = addParameters( "param-one" to "value-one", "param-two" to "value-two" ) @@ -48,7 +48,7 @@ class ZplCommandWithMultipleParameters : ZplCommand { class ZplCommandWitNullFirstParameter : ZplCommand { override val command = "^ZCPN" - override val parameters: Map = linkedMapOf( + override val parameters: Map = addParameters( "param-one" to null, "param-two" to "value-two" ) @@ -56,7 +56,7 @@ class ZplCommandWitNullFirstParameter : ZplCommand { class ZplCommandWitNullSecondParameter : ZplCommand { override val command = "^ZCPNS" - override val parameters: Map = linkedMapOf( + override val parameters: Map = addParameters( "param-one" to "value-one", "param-two" to null )