package core

import (
	"fmt"
	"testing"
)

func TestMapSlice(t *testing.T) {
	t.Run("transforma enteros a strings", func(t *testing.T) {
		got := MapSlice([]int{1, 2, 3}, func(n int) string { return fmt.Sprintf("%d", n) })
		if len(got) != 3 || got[0] != "1" || got[1] != "2" || got[2] != "3" {
			t.Errorf("got %v", got)
		}
	})

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

	t.Run("preserva orden", func(t *testing.T) {
		got := MapSlice([]int{3, 1, 2}, func(n int) int { return n * 10 })
		if got[0] != 30 || got[1] != 10 || got[2] != 20 {
			t.Errorf("got %v, want [30 10 20]", got)
		}
	})
}
