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.
5 // +build darwin dragonfly freebsd linux netbsd openbsd solaris
13 "golang.org/x/sys/unix"
16 func testSetGetenv(t *testing.T, key, value string) {
17 err := unix.Setenv(key, value)
19 t.Fatalf("Setenv failed to set %q: %v", value, err)
21 newvalue, found := unix.Getenv(key)
23 t.Fatalf("Getenv failed to find %v variable (want value %q)", key, value)
25 if newvalue != value {
26 t.Fatalf("Getenv(%v) = %q; want %q", key, newvalue, value)
30 func TestEnv(t *testing.T) {
31 testSetGetenv(t, "TESTENV", "AVALUE")
32 // make sure TESTENV gets set to "", not deleted
33 testSetGetenv(t, "TESTENV", "")
36 func TestItoa(t *testing.T) {
37 // Make most negative integer: 0x8000...
48 t.Fatalf("itoa(%d) = %s, want %s", i, s, f)