1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/fiddle] test: add a test for win32_last_socket_error

https://github.com/ruby/fiddle/commit/c86cec03cd
This commit is contained in:
Sutou Kouhei 2021-04-20 11:11:16 +09:00 committed by Nobuyoshi Nakada
parent 303ab5da8b
commit 5516d74ad2
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6

View file

@ -9,7 +9,10 @@ module Fiddle
def setup
super
Fiddle.last_error = nil
Fiddle.win32_last_error = nil if WINDOWS
if WINDOWS
Fiddle.win32_last_error = nil
Fiddle.win32_last_socket_error = nil
end
end
def test_default_abi
@ -106,6 +109,17 @@ module Fiddle
set_last_error.call(n)
assert_equal(n, Fiddle.win32_last_error)
end
def test_win32_last_socket_error
ws2_32 = Fiddle.dlopen("ws2_32")
args = [ws2_32["WSASetLastError"], [TYPE_INT], TYPE_VOID]
args << Function::STDCALL if Function.const_defined?(:STDCALL)
wsa_set_last_error = Function.new(*args)
assert_nil(Fiddle.win32_last_socket_error)
n = 1 << 29 | 1
wsa_set_last_error.call(n)
assert_equal(n, Fiddle.win32_last_socket_error)
end
end
def test_strcpy