diff options
Diffstat (limited to 'libgo/go/path/path_test.go')
-rw-r--r-- | libgo/go/path/path_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libgo/go/path/path_test.go b/libgo/go/path/path_test.go index 65be5506042..69096494e2a 100644 --- a/libgo/go/path/path_test.go +++ b/libgo/go/path/path_test.go @@ -5,6 +5,7 @@ package path import ( + "runtime" "testing" ) @@ -67,7 +68,27 @@ func TestClean(t *testing.T) { if s := Clean(test.path); s != test.result { t.Errorf("Clean(%q) = %q, want %q", test.path, s, test.result) } + if s := Clean(test.result); s != test.result { + t.Errorf("Clean(%q) = %q, want %q", test.result, s, test.result) + } + } + + var ms runtime.MemStats + runtime.ReadMemStats(&ms) + allocs := -ms.Mallocs + const rounds = 100 + for i := 0; i < rounds; i++ { + for _, test := range cleantests { + Clean(test.result) + } + } + runtime.ReadMemStats(&ms) + allocs += ms.Mallocs + /* Fails with gccgo, which has no escape analysis. + if allocs >= rounds { + t.Errorf("Clean cleaned paths: %d allocations per test round, want zero", allocs/rounds) } + */ } type SplitTest struct { |