1 // Copyright 2010 The Go 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.
14 func TestTempFile(t
*testing
.T
) {
15 f
, err
:= TempFile("/_not_exists_", "foo")
16 if f
!= nil || err
== nil {
17 t
.Errorf("TempFile(`/_not_exists_`, `foo`) = %v, %v", f
, err
)
21 f
, err
= TempFile(dir
, "ioutil_test")
22 if f
== nil || err
!= nil {
23 t
.Errorf("TempFile(dir, `ioutil_test`) = %v, %v", f
, err
)
26 re
:= regexp
.MustCompile("^" + regexp
.QuoteMeta(dir
) + "/ioutil_test[0-9]+$")
27 if !re
.MatchString(f
.Name()) {
28 t
.Errorf("TempFile(`"+dir
+"`, `ioutil_test`) created bad name %s", f
.Name())