Archive the differentiated YuXinGu product docs, AI engineering system, design contract, and Go/Vue scaffold. Next execution prioritizes Cece-parity over early innovation (see .ai/product/STRATEGY.md). Co-authored-by: Cursor <cursoragent@cursor.com>
40 lines
789 B
Go
40 lines
789 B
Go
//go:build ignore
|
|
|
|
// EXAMPLE — table-driven unit test shape.
|
|
package examples
|
|
|
|
import "testing"
|
|
|
|
func TestClampBirthMonth(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
month int
|
|
wantErr bool
|
|
}{
|
|
{name: "ok", month: 6, wantErr: false},
|
|
{name: "zero", month: 0, wantErr: true},
|
|
{name: "thirteen", month: 13, wantErr: true},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
err := validateMonth(tt.month)
|
|
if (err != nil) != tt.wantErr {
|
|
t.Fatalf("validateMonth(%d) err=%v wantErr=%v", tt.month, err, tt.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func validateMonth(m int) error {
|
|
if m < 1 || m > 12 {
|
|
return errInvalid
|
|
}
|
|
return nil
|
|
}
|
|
|
|
var errInvalid = errString("invalid")
|
|
|
|
type errString string
|
|
|
|
func (e errString) Error() string { return string(e) }
|