chore: merge backend repo history into monorepo at backend/
git-subtree-dir: backend git-subtree-mainline:dc11190527git-subtree-split:acae976622
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestCalcAge_NilBirthDate(t *testing.T) {
|
||||
if age := CalcAge(nil); age != 0 {
|
||||
t.Fatalf("expected 0 for nil birth date, got %d", age)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCalcAge_BirthdayAlreadyPassedThisYear(t *testing.T) {
|
||||
birth := time.Now().AddDate(-25, -1, 0) // ۲۵ سال و ۱ ماه پیش -> تولد امسال رد شده
|
||||
if age := CalcAge(&birth); age != 25 {
|
||||
t.Fatalf("expected age 25, got %d", age)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCalcAge_BirthdayNotYetThisYear(t *testing.T) {
|
||||
birth := time.Now().AddDate(-25, 1, 0) // تولد ۱ ماه دیگهست -> هنوز ۲۴ سالشه
|
||||
if age := CalcAge(&birth); age != 24 {
|
||||
t.Fatalf("expected age 24, got %d", age)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user