mirror of
https://github.com/syncthing/syncthing.git
synced 2024-11-17 02:48:57 -07:00
26 lines
478 B
Go
26 lines
478 B
Go
|
package luhn_test
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/calmh/syncthing/luhn"
|
||
|
)
|
||
|
|
||
|
func TestGenerate(t *testing.T) {
|
||
|
a := luhn.Alphabet("abcdef")
|
||
|
c := a.Generate("abcdef")
|
||
|
if c != 'e' {
|
||
|
t.Errorf("Incorrect check digit %c != e", c)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func TestValidate(t *testing.T) {
|
||
|
a := luhn.Alphabet("abcdef")
|
||
|
if !a.Validate("abcdefe") {
|
||
|
t.Errorf("Incorrect validation response for abcdefe")
|
||
|
}
|
||
|
if a.Validate("abcdefd") {
|
||
|
t.Errorf("Incorrect validation response for abcdefd")
|
||
|
}
|
||
|
}
|