env_unix_test.go 652 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2013 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. // +build darwin dragonfly freebsd linux netbsd openbsd solaris
  5. package os_test
  6. import (
  7. . "os"
  8. "testing"
  9. )
  10. var setenvEinvalTests = []struct {
  11. k, v string
  12. }{
  13. {"", ""}, // empty key
  14. {"k=v", ""}, // '=' in key
  15. {"\x00", ""}, // '\x00' in key
  16. {"k", "\x00"}, // '\x00' in value
  17. }
  18. func TestSetenvUnixEinval(t *testing.T) {
  19. for _, tt := range setenvEinvalTests {
  20. err := Setenv(tt.k, tt.v)
  21. if err == nil {
  22. t.Errorf(`Setenv(%q, %q) == nil, want error`, tt.k, tt.v)
  23. }
  24. }
  25. }