more tests, more badges
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
# ZPLGFA Golang Package
|
# ZPLGFA Golang Package
|
||||||
|
|
||||||
[](https://godoc.org/github.com/SimonWaldherr/zplgfa)
|
[](https://godoc.org/github.com/SimonWaldherr/zplgfa)
|
||||||
|
[](https://travis-ci.org/SimonWaldherr/zplgfa)
|
||||||
|
[](https://coveralls.io/github/SimonWaldherr/zplgfa?branch=master)
|
||||||
[](https://goreportcard.com/report/github.com/SimonWaldherr/zplgfa)
|
[](https://goreportcard.com/report/github.com/SimonWaldherr/zplgfa)
|
||||||
[](https://codebeat.co/projects/github-com-simonwaldherr-zplgfa-master)
|
[](https://codebeat.co/projects/github-com-simonwaldherr-zplgfa-master)
|
||||||
[](https://bettercodehub.com/results/SimonWaldherr/zplgfa)
|
[](https://bettercodehub.com/results/SimonWaldherr/zplgfa)
|
||||||
|
|||||||
@@ -11,15 +11,40 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type zplTest struct {
|
||||||
|
file string
|
||||||
|
zpl string
|
||||||
|
}
|
||||||
|
|
||||||
|
var zplTests []zplTest
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
zplTests = []zplTest{
|
||||||
|
{
|
||||||
|
file: "./test.png",
|
||||||
|
zpl: "^XA,^FS^FO0,0^GFA,32,51,3,,::01C000::,001C00::,1DDC00::,::^FS,^XZ",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
file: "./test2.png",
|
||||||
|
zpl: "^XA,^FS^FO0,0^GFA,389,630,63,,038038038038038038038038038038038038038038038038038038038038038038038038038038038038038038038038038038038038038038038038038000::1C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C7100::E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00:lJF00^FS,^XZ",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func Test_CompressASCII(t *testing.T) {
|
func Test_CompressASCII(t *testing.T) {
|
||||||
if str := CompressASCII("FFFFFFFF000000"); str != "NFL0" {
|
if str := CompressASCII("FFFFFFFF000000"); str != "NFL0" {
|
||||||
t.Fatalf("CompressASCII failed")
|
t.Fatalf("CompressASCII failed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func Test_ConvertToZPL(t *testing.T) {
|
func Test_ConvertToZPL(t *testing.T) {
|
||||||
|
for i, testcase := range zplTests {
|
||||||
|
|
||||||
|
filename, zplstring := testcase.file, testcase.zpl
|
||||||
// open file
|
// open file
|
||||||
file, err := os.Open("./test.png")
|
file, err := os.Open(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Warning: could not open the file: %s\n", err)
|
log.Printf("Warning: could not open the file: %s\n", err)
|
||||||
return
|
return
|
||||||
@@ -53,7 +78,8 @@ func Test_ConvertToZPL(t *testing.T) {
|
|||||||
gfimg = strings.Replace(gfimg, " ", "", -1)
|
gfimg = strings.Replace(gfimg, " ", "", -1)
|
||||||
gfimg = strings.Replace(gfimg, "\n", "", -1)
|
gfimg = strings.Replace(gfimg, "\n", "", -1)
|
||||||
|
|
||||||
if gfimg != "^XA,^FS^FO0,0^GFA,32,51,3,,::01C000::,001C00::,1DDC00::,::^FS,^XZ" {
|
if gfimg != zplstring {
|
||||||
t.Fatalf("ConvertToZPL failed")
|
t.Fatalf("Testcase %d ConvertToZPL failed", i)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user