/*
 * SPDX-FileCopyrightText: 2023 jordi fita mas <jfita@peritasoft.com>
 * SPDX-License-Identifier: AGPL-3.0-only
 */

package uuid

import (
	"strings"
	"testing"
)

type test struct {
	in     string
	isUuid bool
}

var tests = []test{
	{"f47ac10b-58cc-0372-8567-0e02b2c3d479", true},
	{"2bc1be74-169d-4300-a239-49a1196a045d", true},
	{"12bc1be74-169d-4300-a239-49a1196a045d", false},
	{"2bc1be74-169d-4300-a239-49a1196a045", false},
	{"2bc1be74-1x9d-4300-a239-49a1196a045d", false},
	{"2bc1be74-169d-4300-a239-49a1196ag45d", false},
}

func testValid(t *testing.T, in string, isUuid bool) {
	if ok := Valid(in); ok != isUuid {
		t.Errorf("Valid(%s) got %v expected %v", in, ok, isUuid)
	}
}

func TestUUID(t *testing.T) {
	for _, tt := range tests {
		testValid(t, tt.in, tt.isUuid)
		testValid(t, strings.ToUpper(tt.in), tt.isUuid)
	}
}
