package vuln

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

type testData struct {
	input    string
	pattern  string
	expected bool
}

func TestIsMatch(t *testing.T) {
	tests := []testData{
		{
			input:    "",
			pattern:  "",
			expected: true,
		},
		{
			input:    "test",
			pattern:  "test",
			expected: true,
		},
		{
			input:    "Test",
			pattern:  "test",
			expected: false,
		},
		{
			input:    "test",
			pattern:  "?est",
			expected: true,
		},
		{
			input:    "test",
			pattern:  "t*st",
			expected: true,
		},
		{
			input:    "Test",
			pattern:  "*est",
			expected: true,
		},
		{
			input:    "Test",
			pattern:  "Te*",
			expected: true,
		},
		{
			input:    "Test",
			pattern:  "Te??",
			expected: true,
		},
		{
			input:    "Test",
			pattern:  "Te?",
			expected: false,
		},
		{
			input:    "Test",
			pattern:  "Te?*",
			expected: true,
		},
	}

	for _, v := range tests {
		t.Run("", func(t *testing.T) {
			match := IsMatch(v.input, v.pattern)
			assert.Equal(t, v.expected, match)
		})
	}
}
