Other: Safer user types

This commit is contained in:
James Houlahan
2022-10-12 00:20:04 +02:00
parent 4dc32dc7f2
commit fd63611b41
35 changed files with 1253 additions and 771 deletions

View 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)
}
}