aboutsummaryrefslogtreecommitdiffstats
path: root/setupapi/setupapi_windows_test.go
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2019-02-06 20:15:40 +0100
committerSimon Rozman <simon@rozman.si>2019-02-06 20:15:40 +0100
commit3c29434a79f5af9ce668f699105778f36417a5d6 (patch)
tree2191a640c92e7c3e4b633c72b8e44355f1eca582 /setupapi/setupapi_windows_test.go
parentFix up errors and paths (diff)
downloadwireguard-go-3c29434a79f5af9ce668f699105778f36417a5d6.tar.xz
wireguard-go-3c29434a79f5af9ce668f699105778f36417a5d6.zip
setupapi: Make toUTF16() public and add UTF16ToBuf() counterpart
Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to '')
-rw-r--r--setupapi/setupapi_windows_test.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/setupapi/setupapi_windows_test.go b/setupapi/setupapi_windows_test.go
index 12b5fe1..3d9abd6 100644
--- a/setupapi/setupapi_windows_test.go
+++ b/setupapi/setupapi_windows_test.go
@@ -403,3 +403,16 @@ func TestSetupDiGetSelectedDevice(t *testing.T) {
}
}
}
+
+func TestUTF16ToBuf(t *testing.T) {
+ buf := []uint16{0x0123, 0x4567, 0x89ab, 0xcdef}
+ buf2 := UTF16ToBuf(buf)
+ if len(buf)*2 != len(buf2) ||
+ cap(buf)*2 != cap(buf2) ||
+ buf2[0] != 0x23 || buf2[1] != 0x01 ||
+ buf2[2] != 0x67 || buf2[3] != 0x45 ||
+ buf2[4] != 0xab || buf2[5] != 0x89 ||
+ buf2[6] != 0xef || buf2[7] != 0xcd {
+ t.Errorf("SetupDiSetSelectedDevice(nil) should fail with ERROR_INVALID_USER_BUFFER")
+ }
+}