[前][次][番号順一覧][スレッド一覧]

ruby-changes:66763

From: Sutou <ko1@a...>
Date: Tue, 13 Jul 2021 19:38:20 +0900 (JST)
Subject: [ruby-changes:66763] 5516d74ad2 (master): [ruby/fiddle] test: add a test for win32_last_socket_error

https://git.ruby-lang.org/ruby.git/commit/?id=5516d74ad2

From 5516d74ad2465ec98a09f80337a2ff9a78ba22c6 Mon Sep 17 00:00:00 2001
From: Sutou Kouhei <kou@c...>
Date: Tue, 20 Apr 2021 11:11:16 +0900
Subject: [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 842221c..5d41477 100644
--- a/test/fiddle/test_function.rb
+++ b/test/fiddle/test_function.rb
@@ -9,7 +9,10 @@ module Fiddle https://github.com/ruby/ruby/blob/trunk/test/fiddle/test_function.rb#L9
     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 https://github.com/ruby/ruby/blob/trunk/test/fiddle/test_function.rb#L109
         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
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]