cryptocore: support Go 1.4 in tests
This commit is contained in:
parent
508a949d9d
commit
66156181ee
19
internal/cryptocore/cryptocore_go1.4_test.go
Normal file
19
internal/cryptocore/cryptocore_go1.4_test.go
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// +build !go1.5
|
||||||
|
// = go 1.4 or lower
|
||||||
|
|
||||||
|
package cryptocore
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Native Go crypto with 128-bit IVs is only supported on Go 1.5 and up
|
||||||
|
func TestCryptoCoreNewGo14(t *testing.T) {
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r == nil {
|
||||||
|
t.Errorf("The code did not panic")
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
key := make([]byte, 32)
|
||||||
|
New(key, false, true)
|
||||||
|
}
|
17
internal/cryptocore/cryptocore_go1.5_test.go
Normal file
17
internal/cryptocore/cryptocore_go1.5_test.go
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// +build go1.5
|
||||||
|
// = go 1.5 or higher
|
||||||
|
|
||||||
|
package cryptocore
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Native Go crypto with 128-bit IVs is only supported on Go 1.5 and up
|
||||||
|
func TestCryptoCoreNewGo15(t *testing.T) {
|
||||||
|
key := make([]byte, 32)
|
||||||
|
c := New(key, false, true)
|
||||||
|
if c.IVLen != 12 {
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
}
|
@ -16,10 +16,11 @@ func TestCryptoCoreNew(t *testing.T) {
|
|||||||
if c.IVLen != 12 {
|
if c.IVLen != 12 {
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
c = New(key, false, true)
|
c = New(key, false, false)
|
||||||
if c.IVLen != 16 {
|
if c.IVLen != 12 {
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
|
// "New(key, false, true)" is tested for Go 1.4 and 1.5+ seperately
|
||||||
}
|
}
|
||||||
|
|
||||||
// "New" should panic on any key not 32 bytes long
|
// "New" should panic on any key not 32 bytes long
|
||||||
|
Loading…
Reference in New Issue
Block a user