Files
gofatqr/nif_test.go
T
esilva f61535e7e7 Basic functionality
User can pass a string to the Scanner and get the struced filled
2025-09-05 18:51:51 +01:00

44 lines
695 B
Go

package gofatqr
import (
"fmt"
"testing"
)
func TestIsValidNIF(t *testing.T) {
testCases := []struct {
name string
expect bool
input string
}{
{
name: "Normal NIF",
expect: true,
input: "198435678",
},
{
name: "String too short",
expect: false,
input: "19845678",
},
{
name: "String too long",
expect: false,
input: "1985678654",
},
{
name: "Not digits in the string",
expect: false,
input: "1AC43567A",
},
}
for _, tc := range testCases {
fmt.Printf("Test: %v\n", tc.name)
res := isValidNIF(tc.input)
if res != tc.expect {
t.Errorf("Expected %t for input %s, got %t", tc.expect, tc.input, res)
}
}
}