public void TestSeek() { using (var cfile = new CFile(BuildStream(new byte[] { 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98 }))) { Assert.Equal(0, cfile.Seek(4, SeekOrigin.Current)); Assert.Equal(0x98BADCFE, (uint)cfile.ReadInt32()); Assert.Equal(0, cfile.Seek(0, SeekOrigin.Begin)); Assert.Equal((int)0x78563412, cfile.ReadInt32()); } using (var cfile = new CFile(null)) { Assert.Equal(-1, cfile.Seek(4, SeekOrigin.Current)); } }
public void TestReadInt32() { using (var cfile = new CFile(BuildStream(new byte[] { 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98 }))) { Assert.Equal((int)0x78563412, cfile.ReadInt32()); Assert.Equal(0x98BADCFE, (uint)cfile.ReadInt32()); Assert.Equal(0, cfile.ReadInt32()); Assert.Equal(true, cfile.EOF); } using (var cfile = new CFile(BuildStream(new byte[] { 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA }))) { Assert.Equal((int)0x78563412, cfile.ReadInt32()); Assert.Equal(0, cfile.ReadInt32()); Assert.Equal(0, cfile.ReadInt32()); 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((int)0x78563412, cfile.ReadInt32()); Assert.Equal(0x98BADCFE, (uint)cfile.ReadInt32()); Assert.Equal(0, cfile.ReadInt32()); 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 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 TestSeek() { using (var cfile = new CFile(BuildStream(new byte[] { 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98 }))) { Assert.AreEqual(0, cfile.Seek(4, SeekOrigin.Current)); Assert.AreEqual(0x98BADCFE, (uint)cfile.ReadInt32()); Assert.AreEqual(0, cfile.Seek(0, SeekOrigin.Begin)); Assert.AreEqual((int)0x78563412, cfile.ReadInt32()); } using (var cfile = new CFile(null)) { Assert.AreEqual(-1, cfile.Seek(4, SeekOrigin.Current)); } }
public void TestReadInt32() { using (var cfile = new CFile(BuildStream(new byte[] { 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA, 0x98 }))) { Assert.AreEqual((int)0x78563412, cfile.ReadInt32()); Assert.AreEqual(0x98BADCFE, (uint)cfile.ReadInt32()); Assert.AreEqual(0, cfile.ReadInt32()); Assert.AreEqual(true, cfile.EOF); } using (var cfile = new CFile(BuildStream(new byte[] { 0x12, 0x34, 0x56, 0x78, 0xFE, 0xDC, 0xBA }))) { Assert.AreEqual((int)0x78563412, cfile.ReadInt32()); Assert.AreEqual(0, cfile.ReadInt32()); Assert.AreEqual(0, cfile.ReadInt32()); 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((int)0x78563412, cfile.ReadInt32()); Assert.AreEqual(0x98BADCFE, (uint)cfile.ReadInt32()); Assert.AreEqual(0, cfile.ReadInt32()); 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); } }