예제 #1
0
        public void FloatTest(float value)
        {
            float replica = 0;

            m_stream.WriteFloat(value);
            Assert.AreEqual(32, m_stream.BitOffset);

            m_stream.ResetRead();
            replica = m_stream.ReadFloat();

            Assert.AreEqual(value, replica);
        }
예제 #2
0
        public void PeekFloat(float value)
        {
            const float min = -5, max = 5, prec = 0.2f;

            m_stream.WriteFloat(value, min, max, prec);
            m_stream.ResetRead();
            Assert.AreEqual(value, m_stream.PeekFloat(min, max, prec), 0.000005f);
            Assert.AreEqual(0, m_stream.BitOffset);
        }
예제 #3
0
        public void ReadWriteMultipleTest()
        {
            const bool   bVal   = true;
            const double dVal   = double.MaxValue / 3 * 2;
            const float  fVal   = float.MinValue / 5;
            const short  sVal   = -12345;
            const int    offset = 113;

            m_stream = new BitStreamer();
            m_stream.ResetWrite(64);
            m_stream.WriteBool(bVal);
            m_stream.WriteDouble(dVal);
            m_stream.WriteFloat(fVal);
            m_stream.WriteShort(sVal);
            Assert.AreEqual(offset, m_stream.BitOffset);

            m_stream.ResetRead();
            Assert.AreEqual(bVal, m_stream.ReadBool());
            Assert.AreEqual(dVal, m_stream.ReadDouble());
            Assert.AreEqual(fVal, m_stream.ReadFloat());
            Assert.AreEqual(sVal, m_stream.ReadShort());
            Assert.AreEqual(offset, m_stream.BitOffset);
        }