mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-17 23:56:56 +00:00
Other: Safer user types
This commit is contained in:
34
internal/safe/slice_test.go
Normal file
34
internal/safe/slice_test.go
Normal file
@ -0,0 +1,34 @@
|
||||
package safe
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestSlice(t *testing.T) {
|
||||
s := NewSlice(1, 2, 3, 4, 5)
|
||||
|
||||
{
|
||||
var have []int
|
||||
|
||||
s.Iter(func(val int) {
|
||||
have = append(have, val)
|
||||
})
|
||||
|
||||
require.Equal(t, []int{1, 2, 3, 4, 5}, have)
|
||||
}
|
||||
|
||||
s.Append(6)
|
||||
s.Delete(3)
|
||||
|
||||
{
|
||||
var have []int
|
||||
|
||||
s.Iter(func(val int) {
|
||||
have = append(have, val)
|
||||
})
|
||||
|
||||
require.Equal(t, []int{1, 2, 4, 5, 6}, have)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user