.gitignore added
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / sys@v0.0.0-20210124154548-22da62e12c0c / unix / syscall_test.go
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
5 // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
6
7 package unix_test
8
9 import (
10         "fmt"
11         "testing"
12
13         "golang.org/x/sys/unix"
14 )
15
16 func testSetGetenv(t *testing.T, key, value string) {
17         err := unix.Setenv(key, value)
18         if err != nil {
19                 t.Fatalf("Setenv failed to set %q: %v", value, err)
20         }
21         newvalue, found := unix.Getenv(key)
22         if !found {
23                 t.Fatalf("Getenv failed to find %v variable (want value %q)", key, value)
24         }
25         if newvalue != value {
26                 t.Fatalf("Getenv(%v) = %q; want %q", key, newvalue, value)
27         }
28 }
29
30 func TestEnv(t *testing.T) {
31         testSetGetenv(t, "TESTENV", "AVALUE")
32         // make sure TESTENV gets set to "", not deleted
33         testSetGetenv(t, "TESTENV", "")
34 }
35
36 func TestItoa(t *testing.T) {
37         // Make most negative integer: 0x8000...
38         i := 1
39         for i<<1 != 0 {
40                 i <<= 1
41         }
42         if i >= 0 {
43                 t.Fatal("bad math")
44         }
45         s := unix.Itoa(i)
46         f := fmt.Sprint(i)
47         if s != f {
48                 t.Fatalf("itoa(%d) = %s, want %s", i, s, f)
49         }
50 }
51
52 func TestUname(t *testing.T) {
53         var utsname unix.Utsname
54         err := unix.Uname(&utsname)
55         if err != nil {
56                 t.Fatalf("Uname: %v", err)
57         }
58
59         t.Logf("OS: %s/%s %s", utsname.Sysname[:], utsname.Machine[:], utsname.Release[:])
60 }
61
62 // Test that this compiles. (Issue #31735)
63 func TestStatFieldNames(t *testing.T) {
64         var st unix.Stat_t
65         var _ *unix.Timespec
66         _ = &st.Atim
67         _ = &st.Mtim
68         _ = &st.Ctim
69         _ = int64(st.Mtim.Sec)
70         _ = int64(st.Mtim.Nsec)
71 }