diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-03-03 06:03:23 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-03-03 06:03:23 +0000 |
commit | f9ca2119e403653cdf529646d3a3790c5c473ac2 (patch) | |
tree | bc0355516dd1ea4e6d90f100726c337502b05dce /test/dl/test_win32.rb | |
parent | 078928bbdd66586ee18fce8fa4485ac31d960df3 (diff) | |
download | ruby-f9ca2119e403653cdf529646d3a3790c5c473ac2.tar.gz |
* test/dl: moved from ext/dl/test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22717 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/dl/test_win32.rb')
-rw-r--r-- | test/dl/test_win32.rb | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/dl/test_win32.rb b/test/dl/test_win32.rb new file mode 100644 index 0000000000..b40e3690d8 --- /dev/null +++ b/test/dl/test_win32.rb @@ -0,0 +1,54 @@ +require 'test_base' +require 'dl/import' +require 'dl/types' + +module Win32API + extend DL::Importer + + dlload "kernel32.dll" + + include DL::Win32Types + + OSVERSIONINFO = struct [ + "DWORD dwOSVersionInfoSize", + "DWORD dwMajorVersion", + "DWORD dwMinorVersion", + "DWORD dwBuildNumber", + "DWORD dwPlatformId", + "UCHAR szCSDVersion[128]", + ] + + typealias "POSVERSIONINFO", "OSVERSIONINFO*" + + extern "BOOL GetVersionEx(POSVERSIONINFO)", :stdcall + + def get_version_ex() + ptr = OSVERSIONINFO.malloc() + ptr.dwOSVersionInfoSize = OSVERSIONINFO.size + ret = GetVersionEx(ptr) + if( ret ) + ptr + else + nil + end + end + module_function :get_version_ex +rescue DL::DLError +end + +module DL +class TestWin32 < TestBase + def test_version() + platform = Win32API.get_version_ex().dwPlatformId + case ENV['OS'] + when 'Windows_NT' + expect = 2 + when /Windows.+/ + expect = 1 + else + expect = 0 + end + assert_equal(expect, platform) + end +end +end if defined?(Win32API::OSVERSIONINFO) |