longest-common_test.go 417 B

12345678910111213141516171819202122
  1. // License: GPLv3 Copyright: 2022, Kovid Goyal, <kovid at kovidgoyal.net>
  2. package utils
  3. import (
  4. "fmt"
  5. "testing"
  6. )
  7. var _ = fmt.Print
  8. func TestLongestCommon(t *testing.T) {
  9. p := func(expected string, items ...string) {
  10. actual := Prefix(items)
  11. if actual != expected {
  12. t.Fatalf("Failed with %#v\nExpected: %#v\nActual: %#v", items, expected, actual)
  13. }
  14. }
  15. p("abc", "abc", "abcd")
  16. p("", "abc", "xy")
  17. }