diff options
Diffstat (limited to 'setupapi/setupapi_windows_test.go')
-rw-r--r-- | setupapi/setupapi_windows_test.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/setupapi/setupapi_windows_test.go b/setupapi/setupapi_windows_test.go index 1d3c33d..e26032d 100644 --- a/setupapi/setupapi_windows_test.go +++ b/setupapi/setupapi_windows_test.go @@ -6,6 +6,7 @@ package setupapi import ( + "strings" "syscall" "testing" @@ -19,6 +20,24 @@ func init() { computerName, _ = windows.ComputerName() } +func TestSetupDiClassNameFromGuid(t *testing.T) { + className, err := SetupDiClassNameFromGuid(&deviceClassNetGUID) + if err != nil { + t.Errorf("Error calling SetupDiClassNameFromGuid: %s", err.Error()) + } else if strings.ToLower(className) != "net" { + t.Errorf("SetupDiClassNameFromGuid(%x) should return \"Net\"", deviceClassNetGUID) + } + + _, err = SetupDiClassNameFromGuid(nil) + if err == nil { + t.Errorf("SetupDiClassNameFromGuid(nil) should fail") + } else { + if errWin, ok := err.(syscall.Errno); !ok || errWin != 1784 /*ERROR_INVALID_USER_BUFFER*/ { + t.Errorf("SetupDiClassNameFromGuid(nil) should fail with ERROR_INVALID_USER_BUFFER") + } + } +} + func TestSetupDiGetClassDevsEx(t *testing.T) { devInfoList, err := SetupDiGetClassDevsEx(&deviceClassNetGUID, "PCI", 0, DIGCF_PRESENT, DevInfo(0), computerName) if err == nil { |