about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-01-31 18:39:31 -0800
committerEric Wong <normalperson@yhbt.net>2011-01-31 18:46:20 -0800
commit36f69750cd69cbf892580da04be6675e23d92f6f (patch)
treea04e2574c0de5e1ebdcaa2ff8c9683c7a4ff6fdf /test
parent37e50a9a5fcd45242373379c0dc61ebf8ff609af (diff)
downloadkgio-36f69750cd69cbf892580da04be6675e23d92f6f.tar.gz
This allows people to more easily use Kgio in existing apps.
Diffstat (limited to 'test')
-rw-r--r--test/test_singleton_read_write.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/test_singleton_read_write.rb b/test/test_singleton_read_write.rb
new file mode 100644
index 0000000..5abbf00
--- /dev/null
+++ b/test/test_singleton_read_write.rb
@@ -0,0 +1,21 @@
+require 'test/unit'
+$-w = true
+require 'kgio'
+
+class TestSingletonReadWrite < Test::Unit::TestCase
+
+  def test_unix_socketpair
+    a, b = UNIXSocket.pair
+    assert_nothing_raised { Kgio.trywrite(a, "HELLO") }
+    buf = ""
+    assert_equal "HELLO", Kgio.tryread(b, 5, buf)
+    assert_equal "HELLO", buf
+    assert_equal :wait_readable, Kgio.tryread(b, 5)
+  end
+
+  def test_arg_error
+    assert_raises(ArgumentError) { Kgio.tryread }
+    assert_raises(ArgumentError) { Kgio.tryread($stdin) }
+    assert_raises(ArgumentError) { Kgio.trywrite($stdout) }
+  end
+end