add test for sanitize func

Signed-off-by: aog <theaog@users.noreply.github.com>
This commit is contained in:
aog 2023-02-25 11:09:40 +02:00
parent 97541aba4b
commit 513e90d9dc

25
tools/cg/main_test.go Normal file

@ -0,0 +1,25 @@
package main
import (
"os"
"testing"
)
func TestSanitize(t *testing.T) {
from := "/dev/urandom"
file, err := os.Open(from)
if err != nil {
t.Fatalf("unable to open file %v", err)
}
defer file.Close()
data := make([]byte, 4096)
n, err := file.Read(data)
if err != nil {
t.Fatalf("unable to read bytes: %v", err)
}
t.Logf("read %v bytes from %v", n, from)
r1 := sanitize(string(data))
t.Logf("result1: %v", r1)
}