windows-pr 1.0.8 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +9 -0
- data/README +114 -118
- data/Rakefile +65 -50
- data/lib/windows/com/accessibility.rb +13 -13
- data/lib/windows/limits.rb +26 -18
- data/lib/windows/msvcrt/string.rb +159 -159
- data/lib/windows/service.rb +1 -0
- data/lib/windows/unicode.rb +153 -142
- data/test/tc_handle.rb +1 -1
- data/test/tc_mailslot.rb +2 -2
- data/test/tc_msvcrt_string.rb +69 -68
- data/test/tc_network_management.rb +1 -1
- data/test/tc_unicode.rb +83 -82
- data/windows-pr.gemspec +27 -29
- metadata +3 -3
data/test/tc_handle.rb
CHANGED
@@ -17,7 +17,7 @@ class TC_Windows_Handle < Test::Unit::TestCase
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_numeric_constants
|
20
|
-
assert_equal(
|
20
|
+
assert_equal(0xFFFFFFFF, HandleFoo::INVALID_HANDLE_VALUE)
|
21
21
|
assert_equal(0x00000001, HandleFoo::HANDLE_FLAG_INHERIT)
|
22
22
|
assert_equal(0x00000002, HandleFoo::HANDLE_FLAG_PROTECT_FROM_CLOSE)
|
23
23
|
end
|
data/test/tc_mailslot.rb
CHANGED
@@ -10,8 +10,8 @@ class TC_Windows_Mailslot < Test::Unit::TestCase
|
|
10
10
|
include Windows::Mailslot
|
11
11
|
|
12
12
|
def test_constants
|
13
|
-
assert_equal(
|
14
|
-
assert_equal(
|
13
|
+
assert_equal(0xFFFFFFFF, MAILSLOT_WAIT_FOREVER)
|
14
|
+
assert_equal(0xFFFFFFFF, MAILSLOT_NO_MESSAGE)
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_methods
|
data/test/tc_msvcrt_string.rb
CHANGED
@@ -7,86 +7,87 @@ require 'windows/msvcrt/string'
|
|
7
7
|
require 'test/unit'
|
8
8
|
|
9
9
|
class TC_Windows_MSVCRT_String < Test::Unit::TestCase
|
10
|
-
|
10
|
+
include Windows::MSVCRT::String
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
def setup
|
13
|
+
@buf = 0.chr * 260
|
14
|
+
@str = 'hello'
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
17
|
+
def test_method_constants
|
18
|
+
assert_not_nil(Strcmp)
|
19
|
+
assert_not_nil(Strcpy)
|
20
|
+
assert_not_nil(Strcspn)
|
21
|
+
assert_not_nil(Strlen)
|
22
|
+
assert_not_nil(Strncpy)
|
23
|
+
assert_not_nil(Strrchr)
|
24
|
+
assert_not_nil(Strrev)
|
25
|
+
assert_not_nil(Strtok)
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
def test_strchr
|
29
|
+
assert_respond_to(self, :strchr)
|
30
|
+
assert_equal('llo', strchr('hello', 108))
|
31
|
+
assert_equal(nil, strchr('hello', 120))
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
def test_strchr_with_zero
|
35
|
+
assert_nil(strchr(0, 'l'[0]))
|
36
|
+
assert_nil(strchr('hello', 0))
|
37
|
+
end
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
def test_strchr_expected_errors
|
40
|
+
assert_raise(ArgumentError){ strchr }
|
41
|
+
assert_raise(ArgumentError){ strchr('hello') }
|
42
|
+
end
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
def test_strcmp
|
45
|
+
assert_respond_to(self, :strcmp)
|
46
|
+
assert_equal(-1, strcmp('alpha', 'beta'))
|
47
|
+
assert_equal(1, strcmp('beta', 'alpha'))
|
48
|
+
assert_equal(0, strcmp('alpha', 'alpha'))
|
49
|
+
end
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
def test_strcmp_expected_errors
|
52
|
+
assert_raise(ArgumentError){ strcmp }
|
53
|
+
assert_raise(ArgumentError){ strcmp('alpha') }
|
54
|
+
end
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
def test_strcpy
|
57
|
+
assert_respond_to(self, :strcpy)
|
58
|
+
assert_kind_of(Fixnum, strcpy(@buf, ['hello'].pack('p*').unpack('L')[0]))
|
59
|
+
assert_equal('hello', @buf.strip)
|
60
|
+
end
|
60
61
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
def test_strcspn
|
63
|
+
assert_respond_to(self, :strcspn)
|
64
|
+
assert_equal(3, strcspn('abcxyz123', '&^(x'))
|
65
|
+
assert_equal(9, strcspn('abcxyz123', '&^(('))
|
66
|
+
end
|
66
67
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
68
|
+
def test_strcspn_expected_errors
|
69
|
+
assert_raise(ArgumentError){ strcspn }
|
70
|
+
assert_raise(ArgumentError){ strcspn('alpha') }
|
71
|
+
end
|
71
72
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
73
|
+
def test_strlen
|
74
|
+
assert_respond_to(self, :strlen)
|
75
|
+
assert_equal(5, strlen('hello'))
|
76
|
+
assert_equal(0, strlen(''))
|
77
|
+
end
|
77
78
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
79
|
+
def test_strlen_expected_errors
|
80
|
+
assert_raise(ArgumentError){ strlen }
|
81
|
+
assert_raise(ArgumentError){ strlen('a', 'b') }
|
82
|
+
end
|
82
83
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
84
|
+
def test_strncpy
|
85
|
+
assert_respond_to(self, :strncpy)
|
86
|
+
assert_equal('alp', strncpy(@buf, 'alpha', 3))
|
87
|
+
assert_equal('alp', @buf.strip)
|
88
|
+
end
|
88
89
|
|
89
|
-
|
90
|
-
|
91
|
-
|
90
|
+
def teardown
|
91
|
+
@buf = nil
|
92
|
+
end
|
92
93
|
end
|
@@ -17,7 +17,7 @@ class TC_Windows_Network_Management < Test::Unit::TestCase
|
|
17
17
|
|
18
18
|
def test_numeric_constants
|
19
19
|
assert_equal(0, NetworkManagementFoo::NERR_Success)
|
20
|
-
assert_equal(
|
20
|
+
assert_equal(0xFFFFFFFF, NetworkManagementFoo::MAX_PREFERRED_LENGTH)
|
21
21
|
assert_equal(0x00000001, NetworkManagementFoo::SV_TYPE_WORKSTATION)
|
22
22
|
end
|
23
23
|
|
data/test/tc_unicode.rb
CHANGED
@@ -1,82 +1,83 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
require "
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
assert_equal(
|
15
|
-
assert_equal(
|
16
|
-
assert_equal(
|
17
|
-
assert_equal(
|
18
|
-
assert_equal(
|
19
|
-
assert_equal(
|
20
|
-
|
21
|
-
|
22
|
-
assert_equal(
|
23
|
-
assert_equal(
|
24
|
-
assert_equal(
|
25
|
-
|
26
|
-
|
27
|
-
assert_equal(
|
28
|
-
assert_equal(
|
29
|
-
assert_equal(
|
30
|
-
assert_equal(
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
assert_respond_to(self, :
|
36
|
-
assert_respond_to(self, :
|
37
|
-
assert_respond_to(self, :
|
38
|
-
assert_respond_to(self, :
|
39
|
-
assert_respond_to(self, :
|
40
|
-
assert_respond_to(self, :
|
41
|
-
assert_respond_to(self, :
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
assert_equal("
|
48
|
-
assert_equal("\
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
assert_equal("\
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
assert_raise(TypeError){ multi_to_wide(
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
assert_equal('
|
65
|
-
assert_equal(
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
assert_equal(
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
assert_raise(TypeError){ wide_to_multi(
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
@
|
81
|
-
|
82
|
-
end
|
1
|
+
# encoding: ascii-8bit
|
2
|
+
#####################################################################
|
3
|
+
# tc_unicode.rb
|
4
|
+
#
|
5
|
+
# Test case for the Windows::Unicode module.
|
6
|
+
#####################################################################
|
7
|
+
require "windows/unicode"
|
8
|
+
require "test/unit"
|
9
|
+
|
10
|
+
class TC_Windows_Unicode < Test::Unit::TestCase
|
11
|
+
include Windows::Unicode
|
12
|
+
|
13
|
+
def test_numeric_constants
|
14
|
+
assert_equal(0, CP_ACP)
|
15
|
+
assert_equal(1, CP_OEMCP)
|
16
|
+
assert_equal(2, CP_MACCP)
|
17
|
+
assert_equal(3, CP_THREAD_ACP)
|
18
|
+
assert_equal(42, CP_SYMBOL)
|
19
|
+
assert_equal(65000, CP_UTF7)
|
20
|
+
assert_equal(65001, CP_UTF8)
|
21
|
+
|
22
|
+
assert_equal(0x00000001, MB_PRECOMPOSED)
|
23
|
+
assert_equal(0x00000002, MB_COMPOSITE)
|
24
|
+
assert_equal(0x00000004, MB_USEGLYPHCHARS)
|
25
|
+
assert_equal(0x00000008, MB_ERR_INVALID_CHARS)
|
26
|
+
|
27
|
+
assert_equal(0x00000200, WC_COMPOSITECHECK)
|
28
|
+
assert_equal(0x00000010, WC_DISCARDNS)
|
29
|
+
assert_equal(0x00000020, WC_SEPCHARS)
|
30
|
+
assert_equal(0x00000040, WC_DEFAULTCHAR)
|
31
|
+
assert_equal(0x00000400, WC_NO_BEST_FIT_CHARS)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_method_constants
|
35
|
+
assert_respond_to(self, :GetTextCharset)
|
36
|
+
assert_respond_to(self, :GetTextCharsetInfo)
|
37
|
+
assert_respond_to(self, :IsDBCSLeadByte)
|
38
|
+
assert_respond_to(self, :IsDBCSLeadByteEx)
|
39
|
+
assert_respond_to(self, :IsTextUnicode)
|
40
|
+
assert_respond_to(self, :MultiByteToWideChar)
|
41
|
+
assert_respond_to(self, :TranslateCharsetInfo)
|
42
|
+
assert_respond_to(self, :WideCharToMultiByte)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_multi_to_wide
|
46
|
+
assert_respond_to(self, :multi_to_wide)
|
47
|
+
assert_equal("\000\000", multi_to_wide(''))
|
48
|
+
assert_equal("h\000e\000l\000l\000o\000\000\000", multi_to_wide('hello'))
|
49
|
+
assert_equal("\316\000\" \316\000\273\000\316\000\273\000\316\000\254\000\317\000\222\001\000\000", multi_to_wide("Ελλάσ"))
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_multi_to_wide_with_encoding
|
53
|
+
assert_equal("h\000e\000l\000l\000o\000\000\000", multi_to_wide('hello', CP_UTF8))
|
54
|
+
assert_equal("\225\003\273\003\273\003\254\003\303\003\000\000", multi_to_wide("Ελλάσ", CP_UTF8))
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_multi_to_wide_expected_errors
|
58
|
+
assert_raise(TypeError){ multi_to_wide(1) }
|
59
|
+
assert_raise(TypeError){ multi_to_wide([]) }
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_wide_to_multi
|
63
|
+
assert_respond_to(self, :wide_to_multi)
|
64
|
+
assert_equal('', wide_to_multi("\000\000"))
|
65
|
+
assert_equal('hello', wide_to_multi("h\000e\000l\000l\000o\000\000\000"))
|
66
|
+
assert_equal("Ελλάσ", wide_to_multi("\316\000\" \316\000\273\000\316\000\273\000\316\000\254\000\317\000\222\001\000\000"))
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_wide_to_multi_with_encoding
|
70
|
+
assert_equal('hello', wide_to_multi("h\000e\000l\000l\000o\000\000\000"), CP_UTF8)
|
71
|
+
assert_equal("Ελλάσ", wide_to_multi("\225\003\273\003\273\003\254\003\303\003\000\000", CP_UTF8))
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_wide_to_multi_expected_errors
|
75
|
+
assert_raise(TypeError){ wide_to_multi(1) }
|
76
|
+
assert_raise(TypeError){ wide_to_multi([]) }
|
77
|
+
end
|
78
|
+
|
79
|
+
def teardown
|
80
|
+
@foo = nil
|
81
|
+
@unicode = nil
|
82
|
+
end
|
83
|
+
end
|
data/windows-pr.gemspec
CHANGED
@@ -1,36 +1,34 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'windows-pr'
|
5
|
+
spec.version = '1.0.9'
|
6
|
+
spec.license = 'Artistic 2.0'
|
7
|
+
spec.authors = ['Daniel J. Berger', 'Park Heesob']
|
8
|
+
spec.email = 'djberg96@gmail.com'
|
9
|
+
spec.homepage = 'http://www.rubyforge.org/projects/win32utils'
|
10
|
+
spec.platform = Gem::Platform::RUBY
|
11
|
+
spec.summary = 'Windows functions and constants bundled via Win32::API'
|
12
|
+
spec.test_files = Dir["test/tc*"]
|
13
|
+
spec.files = Dir["**/*"].reject{ |f| f.include?('git') }
|
14
14
|
|
15
|
-
|
15
|
+
spec.rubyforge_project = 'win32utils'
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
spec.extra_rdoc_files = [
|
18
|
+
'MANIFEST',
|
19
|
+
'README',
|
20
|
+
'CHANGES',
|
21
|
+
'doc/conversion_guide.txt'
|
22
|
+
]
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
spec.add_dependency('windows-api', '>= 0.3.0')
|
25
|
+
spec.add_dependency('win32-api', '>= 1.4.5')
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
spec.description = <<-EOF
|
28
|
+
The windows-pr library is a collection of Windows functions and constants
|
29
|
+
pre-defined for you using the windows-api library. It also autogenerates
|
30
|
+
explicit ANSI and Wide character versions of those functions, as well as
|
31
|
+
constants that can be used as methods, e.g. CloseHandle() instead of
|
32
|
+
CloseHandle.call().
|
33
|
+
EOF
|
34
34
|
end
|
35
|
-
|
36
|
-
Gem::Builder.new(spec).build
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: windows-pr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date:
|
13
|
+
date: 2010-02-06 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: 1.4.5
|
35
35
|
version:
|
36
|
-
description: "
|
36
|
+
description: " The windows-pr library is a collection of Windows functions and constants\n pre-defined for you using the windows-api library. It also autogenerates\n explicit ANSI and Wide character versions of those functions, as well as\n constants that can be used as methods, e.g. CloseHandle() instead of\n CloseHandle.call().\n"
|
37
37
|
email: djberg96@gmail.com
|
38
38
|
executables: []
|
39
39
|
|