Esempio n. 1
0
        public void ReadNegativeFixedPoint16FromBitsTest()
        {
            var       mem    = new MemoryStream();
            var       writer = new SwfStreamWriter(mem);
            const int val    = -81920;
            var       bits   = new SignedBitsCount(val).GetBits();

            writer.WriteSignedBits(val, bits);
            writer.FlushBits();
            mem.Seek(0, SeekOrigin.Begin);
            var    reader = new SwfStreamReader(mem);
            double actual = reader.ReadFixedPoint16(bits);

            Assert.AreEqual(-1.25, actual);
        }
Esempio n. 2
0
        public void WriteSignedBitsNegativeTest()
        {
            var mem    = new MemoryStream();
            var writer = new SwfStreamWriter(mem);

            writer.WriteSignedBits(-0x155, 10);
            writer.WriteBit(false);
            writer.WriteBit(false);
            writer.WriteBit(false);
            writer.WriteBit(false);
            writer.WriteBit(true);
            writer.WriteBit(true);

            mem.Seek(0, SeekOrigin.Begin);

            Assert.AreEqual(0xaa, mem.ReadByte());
            Assert.AreEqual(0xc3, mem.ReadByte());

            Assert.AreEqual(mem.Length, mem.Position, "Should reach end of the stream");
        }
Esempio n. 3
0
        public void WriteSignedBitsPositiveTest()
        {
            var mem = new MemoryStream();
            var writer = new SwfStreamWriter(mem);
            writer.WriteSignedBits(0x0ab, 10);
            writer.WriteBit(false);
            writer.WriteBit(false);
            writer.WriteBit(false);
            writer.WriteBit(false);
            writer.WriteBit(true);
            writer.WriteBit(true);

            mem.Seek(0, SeekOrigin.Begin);

            Assert.AreEqual(0x2a, mem.ReadByte());
            Assert.AreEqual(0xc3, mem.ReadByte());

            Assert.AreEqual(mem.Length, mem.Position, "Should reach end of the stream");
        }
Esempio n. 4
0
 public void ReadNegativeFixedPoint16FromBitsTest()
 {
     var mem = new MemoryStream();
     var writer = new SwfStreamWriter(mem);
     const int val = -81920;
     var bits = new SignedBitsCount(val).GetBits();
     writer.WriteSignedBits(val, bits);
     writer.FlushBits();
     mem.Seek(0, SeekOrigin.Begin);
     var reader = new SwfStreamReader(mem);
     double actual = reader.ReadFixedPoint16(bits);
     Assert.AreEqual(-1.25, actual);
 }