23 lines
712 B
Go
23 lines
712 B
Go
package main
|
|
|
|
import "testing"
|
|
|
|
func TestSplitRefEntry(t *testing.T) {
|
|
code, ref, ok := splitRefEntry("rda@st-25")
|
|
if !ok || code != "RDA" || ref != "ST-25" {
|
|
t.Fatalf("got %q %q %v", code, ref, ok)
|
|
}
|
|
// The picker writes what the operator typed, spacing included.
|
|
if _, ref, _ = splitRefEntry("POTA@ fr-1234 "); ref != "FR-1234" {
|
|
t.Fatalf("not trimmed: %q", ref)
|
|
}
|
|
// A reference can contain the separator characters of a label; only the
|
|
// FIRST @ splits, so "IOTA@EU-064" survives and a stray one does not create
|
|
// an award out of nothing.
|
|
for _, bad := range []string{"", "RDA", "@ST-25", "RDA@", "RDA@ "} {
|
|
if _, _, ok := splitRefEntry(bad); ok {
|
|
t.Fatalf("%q accepted", bad)
|
|
}
|
|
}
|
|
}
|