about summary refs log tree commit homepage
path: root/test/test_tmpio.rb
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-04-01 23:19:32 +0000
committerEric Wong <e@80x24.org>2015-04-01 23:35:23 +0000
commitadbf9a03518a94932e951c231852dffc63671432 (patch)
tree94719c983e836ad01618803413403337a75ad379 /test/test_tmpio.rb
parent3c3ee6b78ab53478731d86fd99b8f9d6dc2d31a7 (diff)
downloadyahns-adbf9a03518a94932e951c231852dffc63671432.tar.gz
This will allow us to write arrays for chunked output without
unnecessary data copies.
Diffstat (limited to 'test/test_tmpio.rb')
-rw-r--r--test/test_tmpio.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/test_tmpio.rb b/test/test_tmpio.rb
new file mode 100644
index 0000000..79c9f32
--- /dev/null
+++ b/test/test_tmpio.rb
@@ -0,0 +1,20 @@
+# -*- encoding: binary -*-
+# Copyright (C) 2009-2015 all contributors <yahns-public@yhbt.net>
+# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-2.0.txt)
+require_relative 'helper'
+
+class TestTmpIO < Testcase
+  def test_writev
+    a, b = UNIXSocket.pair
+    a.extend Kgio::PipeMethods
+    tmpio = Yahns::TmpIO.new(Dir.tmpdir)
+    ary = [ "hello\n".freeze, "world\n".freeze ].freeze
+    tmpio.kgio_trywritev(ary)
+    a.trysendfile(tmpio, 0, 12)
+    assert_equal "hello\nworld\n", b.read(12)
+  ensure
+    b.close
+    a.close
+    tmpio.close
+  end
+end