git.sr.ht/~pingoo/stdx@v0.0.0-20240218134121-094174641f6e/otc/otc_test.go (about) 1 package otc_test 2 3 import ( 4 "testing" 5 6 "git.sr.ht/~pingoo/stdx/otc" 7 ) 8 9 func TestNewAndVerify(t *testing.T) { 10 length := 8 11 12 for i := 0; i < 5; i += 1 { 13 code, err := otc.New(uint16(length)) 14 if err != nil { 15 t.Error(err) 16 return 17 } 18 codeText := code.Code() 19 token := code.Token() 20 if !otc.Verify(codeText, token) { 21 t.Errorf("code is not valid: code (%s) | token (%s)", codeText, token) 22 return 23 } 24 } 25 }