public void TestReadDoubles() { using (var cfile = new CFile(BuildStream(new byte[] { 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98, 0xFE, 0xDC, 0xBA, 0x98 }))) { var vals = cfile.ReadDoubles(4); Assert.Equal(2, vals.Length); Assert.Equal("4.69197536052338E+271", vals[0].ToString(CultureInfo.InvariantCulture)); Assert.Equal(-1.50730608775746E-189, vals[1], 15); Assert.Equal(null, cfile.ReadDoubles(4)); Assert.Equal(true, cfile.EOF); } using (var cfile = new CFile(BuildStream(new byte[] { 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98, 0xFE, 0xDC, 0xBA }))) { var vals = cfile.ReadDoubles(4); Assert.Equal(1, vals.Length); Assert.Equal("4.69197536052338E+271", vals[0].ToString(CultureInfo.InvariantCulture)); Assert.Equal(null, cfile.ReadDoubles(4)); Assert.Equal(true, cfile.EOF); } using (var cfile = new CFile(BuildStream(new byte[] { 97, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98, 0xFE, 0xDC, 0xBA, 0x98 }))) { Assert.Equal('a', cfile.ReadChar()); var vals = cfile.ReadDoubles(4); Assert.Equal(2, vals.Length); Assert.Equal("4.69197536052338E+271", vals[0].ToString(CultureInfo.InvariantCulture)); Assert.Equal(-1.50730608775746E-189, vals[1], 15); Assert.Equal(null, cfile.ReadDoubles(4)); Assert.Equal(true, cfile.EOF); } }
public void TestReadDoubles() { using (var cfile = new CFile(BuildStream(new byte[] { 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98, 0xFE, 0xDC, 0xBA, 0x98 }))) { var vals = cfile.ReadDoubles(4); Assert.AreEqual(2, vals.Length); Assert.AreEqual(4.69197536052338E+271, vals[0], 1e+257); Assert.AreEqual(-1.50730608775746E-189, vals[1], 1e-150); Assert.AreEqual(null, cfile.ReadDoubles(4)); Assert.AreEqual(true, cfile.EOF); } using (var cfile = new CFile(BuildStream(new byte[] { 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98, 0xFE, 0xDC, 0xBA }))) { var vals = cfile.ReadDoubles(4); Assert.AreEqual(1, vals.Length); Assert.AreEqual(4.69197536052338E+271, vals[0], 1e+257); Assert.AreEqual(null, cfile.ReadDoubles(4)); Assert.AreEqual(true, cfile.EOF); } using (var cfile = new CFile(BuildStream(new byte[] { 97, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98, 0xFE, 0xDC, 0xBA, 0x98 }))) { Assert.AreEqual('a', cfile.ReadChar()); var vals = cfile.ReadDoubles(4); Assert.AreEqual(2, vals.Length); Assert.AreEqual(4.69197536052338E+271, vals[0], 1e+257); Assert.AreEqual(-1.50730608775746E-189, vals[1], 1e-150); Assert.AreEqual(null, cfile.ReadDoubles(4)); Assert.AreEqual(true, cfile.EOF); } }
public void TestReadInt32s() { using (var cfile = new CFile(BuildStream(new byte[] { 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98 }))) { var vals = cfile.ReadInt32s(4); Assert.Equal(2, vals.Length); Assert.Equal((int)0x78563412, vals[0]); Assert.Equal(0x98BADCFE, (uint)vals[1]); Assert.Equal(null, cfile.ReadInt32s(4)); Assert.Equal(true, cfile.EOF); } using (var cfile = new CFile(BuildStream(new byte[] { 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA }))) { var vals = cfile.ReadInt32s(4); Assert.Equal(1, vals.Length); Assert.Equal((int)0x78563412, vals[0]); Assert.Equal(null, cfile.ReadInt32s(4)); Assert.Equal(true, cfile.EOF); } using (var cfile = new CFile(BuildStream(new byte[] { 97, 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98 }))) { Assert.Equal('a', cfile.ReadChar()); var vals = cfile.ReadInt32s(4); Assert.Equal(2, vals.Length); Assert.Equal((int)0x78563412, vals[0]); Assert.Equal(0x98BADCFE, (uint)vals[1]); Assert.Equal(null, cfile.ReadInt32s(4)); Assert.Equal(true, cfile.EOF); } }
public void TestReadDouble() { using (var cfile = new CFile(BuildStream(new byte[] { 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98, 0xFE, 0xDC, 0xBA, 0x98 }))) { Assert.Equal("4.69197536052338E+271", cfile.ReadDouble().ToString(CultureInfo.InvariantCulture)); Assert.Equal(-1.50730608775746E-189, cfile.ReadDouble(), 15); Assert.Equal(0, cfile.ReadDouble()); Assert.Equal(true, cfile.EOF); } using (var cfile = new CFile(BuildStream(new byte[] { 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98, 0xFE, 0xDC, 0xBA }))) { Assert.Equal("4.69197536052338E+271", cfile.ReadDouble().ToString(CultureInfo.InvariantCulture)); Assert.Equal(0, cfile.ReadDouble()); Assert.Equal(0, cfile.ReadDouble()); Assert.Equal(true, cfile.EOF); } using (var cfile = new CFile(BuildStream(new byte[] { 97, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98, 0xFE, 0xDC, 0xBA, 0x98 }))) { Assert.Equal('a', cfile.ReadChar()); Assert.Equal("4.69197536052338E+271", cfile.ReadDouble().ToString(CultureInfo.InvariantCulture)); Assert.Equal(-1.50730608775746E-189, cfile.ReadDouble(), 15); Assert.Equal(0, cfile.ReadInt32()); Assert.Equal(true, cfile.EOF); } }
public void TestReadUInt32() { using (var cfile = new CFile(BuildStream(new byte[] { 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98 }))) { Assert.Equal((uint)0x78563412, cfile.ReadUInt32()); Assert.Equal(0x98BADCFE, cfile.ReadUInt32()); Assert.Equal((uint)0, cfile.ReadUInt32()); Assert.Equal(true, cfile.EOF); } using (var cfile = new CFile(BuildStream(new byte[] { 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA }))) { Assert.Equal((uint)0x78563412, cfile.ReadUInt32()); Assert.Equal((uint)0, cfile.ReadUInt32()); Assert.Equal((uint)0, cfile.ReadUInt32()); Assert.Equal(true, cfile.EOF); } using (var cfile = new CFile(BuildStream(new byte[] { 97, 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98 }))) { Assert.Equal('a', cfile.ReadChar()); Assert.Equal((uint)0x78563412, cfile.ReadUInt32()); Assert.Equal(0x98BADCFE, cfile.ReadUInt32()); Assert.Equal((uint)0, cfile.ReadUInt32()); Assert.Equal(true, cfile.EOF); } }
public void TestReadDouble() { using (var cfile = new CFile(BuildStream(new byte[] { 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98, 0xFE, 0xDC, 0xBA, 0x98 }))) { Assert.AreEqual(4.69197536052338E+271, cfile.ReadDouble(), 1e+257); Assert.AreEqual(-1.50730608775746E-189, cfile.ReadDouble(), 1e-150); Assert.AreEqual(0, cfile.ReadDouble()); Assert.AreEqual(true, cfile.EOF); } using (var cfile = new CFile(BuildStream(new byte[] { 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98, 0xFE, 0xDC, 0xBA }))) { Assert.AreEqual(4.69197536052338E+271, cfile.ReadDouble(), 1e+257); Assert.AreEqual(0, cfile.ReadDouble()); Assert.AreEqual(0, cfile.ReadDouble()); Assert.AreEqual(true, cfile.EOF); } using (var cfile = new CFile(BuildStream(new byte[] { 97, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98, 0xFE, 0xDC, 0xBA, 0x98 }))) { Assert.AreEqual('a', cfile.ReadChar()); Assert.AreEqual(4.69197536052338E+271, cfile.ReadDouble(), 1e+257); Assert.AreEqual(-1.50730608775746E-189, cfile.ReadDouble(), 1e-150); Assert.AreEqual(0, cfile.ReadInt32()); Assert.AreEqual(true, cfile.EOF); } }
public void TestReadChar() { using (var cfile = new CFile(BuildStream("èaà\nüî"))) { #if !NET_STANDARD Assert.Equal(195, cfile.ReadChar()); Assert.Equal(168, cfile.ReadChar()); Assert.Equal(97, cfile.ReadChar()); Assert.Equal(195, cfile.ReadChar()); Assert.Equal(160, cfile.ReadChar()); Assert.Equal(10, cfile.ReadChar()); Assert.Equal(195, cfile.ReadChar()); Assert.Equal(188, cfile.ReadChar()); Assert.Equal(195, cfile.ReadChar()); Assert.Equal(174, cfile.ReadChar()); #else Assert.Equal(232, cfile.ReadChar()); Assert.Equal(97, cfile.ReadChar()); Assert.Equal(224, cfile.ReadChar()); Assert.Equal(10, cfile.ReadChar()); Assert.Equal(252, cfile.ReadChar()); Assert.Equal(238, cfile.ReadChar()); #endif Assert.Equal(0, cfile.ReadChar()); Assert.Equal(true, cfile.EOF); } #if !NET_STANDARD using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.GetEncoding("windows-1252")))) { Assert.Equal(232, cfile.ReadChar()); Assert.Equal(97, cfile.ReadChar()); Assert.Equal(224, cfile.ReadChar()); Assert.Equal(10, cfile.ReadChar()); Assert.Equal(252, cfile.ReadChar()); Assert.Equal(238, cfile.ReadChar()); Assert.Equal(0, cfile.ReadChar()); Assert.Equal(true, cfile.EOF); } #endif using (var cfile = new CFile(BuildStream("èaà\nüî"), Encoding.UTF8)) { Assert.Equal('è', cfile.ReadChar()); Assert.Equal('a', cfile.ReadChar()); Assert.Equal('à', cfile.ReadChar()); Assert.Equal('\n', cfile.ReadChar()); Assert.Equal('ü', cfile.ReadChar()); Assert.Equal('î', cfile.ReadChar()); Assert.Equal(0, cfile.ReadChar()); Assert.Equal(true, cfile.EOF); } #if !NET_STANDARD using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.GetEncoding("windows-1252")), Encoding.GetEncoding("windows-1252"))) { Assert.Equal(232, cfile.ReadChar()); Assert.Equal(97, cfile.ReadChar()); Assert.Equal(224, cfile.ReadChar()); Assert.Equal(10, cfile.ReadChar()); Assert.Equal(252, cfile.ReadChar()); Assert.Equal(238, cfile.ReadChar()); Assert.Equal(0, cfile.ReadChar()); Assert.Equal(true, cfile.EOF); } using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.UTF8), Encoding.GetEncoding("windows-1252"))) { Assert.Equal(195, cfile.ReadChar()); Assert.Equal(168, cfile.ReadChar()); Assert.Equal(97, cfile.ReadChar()); Assert.Equal(195, cfile.ReadChar()); Assert.Equal(160, cfile.ReadChar()); Assert.Equal(10, cfile.ReadChar()); Assert.Equal(195, cfile.ReadChar()); Assert.Equal(188, cfile.ReadChar()); Assert.Equal(195, cfile.ReadChar()); Assert.Equal(174, cfile.ReadChar()); Assert.Equal(0, cfile.ReadChar()); Assert.Equal(true, cfile.EOF); } #endif using (var cfile = new CFile(BuildStream(new byte[] { 195 }), Encoding.UTF8)) { Assert.Equal(65533, cfile.ReadChar()); Assert.Equal(0, cfile.ReadChar()); Assert.Equal(true, cfile.EOF); } }
public void TestReadUInt32() { using (var cfile = new CFile(BuildStream(new byte[] { 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98 }))) { Assert.AreEqual((uint)0x78563412, cfile.ReadUInt32()); Assert.AreEqual(0x98BADCFE, cfile.ReadUInt32()); Assert.AreEqual((uint)0, cfile.ReadUInt32()); Assert.AreEqual(true, cfile.EOF); } using (var cfile = new CFile(BuildStream(new byte[] { 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA }))) { Assert.AreEqual((uint)0x78563412, cfile.ReadUInt32()); Assert.AreEqual((uint)0, cfile.ReadUInt32()); Assert.AreEqual((uint)0, cfile.ReadUInt32()); Assert.AreEqual(true, cfile.EOF); } using (var cfile = new CFile(BuildStream(new byte[] { 97, 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98 }))) { Assert.AreEqual('a', cfile.ReadChar()); Assert.AreEqual((uint)0x78563412, cfile.ReadUInt32()); Assert.AreEqual(0x98BADCFE, cfile.ReadUInt32()); Assert.AreEqual((uint)0, cfile.ReadUInt32()); Assert.AreEqual(true, cfile.EOF); } }
public void TestReadInt32s() { using (var cfile = new CFile(BuildStream(new byte[] { 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98 }))) { var vals = cfile.ReadInt32s(4); Assert.AreEqual(2, vals.Length); Assert.AreEqual((int)0x78563412, vals[0]); Assert.AreEqual(0x98BADCFE, (uint)vals[1]); Assert.AreEqual(null, cfile.ReadInt32s(4)); Assert.AreEqual(true, cfile.EOF); } using (var cfile = new CFile(BuildStream(new byte[] { 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA }))) { var vals = cfile.ReadInt32s(4); Assert.AreEqual(1, vals.Length); Assert.AreEqual((int)0x78563412, vals[0]); Assert.AreEqual(null, cfile.ReadInt32s(4)); Assert.AreEqual(true, cfile.EOF); } using (var cfile = new CFile(BuildStream(new byte[] { 97, 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98 }))) { Assert.AreEqual('a', cfile.ReadChar()); var vals = cfile.ReadInt32s(4); Assert.AreEqual(2, vals.Length); Assert.AreEqual((int)0x78563412, vals[0]); Assert.AreEqual(0x98BADCFE, (uint)vals[1]); Assert.AreEqual(null, cfile.ReadInt32s(4)); Assert.AreEqual(true, cfile.EOF); } }
public void TestReadDouble() { using (var cfile = new CFile(BuildStream(new byte[] { 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98, 0xFE, 0xDC, 0xBA, 0x98 }))) { Assert.AreEqual(4.69197536052338E+271, cfile.ReadDouble(), 1e+257); Assert.AreEqual(-1.50730608775746E-189, cfile.ReadDouble(), 1e-150); Assert.AreEqual(0, cfile.ReadDouble()); Assert.AreEqual(true, cfile.EOF); } using (var cfile = new CFile(BuildStream(new byte[] { 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98, 0xFE, 0xDC, 0xBA}))) { Assert.AreEqual(4.69197536052338E+271, cfile.ReadDouble(), 1e+257); Assert.AreEqual(0, cfile.ReadDouble()); Assert.AreEqual(0, cfile.ReadDouble()); Assert.AreEqual(true, cfile.EOF); } using (var cfile = new CFile(BuildStream(new byte[] {97, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98, 0xFE, 0xDC, 0xBA, 0x98 }))) { Assert.AreEqual('a', cfile.ReadChar()); Assert.AreEqual(4.69197536052338E+271, cfile.ReadDouble(), 1e+257); Assert.AreEqual(-1.50730608775746E-189, cfile.ReadDouble(), 1e-150); Assert.AreEqual(0, cfile.ReadInt32()); Assert.AreEqual(true, cfile.EOF); } }
public void TestReadChar() { using (var cfile = new CFile(BuildStream("èaà\nüî"))) { Assert.AreEqual(195, cfile.ReadChar()); Assert.AreEqual(168, cfile.ReadChar()); Assert.AreEqual(97, cfile.ReadChar()); Assert.AreEqual(195, cfile.ReadChar()); Assert.AreEqual(160, cfile.ReadChar()); Assert.AreEqual(10, cfile.ReadChar()); Assert.AreEqual(195, cfile.ReadChar()); Assert.AreEqual(188, cfile.ReadChar()); Assert.AreEqual(195, cfile.ReadChar()); Assert.AreEqual(174, cfile.ReadChar()); Assert.AreEqual(0, cfile.ReadChar()); Assert.AreEqual(true, cfile.EOF); } using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.GetEncoding("windows-1252")))) { Assert.AreEqual(232, cfile.ReadChar()); Assert.AreEqual(97, cfile.ReadChar()); Assert.AreEqual(224, cfile.ReadChar()); Assert.AreEqual(10, cfile.ReadChar()); Assert.AreEqual(252, cfile.ReadChar()); Assert.AreEqual(238, cfile.ReadChar()); Assert.AreEqual(0, cfile.ReadChar()); Assert.AreEqual(true, cfile.EOF); } using (var cfile = new CFile(BuildStream("èaà\nüî"), Encoding.UTF8)) { Assert.AreEqual('è', cfile.ReadChar()); Assert.AreEqual('a', cfile.ReadChar()); Assert.AreEqual('à', cfile.ReadChar()); Assert.AreEqual('\n', cfile.ReadChar()); Assert.AreEqual('ü', cfile.ReadChar()); Assert.AreEqual('î', cfile.ReadChar()); Assert.AreEqual(0, cfile.ReadChar()); Assert.AreEqual(true, cfile.EOF); } using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.GetEncoding("windows-1252")), Encoding.GetEncoding("windows-1252"))) { Assert.AreEqual(232, cfile.ReadChar()); Assert.AreEqual(97, cfile.ReadChar()); Assert.AreEqual(224, cfile.ReadChar()); Assert.AreEqual(10, cfile.ReadChar()); Assert.AreEqual(252, cfile.ReadChar()); Assert.AreEqual(238, cfile.ReadChar()); Assert.AreEqual(0, cfile.ReadChar()); Assert.AreEqual(true, cfile.EOF); } using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.UTF8), Encoding.GetEncoding("windows-1252"))) { Assert.AreEqual(195, cfile.ReadChar()); Assert.AreEqual(168, cfile.ReadChar()); Assert.AreEqual(97, cfile.ReadChar()); Assert.AreEqual(195, cfile.ReadChar()); Assert.AreEqual(160, cfile.ReadChar()); Assert.AreEqual(10, cfile.ReadChar()); Assert.AreEqual(195, cfile.ReadChar()); Assert.AreEqual(188, cfile.ReadChar()); Assert.AreEqual(195, cfile.ReadChar()); Assert.AreEqual(174, cfile.ReadChar()); Assert.AreEqual(0, cfile.ReadChar()); Assert.AreEqual(true, cfile.EOF); } using (var cfile = new CFile(BuildStream(new byte[] { 195 }), Encoding.UTF8)) { Assert.AreEqual(65533, cfile.ReadChar()); Assert.AreEqual(0, cfile.ReadChar()); Assert.AreEqual(true, cfile.EOF); } }