github.com/avahowell/sia@v0.5.1-beta.0.20160524050156-83dcc3d37c94/crypto/discard_test.go (about) 1 package crypto 2 3 import ( 4 "bytes" 5 "testing" 6 ) 7 8 // TestUnitSecureWipe tests that the SecureWipe function sets all the elements 9 // in a byte slice to 0. 10 func TestUnitSecureWipe(t *testing.T) { 11 s := []byte{1, 2, 3, 4} 12 SecureWipe(s) 13 if !bytes.Equal(s, make([]byte, len(s))) { 14 t.Error("some bytes not set to 0") 15 } 16 } 17 18 // TestUnitSecureWipeEdgeCases tests that SecureWipe doesn't panic on nil or 19 // empty slices. 20 func TestUnitSecureWipeEdgeCases(t *testing.T) { 21 SecureWipe(nil) 22 SecureWipe([]byte{}) 23 }