mirror of
https://github.com/hackerschoice/segfault.git
synced 2024-06-27 09:18:41 +00:00
add test for sanitize func
Signed-off-by: aog <theaog@users.noreply.github.com>
This commit is contained in:
parent
97541aba4b
commit
513e90d9dc
25
tools/cg/main_test.go
Normal file
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)
|
||||
}
|
Loading…
Reference in New Issue
Block a user