Debian Codegraph @

all_test.go

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 // Copyright (c) 2014 The fileutil Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package fileutil // import "modernc.org/fileutil"
6
7 import (
8 "os"
9 "path/filepath"
10 "strings"
11 "testing"
12 )
13
14 func TestTempFile(t *testing.T) {
15 f, err := TempFile("", "abc", "mno.xyz")
16 if err != nil {
17 t.Fatal(err)
18 }
19
20 n := f.Name()
21 t.Log(n)
22 defer func() {
23 f.Close()
24 os.Remove(n)
25 }()
26
27 base := filepath.Base(n)
28 if base == "abcmno.xyz" {
29 t.Fatal(base)
30 }
31
32 if !strings.HasPrefix(base, "abc") {
33 t.Fatal(base)
34 }
35
36 if !strings.HasSuffix(base, "mno.xyz") {
37 t.Fatal(base)
38 }
39 }