Files
volumen/internal/fediverse/fediverse_test.go
T

22 lines
613 B
Go
Raw Normal View History

2026-09-18 12:03:35 +02:00
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
package fediverse
import "testing"
func TestValid(t *testing.T) {
good := []string{"@user@host.social", "@a@b", "@petr@social.example.org"}
for _, handle := range good {
if !Valid(handle) {
t.Errorf("Valid(%q) = false, want true", handle)
}
}
bad := []string{"", "user@host", "@user", "@@host", "@user@", "@user @host", "@user@ho st", "u@h"}
for _, handle := range bad {
if Valid(handle) {
t.Errorf("Valid(%q) = true, want false", handle)
}
}
}