github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/kbfs/data/util_test.go (about) 1 // Copyright 2016 Keybase Inc. All rights reserved. 2 // Use of this source code is governed by a BSD 3 // license that can be found in the LICENSE file. 4 5 package data 6 7 import ( 8 "testing" 9 ) 10 11 func testSplitExtension(t *testing.T, s, base, ext string) { 12 // t.Logf("splitExtension(%q)", s) 13 a, b := SplitFileExtension(s) 14 if a != base || b != ext { 15 t.Errorf("splitExtension(%q) => %q,%q, expected %q,%q", s, a, b, base, ext) 16 } 17 } 18 19 func TestSplitExtension(t *testing.T) { 20 testSplitExtension(t, "foo", "foo", "") 21 testSplitExtension(t, "foo.txt", "foo", ".txt") 22 testSplitExtension(t, "foo.tar.gz", "foo", ".tar.gz") 23 testSplitExtension(t, "f.txt", "f", ".txt") 24 testSplitExtension(t, ".txt", ".txt", "") 25 testSplitExtension(t, ".tar.gz", ".tar.gz", "") 26 testSplitExtension(t, "x/y.txt", "x/y", ".txt") 27 testSplitExtension(t, "x/y", "x/y", "") 28 testSplitExtension(t, "x/", "x/", "") 29 testSplitExtension(t, "/.foo", "/.foo", "") 30 testSplitExtension(t, "weird. is this?", "weird. is this?", "") 31 testSplitExtension(t, "", "", "") 32 }