aboutsummaryrefslogtreecommitdiff
path: root/windows/env_windows_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'windows/env_windows_test.go')
-rw-r--r--windows/env_windows_test.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/windows/env_windows_test.go b/windows/env_windows_test.go
new file mode 100644
index 0000000..6824e6e
--- /dev/null
+++ b/windows/env_windows_test.go
@@ -0,0 +1,40 @@
+// Copyright 2024 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package windows_test
+
+import (
+ "fmt"
+ "slices"
+ "testing"
+
+ "golang.org/x/sys/windows"
+)
+
+func TestEnvironUTF8(t *testing.T) {
+ testEnvVariable1Key := "__GO_X_SYS_WINDOWS_ENV_WINDOWS_TEST_VAR_BEAVER"
+ testEnvVariable1Val := "🦫"
+ t.Setenv(testEnvVariable1Key, testEnvVariable1Val)
+
+ testEnvVariable2Key := "__GO_X_SYS_WINDOWS_ENV_WINDOWS_TEST_VAR_WHALE"
+ testEnvVariable2Val := "🐳"
+ t.Setenv(testEnvVariable2Key, testEnvVariable2Val)
+
+ var userToken windows.Token
+
+ env, err := userToken.Environ(true)
+ if err != nil {
+ t.Error(err)
+ }
+
+ testEnvVariable1 := fmt.Sprintf("%s=%s", testEnvVariable1Key, testEnvVariable1Val)
+ if !slices.Contains(env, testEnvVariable1) {
+ t.Fatalf("expected to find %s in env", testEnvVariable1)
+ }
+
+ testEnvVariable2 := fmt.Sprintf("%s=%s", testEnvVariable2Key, testEnvVariable2Val)
+ if !slices.Contains(env, testEnvVariable2) {
+ t.Fatalf("expected to find %s in env", testEnvVariable2)
+ }
+}