package configgen

import (
	"fmt"
	"strings"
	"testing"
)

func TestWordListNoDuplicates(t *testing.T) {
	seen := make(map[string]bool, len(wordList))
	for i, w := range wordList {
		if seen[w] {
			t.Errorf("duplicate word %q at index %d", w, i)
		}
		seen[w] = true
	}
	t.Logf("Total unique words: %d", len(seen))
}

func TestWordListSize(t *testing.T) {
	if len(wordList) < 10000 {
		t.Errorf("word list too small: %d (want >= 10000)", len(wordList))
	}
	t.Logf("Word list size: %d", len(wordList))
}

func TestRandomPassphrase(t *testing.T) {
	p, err := RandomPassphrase(5)
	if err != nil {
		t.Fatal(err)
	}
	parts := strings.Split(p, "-")
	if len(parts) != 5 {
		t.Errorf("expected 5 words, got %d: %s", len(parts), p)
	}
	for _, word := range parts {
		if word == "" {
			t.Error("empty word in passphrase")
		}
	}
	t.Logf("Sample passphrase: %s", p)
}

func TestRandomPassphraseSamples(t *testing.T) {
	for i := 0; i < 5; i++ {
		p, err := RandomPassphrase(5)
		if err != nil {
			t.Fatal(err)
		}
		fmt.Printf("  Sample %d: %s\n", i+1, p)
	}
}
