package core

import (
	"testing"
)

func TestFilterSlice(t *testing.T) {
	t.Run("filtra pares", func(t *testing.T) {
		got := FilterSlice([]int{1, 2, 3, 4, 5}, func(n int) bool { return n%2 == 0 })
		if len(got) != 2 || got[0] != 2 || got[1] != 4 {
			t.Errorf("got %v, want [2 4]", got)
		}
	})

	t.Run("slice vacio retorna vacio", func(t *testing.T) {
		got := FilterSlice([]int{}, func(n int) bool { return true })
		if len(got) != 0 {
			t.Errorf("got %v, want []", got)
		}
	})

	t.Run("ningun match retorna vacio", func(t *testing.T) {
		got := FilterSlice([]int{1, 3, 5}, func(n int) bool { return n%2 == 0 })
		if len(got) != 0 {
			t.Errorf("got %v, want []", got)
		}
	})
}
