From 5516d74ad2465ec98a09f80337a2ff9a78ba22c6 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Tue, 20 Apr 2021 11:11:16 +0900 Subject: [PATCH] [ruby/fiddle] test: add a test for win32_last_socket_error https://github.com/ruby/fiddle/commit/c86cec03cd --- test/fiddle/test_function.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/fiddle/test_function.rb b/test/fiddle/test_function.rb index 842221c91f..5d41477b9f 100644 --- a/test/fiddle/test_function.rb +++ b/test/fiddle/test_function.rb @@ -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