more tests

This commit is contained in:
Simon Waldherr
2018-10-20 18:31:30 +02:00
parent d95b30df9b
commit 2eb19cc251
7 changed files with 26 additions and 3 deletions

View File

@@ -11,6 +11,8 @@
The ZPLGFA Golang package implements some functions to convert PNG, JPEG and GIF files to ZPL compatible ^GF-elements ([Graphic Fields](https://www.zebra.com/us/en/support-downloads/knowledge-articles/gf-graphic-field-zpl-command.html)). The ZPLGFA Golang package implements some functions to convert PNG, JPEG and GIF files to ZPL compatible ^GF-elements ([Graphic Fields](https://www.zebra.com/us/en/support-downloads/knowledge-articles/gf-graphic-field-zpl-command.html)).
If you need a ready to use application and don't want to hassle around with source code, take a look at the [ZPLGFA CLI Tool](https://github.com/SimonWaldherr/zplgfa/tree/master/cmd/zplgfa) which is based on this package.
## install ## install
1. [install Golang](https://golang.org/doc/install) 1. [install Golang](https://golang.org/doc/install)

7
tests/README.md Normal file
View File

@@ -0,0 +1,7 @@
# ZPLGFA Tests
This folder contains some test cases for the ZPLGFA package.
The test coverage can be seen at the [coveralls](https://coveralls.io/github/SimonWaldherr/zplgfa?branch=master) project page.
[![Coverage Status](https://coveralls.io/repos/github/SimonWaldherr/zplgfa/badge.svg?branch=master)](https://coveralls.io/github/SimonWaldherr/zplgfa?branch=master)

BIN
tests/test4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
tests/test5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

File diff suppressed because one or more lines are too long

View File

@@ -185,9 +185,6 @@ func ConvertToGraphicField(source image.Image, graphicType GraphicType) string {
lastLine = curLine lastLine = curLine
case Binary: case Binary:
GraphicFieldData += fmt.Sprintf("%s", line) GraphicFieldData += fmt.Sprintf("%s", line)
default:
graphicType = CompressedASCII
GraphicFieldData += fmt.Sprintln(CompressASCII(hexstr))
} }
} }

View File

@@ -1,6 +1,7 @@
package zplgfa package zplgfa
import ( import (
"encoding/base64"
"encoding/json" "encoding/json"
"image" "image"
_ "image/gif" _ "image/gif"
@@ -81,7 +82,13 @@ 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)
switch graphictype {
case "Binary":
gfimg = base64.StdEncoding.EncodeToString([]byte(gfimg))
}
if gfimg != zplstring { if gfimg != zplstring {
log.Printf("ConvertToZPL Test for file \"%s\" failed, wanted: \n%s\ngot: \n%s\n", filename, zplstring, gfimg)
t.Fatalf("Testcase %d ConvertToZPL failed", i) t.Fatalf("Testcase %d ConvertToZPL failed", i)
} }
} }