common_test.go 602 B

1234567891011121314151617181920212223242526
  1. // Copyright 2011 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.
  4. package ssh
  5. import (
  6. "testing"
  7. )
  8. func TestSafeString(t *testing.T) {
  9. strings := map[string]string{
  10. "\x20\x0d\x0a": "\x20\x0d\x0a",
  11. "flibble": "flibble",
  12. "new\x20line": "new\x20line",
  13. "123456\x07789": "123456 789",
  14. "\t\t\x10\r\n": "\t\t \r\n",
  15. }
  16. for s, expected := range strings {
  17. actual := safeString(s)
  18. if expected != actual {
  19. t.Errorf("expected: %v, actual: %v", []byte(expected), []byte(actual))
  20. }
  21. }
  22. }