From eee4f8a964ac3a9a39d9975ae9fe42527dbfaabd Mon Sep 17 00:00:00 2001 From: Marko Kungla Date: Tue, 21 Nov 2023 05:32:37 +0200 Subject: [PATCH] devops: add FormatByteSlice tests Signed-off-by: Marko Kungla --- nfcsdk_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 nfcsdk_test.go diff --git a/nfcsdk_test.go b/nfcsdk_test.go new file mode 100644 index 0000000..0c45214 --- /dev/null +++ b/nfcsdk_test.go @@ -0,0 +1,29 @@ +// Copyright 2023 The Happy Authors +// Licensed under the Apache License, Version 2.0. +// See the LICENSE file. + +package nfcsdk_test + +import ( + "testing" + + "github.com/happy-sdk/nfcsdk/internal/helpers" +) + +func TestFormatByteSlice(t *testing.T) { + // Test case 1: An empty byte slice should return an empty string. + emptySlice := []byte{} + result := helpers.FormatByteSlice(emptySlice) + expected := "" + if result != expected { + t.Errorf("Expected '%s', but got '%s'", expected, result) + } + + // Test case 2: A byte slice with some data should be formatted as expected. + dataSlice := []byte{72, 101, 108, 108, 111} // ASCII values for "Hello" + result = helpers.FormatByteSlice(dataSlice) + expected = "48:65:6C:6C:6F" // Hexadecimal representation of ASCII values + if result != expected { + t.Errorf("Expected '%s', but got '%s'", expected, result) + } +}