1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/didiopensource-collection

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
int_collection_test.go 1.3 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
yejianfeng Отправлено 09.10.2020 05:26 7a50a6e
package collection
import (
"reflect"
"testing"
)
func TestIntCollection_Insert(t *testing.T) {
{
a := NewIntCollection([]int{1, 2, 3})
b, err := a.Insert(1, 10).ToInts()
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(b, []int{1, 10, 2, 3}) {
t.Fatal("insert error")
}
}
{
a := NewIntCollection([]int{1, 2, 3})
b, err := a.Insert(0, 10).ToInts()
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(b, []int{10, 1, 2, 3}) {
t.Fatal("insert 0 error")
}
}
{
a := NewIntCollection([]int{1, 2, 3})
b, err := a.Insert(3, 10).ToInts()
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(b, []int{1, 2, 3, 10}) {
t.Fatal("insert length error")
}
}
}
func TestIntCollection_Filter(t *testing.T) {
intColl := NewIntCollection([]int{1, 2, 3})
a, err := intColl.First().ToInt()
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(a, 1) {
t.Fatal("filter error")
}
}
func TestIntCollection_Index(t *testing.T) {
intColl := NewIntCollection([]int{1, 2, 3})
iMix := intColl.Index(2)
if iMix.Err() != nil {
t.Fatal(iMix.Err())
}
i, err := iMix.ToInt()
if err != nil {
t.Fatal("index error")
}
if i != 3 {
t.Fatal("not equal")
}
}
func TestIntCollection_Remove(t *testing.T) {
intColl := NewIntCollection([]int{1, 2, 3})
r := intColl.Remove(0)
if r.Err() != nil {
t.Fatal(r.Err())
}
}

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/didiopensource-collection.git
git@api.gitlife.ru:oschina-mirror/didiopensource-collection.git
oschina-mirror
didiopensource-collection
didiopensource-collection
master