File: cast_test.go

package info (click to toggle)
golang-github-anacrolix-missinggo 2.1.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 836 kB
  • sloc: makefile: 4
file content (25 lines) | stat: -rw-r--r-- 485 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package slices

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

type herp int

func TestCastSliceInterface(t *testing.T) {
	var dest []herp
	MakeInto(&dest, []interface{}{herp(1), herp(2)})
	assert.Len(t, dest, 2)
	assert.EqualValues(t, 1, dest[0])
	assert.EqualValues(t, 2, dest[1])
}

func TestCastSliceInts(t *testing.T) {
	var dest []int
	MakeInto(&dest, []uint32{1, 2})
	assert.Len(t, dest, 2)
	assert.EqualValues(t, 1, dest[0])
	assert.EqualValues(t, 2, dest[1])
}