Namespace StreamTest

Imports System.IO

Sub TestMain()
	StringReaderTest()
	MemoryStreamTest()
End Sub

Sub StringReaderTest()
	Dim sr = New StringReader(Ex"0 abc\n123\r\nあいうえお\r\nアイウエオ")
	UnitTest("sr.Read() - 1", sr.Read() = &h30)
	UnitTest("sr.Read() - 2", sr.Read() = &h20)
	UnitTest("sr.Peek()", sr.Peek() = &h61)
	UnitTest("sr.ReadLine() \n", sr.ReadLine() = "abc")
	UnitTest("sr.ReadLine() \r\n", sr.ReadLine() = "123")
	Dim s = sr.ReadToEnd()
	UnitTest("sr.ReadToEnd() \r\n", s = Ex"あいうえお\r\nアイウエオ")
End Sub

Sub MemoryStreamTest()
	Dim buf[3] As Byte
	Dim ms = New MemoryStream(buf,0,4,True)
	UnitTest("ms.CanRead  True", ms.CanRead() = True)
	UnitTest("ms.CanWrite  True", ms.CanWrite() = True)
	UnitTest("ms.Length = 4", ms.Length() = 4)
	UnitTest("ms.Capacity = 4", ms.Capacity() = 4)
	ms.WriteByte(11)
	ms.WriteByte(22)
	ms.WriteByte(33)
	ms.Position = 0
	UnitTest("ms.Position = 0", ms.Position() = 0)
	UnitTest("ms.ReadByte - 11", ms.ReadByte() = 11)
	UnitTest("ms.ReadByte - 22", ms.ReadByte() = 22)
	UnitTest("ms.ReadByte - 33", ms.ReadByte() = 33)
	UnitTest("ms.Position = 3", ms.Position() = 3)
End Sub

End Namespace

StreamTest.TestMain()
