package core

import (
	"testing"
)

func TestAssertContainsAll(t *testing.T) {
	t.Run("todos presentes retorna true y nil", func(t *testing.T) {
		ok, missing := AssertContainsAll([]string{"a", "b", "c"}, []string{"a", "b"})
		if !ok || missing != nil {
			t.Errorf("got ok=%v missing=%v, want ok=true missing=nil", ok, missing)
		}
	})

	t.Run("un elemento faltante retorna false con el faltante", func(t *testing.T) {
		ok, missing := AssertContainsAll([]string{"a", "b"}, []string{"a", "c"})
		if ok {
			t.Error("expected ok=false")
		}
		if len(missing) != 1 || missing[0] != "c" {
			t.Errorf("got missing=%v, want [c]", missing)
		}
	})

	t.Run("multiples faltantes retornan todos en missing", func(t *testing.T) {
		ok, missing := AssertContainsAll([]string{"a"}, []string{"b", "c", "d"})
		if ok {
			t.Error("expected ok=false")
		}
		if len(missing) != 3 {
			t.Errorf("got missing=%v, want [b c d]", missing)
		}
	})

	t.Run("needles vacio retorna true", func(t *testing.T) {
		ok, missing := AssertContainsAll([]string{"a", "b"}, []string{})
		if !ok || missing != nil {
			t.Errorf("got ok=%v missing=%v, want ok=true missing=nil", ok, missing)
		}
	})

	t.Run("haystack vacio con needles no vacios retorna todos como faltantes", func(t *testing.T) {
		ok, missing := AssertContainsAll([]string{}, []string{"x", "y"})
		if ok {
			t.Error("expected ok=false")
		}
		if len(missing) != 2 {
			t.Errorf("got missing=%v, want [x y]", missing)
		}
	})

	t.Run("duplicados en haystack no afectan el resultado", func(t *testing.T) {
		ok, missing := AssertContainsAll([]string{"a", "a", "b", "b"}, []string{"a", "b"})
		if !ok || missing != nil {
			t.Errorf("got ok=%v missing=%v, want ok=true missing=nil", ok, missing)
		}
	})
}
