require 'test/unit'
require 'phi'

class TCFileStream < Test::Unit::TestCase
  def test_1
    # FileStream.new(filename, mode)
    # mode:
    #   fmOpenRead       = $0000;
    #   fmOpenWrite      = $0001;
    #   fmOpenReadWrite  = $0002;
    #
    #   fmShareCompat    = $0000 platform; // DOS compatibility mode is not portable
    #   fmShareExclusive = $0010;
    #   fmShareDenyWrite = $0020;
    #   fmShareDenyRead  = $0030 platform; // write-only not supported on all platforms
    #   fmShareDenyNone  = $0040;
    #
    #   fmCreate = $FFFF
    stream = Phi::FileStream.new($0, 0)
    assert_instance_of Phi::FileStream, stream
  end
end

class TCStringStream < Test::Unit::TestCase
  def test_1
    stream = Phi::StringStream.new('hello')
    assert_equal 5, stream.size
    assert_equal 0, stream.position
    assert_instance_of Phi::StringStream, stream
    # seek(offset, origin)
    # origin:
    #   soFromBeginning = 0;
    #   soFromCurrent = 1;
    #   soFromEnd = 2;
    stream.seek(0, 2)
    assert_equal 5, stream.position
    stream.seek(0, 0)
    assert_equal 0, stream.position
  end
end

class TCMemoryStream < Test::Unit::TestCase
  def test_1
    stream = Phi::MemoryStream.new
    assert_instance_of Phi::MemoryStream, stream
  end
end
