Quellcode durchsuchen

fix: Proper zero character constants

Matthias Ladkau vor 2 Jahren
Ursprung
Commit
2d7d171720

+ 1 - 1
bitutil/packedlist_test.go

@@ -227,7 +227,7 @@ func TestSmallListPacking(t *testing.T) {
 
 	// Simulates a gob encoded string
 
-	if string(UnpackSmallList(string([]byte{0x00}))) != string(0x00) {
+	if string(UnpackSmallList(string([]byte{0x00}))) != string([]byte{0x00}) {
 		t.Error("Unexpected result")
 		return
 	}

+ 1 - 1
cryptutil/gencert_test.go

@@ -23,7 +23,7 @@ import (
 
 const certDir = "certs"
 
-const invalidFileName = "**" + string(0x0)
+const invalidFileName = "**\x00"
 
 func TestMain(m *testing.M) {
 	flag.Parse()

+ 1 - 1
datautil/persistentmap_test.go

@@ -20,7 +20,7 @@ import (
 
 const testdbdir = "test"
 
-const invalidFileName = "**" + string(0x0)
+const invalidFileName = "**\x00"
 
 func TestMain(m *testing.M) {
 	flag.Parse()

+ 6 - 6
fileutil/config_test.go

@@ -17,7 +17,7 @@ import (
 	"time"
 )
 
-const InvalidFileName = "**" + string(0x0)
+const InvalidFileName = "**\x00"
 
 var testDefaultConfig = map[string]interface{}{
 	"MemoryOnlyStorage": false,
@@ -99,10 +99,10 @@ func TestLoadingConfig(t *testing.T) {
 
 	// Check invalid config file
 
-	configFile = "**" + string(0x0)
+	configFile = "**\x00"
 
 	_, err = LoadConfig(configFile, testDefaultConfig)
-	if !strings.Contains(strings.ToLower(err.Error()), string(0)+": invalid argument") {
+	if !strings.Contains(strings.ToLower(err.Error()), "\x00: invalid argument") {
 		t.Error(err)
 		return
 	}
@@ -178,19 +178,19 @@ func TestPersistedConfig(t *testing.T) {
 	time.Sleep(10 * time.Millisecond)
 
 	_, _, err = pt.GetValue("MemoryOnlyStorage")
-	if err == nil || err.Error() != "Could not sync config from disk: open **"+string(0)+": invalid argument" {
+	if err == nil || err.Error() != "Could not sync config from disk: open **\x00: invalid argument" {
 		t.Error("Unexpected stored value:", err)
 		return
 	}
 
 	_, err = pt.GetConfig()
-	if err == nil || err.Error() != "Could not sync config from disk: open **"+string(0)+": invalid argument" {
+	if err == nil || err.Error() != "Could not sync config from disk: open **\x00: invalid argument" {
 		t.Error("Unexpected stored value:", err)
 		return
 	}
 
 	err = pt.Close()
-	if err == nil || err.Error() != "Could not sync config from disk: open **"+string(0)+": invalid argument" {
+	if err == nil || err.Error() != "Could not sync config from disk: open **\x00: invalid argument" {
 		t.Error("Unexpected stored value:", err)
 		return
 	}

+ 2 - 2
fileutil/fileutil_test.go

@@ -45,7 +45,7 @@ func TestDirectoryExists(t *testing.T) {
 		return
 	}
 
-	_, err = PathExists("**" + string(0x0))
+	_, err = PathExists("**\x00")
 	if err == nil {
 		t.Error("Incorrect paths should throw an error")
 		return
@@ -79,7 +79,7 @@ func TestIsDir(t *testing.T) {
 		return
 	}
 
-	_, err = IsDir("**" + string(0x0))
+	_, err = IsDir("**\x00")
 	if err == nil {
 		t.Error("Incorrect paths should throw an error")
 		return

+ 1 - 1
fileutil/multifilebuffer_test.go

@@ -21,7 +21,7 @@ const BUFTESTPATH = "filebuftestpath"
 
 func TestMultiFileBufferErrors(t *testing.T) {
 
-	buf, err := NewMultiFileBuffer("**"+string(0x0),
+	buf, err := NewMultiFileBuffer("**\x00",
 		ConsecutiveNumberIterator(5), EmptyRolloverCondition())
 
 	if buf != nil || err == nil {

+ 1 - 1
httputil/httpserver_test.go

@@ -34,7 +34,7 @@ const certdir = "certs"
 const testporthttp = ":9050"
 const testporthttps = ":9051"
 
-const invalidFileName = "**" + string(0x0)
+const invalidFileName = "**\x00"
 
 func TestMain(m *testing.M) {
 	flag.Parse()

+ 1 - 1
httputil/util_test.go

@@ -18,7 +18,7 @@ import (
 	"testing"
 )
 
-const InvalidFileName = "**" + string(0x0)
+const InvalidFileName = "**\x00"
 
 /*
 dummyResponse is a dummy object for http response testing

+ 1 - 1
lockutil/lockfile_test.go

@@ -22,7 +22,7 @@ import (
 
 const lfdir = "lockfiletest"
 
-const invalidFileName = "**" + string(0x0)
+const invalidFileName = "**\x00"
 
 func TestMain(m *testing.M) {
 	flag.Parse()