win32-pipe 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,162 +1,162 @@
1
- ##########################################################################
2
- # test_win32_pipe.rb
3
- #
4
- # Test suite for the win32-pipe library. This test suite should be run
5
- # via the 'rake test' task.
6
- ##########################################################################
7
- require 'test-unit'
8
- require 'win32/pipe'
9
- include Win32
10
-
11
- class TC_Win32_Pipe < Test::Unit::TestCase
12
- def setup
13
- @pipe = Pipe.new('foo')
14
- end
15
-
16
- test "version is set to expected value" do
17
- assert_equal('0.3.6', Pipe::VERSION)
18
- end
19
-
20
- test "name method basic functionality" do
21
- assert_respond_to(@pipe, :name)
22
- assert_nothing_raised{ @pipe.name }
23
- assert_kind_of(String, @pipe.name)
24
- end
25
-
26
- test "name returns expected string" do
27
- assert_equal("\\\\.\\pipe\\foo", @pipe.name)
28
- end
29
-
30
- test "mode method basic functionality" do
31
- assert_respond_to(@pipe, :pipe_mode)
32
- assert_nothing_raised{ @pipe.pipe_mode }
33
- assert_kind_of(Fixnum, @pipe.pipe_mode)
34
- end
35
-
36
- test "mode method returns expected value" do
37
- assert_equal(Pipe::DEFAULT_PIPE_MODE, @pipe.pipe_mode)
38
- end
39
-
40
- test "open_mode basic functionality" do
41
- assert_respond_to(@pipe, :open_mode)
42
- assert_nothing_raised{ @pipe.open_mode }
43
- assert_kind_of(Numeric, @pipe.open_mode)
44
- end
45
-
46
- test "open_mode returns the expected value" do
47
- assert_equal(Pipe::DEFAULT_OPEN_MODE, @pipe.open_mode)
48
- end
49
-
50
- test "buffer method basic functionality" do
51
- assert_respond_to(@pipe, :buffer)
52
- assert_nothing_raised{ @pipe.buffer }
53
- end
54
-
55
- test "size basic functionality" do
56
- assert_respond_to(@pipe, :size)
57
- assert_nothing_raised{ @pipe.size }
58
- end
59
-
60
- test "length is an alias for size" do
61
- assert_respond_to(@pipe, :length)
62
- assert_alias_method(@pipe, :length, :size)
63
- end
64
-
65
- test "pending method basic functionality" do
66
- assert_respond_to(@pipe, :pending?)
67
- assert_nothing_raised{ @pipe.pending? }
68
- assert_boolean(@pipe.pending?)
69
- end
70
-
71
- test "pending method defaults to false" do
72
- assert_false(@pipe.pending?)
73
- end
74
-
75
- test "asynchronous method basic functionality" do
76
- assert_respond_to(@pipe, :asynchronous?)
77
- assert_nothing_raised{ @pipe.asynchronous? }
78
- assert_boolean(@pipe.asynchronous?)
79
- end
80
-
81
- test "asynchronous method defaults to false" do
82
- assert_false(@pipe.asynchronous?)
83
- end
84
-
85
- test "read method basic functionality" do
86
- assert_respond_to(@pipe, :read)
87
- end
88
-
89
- test "read method raises an error if there's nothing to read" do
90
- assert_raises(Pipe::Error){ @pipe.read }
91
- end
92
-
93
- test "transfered method basic functionality" do
94
- assert_respond_to(@pipe, :transferred)
95
- assert_nothing_raised{ @pipe.transferred }
96
- end
97
-
98
- test "wait method basic functionality" do
99
- assert_respond_to(@pipe, :wait)
100
- end
101
-
102
- test "wait method raises an error in blocking mode" do
103
- assert_raises(Pipe::Error){ @pipe.wait }
104
- end
105
-
106
- test "write method basic functionality" do
107
- assert_respond_to(@pipe, :write)
108
- end
109
-
110
- test "write method requires one argument" do
111
- assert_raises(ArgumentError){ @pipe.write }
112
- end
113
-
114
- test "write method raises an error if there's nothing to write to" do
115
- assert_raises(Pipe::Error){ @pipe.write("foo") }
116
- end
117
-
118
- test "disconnect method basic functionality" do
119
- assert_respond_to(@pipe, :disconnect)
120
- assert_nothing_raised{ @pipe.disconnect }
121
- end
122
-
123
- test "calling the disconnect method multiple times has no effect" do
124
- assert_nothing_raised{ @pipe.disconnect; @pipe.disconnect }
125
- end
126
-
127
- test "close method basic functionality" do
128
- assert_respond_to(@pipe, :close)
129
- assert_nothing_raised{ @pipe.close }
130
- end
131
-
132
- test "calling close multiple times has no effect" do
133
- assert_nothing_raised{ @pipe.close; @pipe.close }
134
- end
135
-
136
- test "pipe_mode constants" do
137
- assert_not_nil(Pipe::WAIT)
138
- assert_not_nil(Pipe::NOWAIT)
139
- assert_not_nil(Pipe::TYPE_BYTE)
140
- assert_not_nil(Pipe::TYPE_MESSAGE)
141
- assert_not_nil(Pipe::READMODE_BYTE)
142
- assert_not_nil(Pipe::READMODE_MESSAGE)
143
- end
144
-
145
- test "open_mode constants" do
146
- assert_not_nil(Pipe::ACCESS_DUPLEX)
147
- assert_not_nil(Pipe::ACCESS_INBOUND)
148
- assert_not_nil(Pipe::ACCESS_OUTBOUND)
149
- assert_not_nil(Pipe::FIRST_PIPE_INSTANCE)
150
- assert_not_nil(Pipe::WRITE_THROUGH)
151
- assert_not_nil(Pipe::OVERLAPPED)
152
- end
153
-
154
- test "other contants" do
155
- assert_not_nil(Pipe::INFINITE)
156
- end
157
-
158
- def teardown
159
- @pipe.close if @pipe
160
- @pipe = nil
161
- end
162
- end
1
+ ##########################################################################
2
+ # test_win32_pipe.rb
3
+ #
4
+ # Test suite for the win32-pipe library. This test suite should be run
5
+ # via the 'rake test' task.
6
+ ##########################################################################
7
+ require 'test-unit'
8
+ require 'win32/pipe'
9
+ include Win32
10
+
11
+ class TC_Win32_Pipe < Test::Unit::TestCase
12
+ def setup
13
+ @pipe = Pipe.new('foo')
14
+ end
15
+
16
+ test "version is set to expected value" do
17
+ assert_equal('0.3.7', Pipe::VERSION)
18
+ end
19
+
20
+ test "name method basic functionality" do
21
+ assert_respond_to(@pipe, :name)
22
+ assert_nothing_raised{ @pipe.name }
23
+ assert_kind_of(String, @pipe.name)
24
+ end
25
+
26
+ test "name returns expected string" do
27
+ assert_equal("\\\\.\\pipe\\foo", @pipe.name)
28
+ end
29
+
30
+ test "mode method basic functionality" do
31
+ assert_respond_to(@pipe, :pipe_mode)
32
+ assert_nothing_raised{ @pipe.pipe_mode }
33
+ assert_kind_of(Fixnum, @pipe.pipe_mode)
34
+ end
35
+
36
+ test "mode method returns expected value" do
37
+ assert_equal(Pipe::DEFAULT_PIPE_MODE, @pipe.pipe_mode)
38
+ end
39
+
40
+ test "open_mode basic functionality" do
41
+ assert_respond_to(@pipe, :open_mode)
42
+ assert_nothing_raised{ @pipe.open_mode }
43
+ assert_kind_of(Numeric, @pipe.open_mode)
44
+ end
45
+
46
+ test "open_mode returns the expected value" do
47
+ assert_equal(Pipe::DEFAULT_OPEN_MODE, @pipe.open_mode)
48
+ end
49
+
50
+ test "buffer method basic functionality" do
51
+ assert_respond_to(@pipe, :buffer)
52
+ assert_nothing_raised{ @pipe.buffer }
53
+ end
54
+
55
+ test "size basic functionality" do
56
+ assert_respond_to(@pipe, :size)
57
+ assert_nothing_raised{ @pipe.size }
58
+ end
59
+
60
+ test "length is an alias for size" do
61
+ assert_respond_to(@pipe, :length)
62
+ assert_alias_method(@pipe, :length, :size)
63
+ end
64
+
65
+ test "pending method basic functionality" do
66
+ assert_respond_to(@pipe, :pending?)
67
+ assert_nothing_raised{ @pipe.pending? }
68
+ assert_boolean(@pipe.pending?)
69
+ end
70
+
71
+ test "pending method defaults to false" do
72
+ assert_false(@pipe.pending?)
73
+ end
74
+
75
+ test "asynchronous method basic functionality" do
76
+ assert_respond_to(@pipe, :asynchronous?)
77
+ assert_nothing_raised{ @pipe.asynchronous? }
78
+ assert_boolean(@pipe.asynchronous?)
79
+ end
80
+
81
+ test "asynchronous method defaults to false" do
82
+ assert_false(@pipe.asynchronous?)
83
+ end
84
+
85
+ test "read method basic functionality" do
86
+ assert_respond_to(@pipe, :read)
87
+ end
88
+
89
+ test "read method raises an error if there's nothing to read" do
90
+ assert_raises(Pipe::Error){ @pipe.read }
91
+ end
92
+
93
+ test "transfered method basic functionality" do
94
+ assert_respond_to(@pipe, :transferred)
95
+ assert_nothing_raised{ @pipe.transferred }
96
+ end
97
+
98
+ test "wait method basic functionality" do
99
+ assert_respond_to(@pipe, :wait)
100
+ end
101
+
102
+ test "wait method raises an error in blocking mode" do
103
+ assert_raises(Pipe::Error){ @pipe.wait }
104
+ end
105
+
106
+ test "write method basic functionality" do
107
+ assert_respond_to(@pipe, :write)
108
+ end
109
+
110
+ test "write method requires one argument" do
111
+ assert_raises(ArgumentError){ @pipe.write }
112
+ end
113
+
114
+ test "write method raises an error if there's nothing to write to" do
115
+ assert_raises(Pipe::Error){ @pipe.write("foo") }
116
+ end
117
+
118
+ test "disconnect method basic functionality" do
119
+ assert_respond_to(@pipe, :disconnect)
120
+ assert_nothing_raised{ @pipe.disconnect }
121
+ end
122
+
123
+ test "calling the disconnect method multiple times has no effect" do
124
+ assert_nothing_raised{ @pipe.disconnect; @pipe.disconnect }
125
+ end
126
+
127
+ test "close method basic functionality" do
128
+ assert_respond_to(@pipe, :close)
129
+ assert_nothing_raised{ @pipe.close }
130
+ end
131
+
132
+ test "calling close multiple times has no effect" do
133
+ assert_nothing_raised{ @pipe.close; @pipe.close }
134
+ end
135
+
136
+ test "pipe_mode constants" do
137
+ assert_not_nil(Pipe::WAIT)
138
+ assert_not_nil(Pipe::NOWAIT)
139
+ assert_not_nil(Pipe::TYPE_BYTE)
140
+ assert_not_nil(Pipe::TYPE_MESSAGE)
141
+ assert_not_nil(Pipe::READMODE_BYTE)
142
+ assert_not_nil(Pipe::READMODE_MESSAGE)
143
+ end
144
+
145
+ test "open_mode constants" do
146
+ assert_not_nil(Pipe::ACCESS_DUPLEX)
147
+ assert_not_nil(Pipe::ACCESS_INBOUND)
148
+ assert_not_nil(Pipe::ACCESS_OUTBOUND)
149
+ assert_not_nil(Pipe::FIRST_PIPE_INSTANCE)
150
+ assert_not_nil(Pipe::WRITE_THROUGH)
151
+ assert_not_nil(Pipe::OVERLAPPED)
152
+ end
153
+
154
+ test "other contants" do
155
+ assert_not_nil(Pipe::INFINITE)
156
+ end
157
+
158
+ def teardown
159
+ @pipe.close if @pipe
160
+ @pipe = nil
161
+ end
162
+ end
@@ -1,62 +1,62 @@
1
- ##########################################################################
2
- # test_win32_pipe_client.rb
3
- #
4
- # Test suite for the Pipe::Client class. This test suite should be run
5
- # as part of the 'rake test' task.
6
- ##########################################################################
7
- require 'test/unit'
8
- require 'win32/pipe'
9
-
10
- class TC_Win32_Pipe_Client < Test::Unit::TestCase
11
- def setup
12
- @server = Win32::Pipe::Server.new('test')
13
- @pipe = nil
14
- @name = 'test'
15
- @pmode = Win32::Pipe::PIPE_NOWAIT
16
- @omode = Win32::Pipe::DEFAULT_OPEN_MODE
17
- end
18
-
19
- test "constructor basic functionality" do
20
- assert_respond_to(Win32::Pipe::Client, :new)
21
- assert_nothing_raised{ @pipe = Win32::Pipe::Client.new(@name) }
22
- end
23
-
24
- test "constructor accepts an optional pipe mode" do
25
- assert_nothing_raised{ @pipe = Win32::Pipe::Client.new(@name, @pmode) }
26
- end
27
-
28
- test "constructor accepts an optional open mode" do
29
- assert_nothing_raised{ @pipe = Win32::Pipe::Client.new(@name, @pmode, @omode) }
30
- end
31
-
32
- test "constructor requires a pipe name" do
33
- assert_raise(ArgumentError){ Win32::Pipe::Client.new }
34
- end
35
-
36
- test "pipe name must be a string" do
37
- assert_raise(TypeError){ Win32::Pipe::Client.new(1) }
38
- end
39
-
40
- test "an error is raised if the named pipe cannot be found" do
41
- assert_raise(SystemCallError, Errno::ENOENT){
42
- Win32::Pipe::Client.new('bogus')
43
- }
44
- end
45
-
46
- def teardown
47
- if @pipe
48
- @pipe.disconnect
49
- @pipe.close
50
- end
51
-
52
- if @server
53
- @server.disconnect
54
- @server.close
55
- end
56
-
57
- @pmode = nil
58
- @omode = nil
59
- @pipe = nil
60
- @server = nil
61
- end
62
- end
1
+ ##########################################################################
2
+ # test_win32_pipe_client.rb
3
+ #
4
+ # Test suite for the Pipe::Client class. This test suite should be run
5
+ # as part of the 'rake test' task.
6
+ ##########################################################################
7
+ require 'test/unit'
8
+ require 'win32/pipe'
9
+
10
+ class TC_Win32_Pipe_Client < Test::Unit::TestCase
11
+ def setup
12
+ @server = Win32::Pipe::Server.new('test')
13
+ @pipe = nil
14
+ @name = 'test'
15
+ @pmode = Win32::Pipe::PIPE_NOWAIT
16
+ @omode = Win32::Pipe::DEFAULT_OPEN_MODE
17
+ end
18
+
19
+ test "constructor basic functionality" do
20
+ assert_respond_to(Win32::Pipe::Client, :new)
21
+ assert_nothing_raised{ @pipe = Win32::Pipe::Client.new(@name) }
22
+ end
23
+
24
+ test "constructor accepts an optional pipe mode" do
25
+ assert_nothing_raised{ @pipe = Win32::Pipe::Client.new(@name, @pmode) }
26
+ end
27
+
28
+ test "constructor accepts an optional open mode" do
29
+ assert_nothing_raised{ @pipe = Win32::Pipe::Client.new(@name, @pmode, @omode) }
30
+ end
31
+
32
+ test "constructor requires a pipe name" do
33
+ assert_raise(ArgumentError){ Win32::Pipe::Client.new }
34
+ end
35
+
36
+ test "pipe name must be a string" do
37
+ assert_raise(TypeError){ Win32::Pipe::Client.new(1) }
38
+ end
39
+
40
+ test "an error is raised if the named pipe cannot be found" do
41
+ assert_raise(SystemCallError, Errno::ENOENT){
42
+ Win32::Pipe::Client.new('bogus')
43
+ }
44
+ end
45
+
46
+ def teardown
47
+ if @pipe
48
+ @pipe.disconnect
49
+ @pipe.close
50
+ end
51
+
52
+ if @server
53
+ @server.disconnect
54
+ @server.close
55
+ end
56
+
57
+ @pmode = nil
58
+ @omode = nil
59
+ @pipe = nil
60
+ @server = nil
61
+ end
62
+ end
@@ -1,34 +1,34 @@
1
- ##########################################################################
2
- # test_win32_pipe_server.rb
3
- #
4
- # Test suite for the Pipe::Server class. This test suite should be run
5
- # as part of the 'rake test' task.
6
- ##########################################################################
7
- require 'test/unit'
8
- require 'win32/pipe'
9
- include Win32
10
-
11
- class TC_Win32_Pipe_Server < Test::Unit::TestCase
12
- def setup
13
- @pipe = nil
14
- end
15
-
16
- def test_constructor_basic
17
- assert_respond_to(Pipe::Server, :new)
18
- assert_nothing_raised{ @pipe = Pipe::Server.new('foo') }
19
- end
20
-
21
- def test_connect
22
- assert_nothing_raised{ @pipe = Pipe::Server.new('foo') }
23
- assert_respond_to(@pipe, :connect)
24
- end
25
-
26
- def test_constructor_expected_errors
27
- assert_raise(ArgumentError){ Pipe::Server.new }
28
- assert_raise(TypeError){ Pipe::Server.new(1) }
29
- end
30
-
31
- def teardown
32
- @pipe = nil
33
- end
34
- end
1
+ ##########################################################################
2
+ # test_win32_pipe_server.rb
3
+ #
4
+ # Test suite for the Pipe::Server class. This test suite should be run
5
+ # as part of the 'rake test' task.
6
+ ##########################################################################
7
+ require 'test/unit'
8
+ require 'win32/pipe'
9
+ include Win32
10
+
11
+ class TC_Win32_Pipe_Server < Test::Unit::TestCase
12
+ def setup
13
+ @pipe = nil
14
+ end
15
+
16
+ def test_constructor_basic
17
+ assert_respond_to(Pipe::Server, :new)
18
+ assert_nothing_raised{ @pipe = Pipe::Server.new('foo') }
19
+ end
20
+
21
+ def test_connect
22
+ assert_nothing_raised{ @pipe = Pipe::Server.new('foo') }
23
+ assert_respond_to(@pipe, :connect)
24
+ end
25
+
26
+ def test_constructor_expected_errors
27
+ assert_raise(ArgumentError){ Pipe::Server.new }
28
+ assert_raise(TypeError){ Pipe::Server.new(1) }
29
+ end
30
+
31
+ def teardown
32
+ @pipe = nil
33
+ end
34
+ end