mirror of
https://github.com/golang/sys.git
synced 2026-02-08 03:36:03 +03:00
This test imports the "slices" package, which did not exist in Go 1.20. The test passes on Go 1.21 and above, and the behavior of the function under test is unlikely to vary by platform, so it doesn't seem worth refactoring the test to work with older releases. Updates golang/go#65055. Fixes golang/go#65223. Change-Id: I5f32106d6057b779579a87750633bc57f97fe152 Cq-Include-Trybots: luci.golang.try:x_sys-go1.20-windows-386,x_sys-go1.20-windows-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/sys/+/557975 Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
// 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.
|
|
|
|
//go:build go1.21
|
|
|
|
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)
|
|
}
|
|
}
|