Debian Codegraph @

windows/env_windows_test.go

raw
1 // Copyright 2024 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 //go:build go1.21
6
7 package windows_test
8
9 import (
10 "fmt"
11 "slices"
12 "testing"
13
14 "golang.org/x/sys/windows"
15 )
16
17 func TestEnvironUTF8(t *testing.T) {
18 testEnvVariable1Key := "__GO_X_SYS_WINDOWS_ENV_WINDOWS_TEST_VAR_BEAVER"
19 testEnvVariable1Val := "🦫"
20 t.Setenv(testEnvVariable1Key, testEnvVariable1Val)
21
22 testEnvVariable2Key := "__GO_X_SYS_WINDOWS_ENV_WINDOWS_TEST_VAR_WHALE"
23 testEnvVariable2Val := "🐳"
24 t.Setenv(testEnvVariable2Key, testEnvVariable2Val)
25
26 var userToken windows.Token
27
28 env, err := userToken.Environ(true)
29 if err != nil {
30 t.Error(err)
31 }
32
33 testEnvVariable1 := fmt.Sprintf("%s=%s", testEnvVariable1Key, testEnvVariable1Val)
34 if !slices.Contains(env, testEnvVariable1) {
35 t.Fatalf("expected to find %s in env", testEnvVariable1)
36 }
37
38 testEnvVariable2 := fmt.Sprintf("%s=%s", testEnvVariable2Key, testEnvVariable2Val)
39 if !slices.Contains(env, testEnvVariable2) {
40 t.Fatalf("expected to find %s in env", testEnvVariable2)
41 }
42 }