ソースを参照

Increase the Coverage of pkg/platform

Signed-off-by: Raja Sami <raja.sami@tenpearls.com>
Raja Sami 8 年 前
コミット
bdc87676bf
2 ファイル変更32 行追加0 行削除
  1. 16 0
      pkg/platform/utsname_int8_test.go
  2. 16 0
      pkg/platform/utsname_uint8_test.go

+ 16 - 0
pkg/platform/utsname_int8_test.go

@@ -0,0 +1,16 @@
+// +build linux,386 linux,amd64 linux,arm64
+
+package platform
+
+import (
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+)
+
+func TestCharToString(t *testing.T) {
+	machineInBytes := [65]int8{120, 56, 54, 95, 54, 52}
+	machineInString := charsToString(machineInBytes)
+	assert.NotNil(t, machineInString, "Unable to convert char into string.")
+	assert.Equal(t, string("x86_64"), machineInString, "Parsed machine code not equal.")
+}

+ 16 - 0
pkg/platform/utsname_uint8_test.go

@@ -0,0 +1,16 @@
+// +build linux,arm linux,ppc64 linux,ppc64le s390x
+
+package platform
+
+import (
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+)
+
+func TestTestCharToString(t *testing.T) {
+	machineInBytes := [65]uint8{120, 56, 54, 95, 54, 52}
+	machineInString := charsToString(machineInBytes)
+	assert.NotNil(t, machineInString, "Unable to convert char into string.")
+	assert.Equal(t, string("x86_64"), machineInString, "Parsed machine code not equal.")
+}