From 486591b239be4bfa6e7fe4e0adb92389a30cf289 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 7 Feb 2014 22:01:14 -0500 Subject: [PATCH] test_kqueue_io: add test for deleting items --- test/test_kqueue_io.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/test_kqueue_io.rb b/test/test_kqueue_io.rb index e2cbe0d..65f2443 100644 --- a/test/test_kqueue_io.rb +++ b/test/test_kqueue_io.rb @@ -29,6 +29,25 @@ class TestKqueueIO < Testcase assert_raises(TypeError) { kq.kevent("HI") } end + def test_delete + kq = Kqueue::IO.new + @to_close << kq + r, w = IO.pipe + @to_close << r + @to_close << w + kq.kevent(Kevent[r.fileno, EvFilt::READ, Ev::ADD, 0, 0, r]) + w.syswrite "." + 2.times do + got = [] + kq.kevent(nil, 1, 0) { |*args| got << args } + assert_equal 1, got.size + end + kq.kevent(Kevent[r.fileno, EvFilt::READ|EvFilt::WRITE, Ev::DELETE, 0, 0, 0]) + got = [] + kq.kevent(nil, 1, 0) { |*args| got << args } + assert_equal 0, got.size + end + def test_multi_event kq = Kqueue::IO.new @to_close << kq -- 2.11.4.GIT