checker/same_test.go
Onur Cinar 04635fcca1
Copyright message is added to all source files. (#123)
# Describe Request

Copyright message is added to all source files.

# Change Type

Code maintenance.
2024-10-29 19:43:20 -07:00

62 lines
986 B
Go

// Copyright (c) 2023-2024 Onur Cinar.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// https://github.com/cinar/checker
package checker_test
import (
"testing"
"github.com/cinar/checker"
)
func TestSameValid(t *testing.T) {
type User struct {
Password string
Confirm string `checkers:"same:Password"`
}
user := &User{
Password: "1234",
Confirm: "1234",
}
_, valid := checker.Check(user)
if !valid {
t.Fail()
}
}
func TestSameInvalid(t *testing.T) {
type User struct {
Password string
Confirm string `checkers:"same:Password"`
}
user := &User{
Password: "1234",
Confirm: "12",
}
_, valid := checker.Check(user)
if valid {
t.Fail()
}
}
func TestSameInvalidName(t *testing.T) {
defer checker.FailIfNoPanic(t)
type User struct {
Password string
Confirm string `checkers:"same:Unknown"`
}
user := &User{
Password: "1234",
Confirm: "1234",
}
checker.Check(user)
}