tempname_test.go 672 B

1234567891011121314151617181920212223242526
  1. // Copyright (C) 2015 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at http://mozilla.org/MPL/2.0/.
  6. package model
  7. import (
  8. "strings"
  9. "testing"
  10. )
  11. func TestLongTempFilename(t *testing.T) {
  12. filename := ""
  13. for i := 0; i < 300; i++ {
  14. filename += "l"
  15. }
  16. tFile := defTempNamer.TempName(filename)
  17. if len(tFile) < 10 || len(tFile) > 200 {
  18. t.Fatal("Invalid long filename")
  19. }
  20. if !strings.HasSuffix(defTempNamer.TempName("short"), "short.tmp") {
  21. t.Fatal("Invalid short filename", defTempNamer.TempName("short"))
  22. }
  23. }