Пример #1
0
    def testReadWriteVec3FromStream(self):
        stream = MemoryStream()
        stream.writeFloat(1.5)
        stream.writeFloat(2.5)
        stream.writeFloat(3.5)
        stream.resetPos()

        v = Vec3Value()
        v.readFromStream(stream)
        self.assertEqual(v.getVal(), (1.5, 2.5, 3.5))

        v.setVal(4.5, 5.5, 6.5)
        stream.resetPos()
        v.writeToStream(stream)

        self.assertEqual(stream.tellg(), 12)
        stream.resetPos()
        self.assertEqual(stream.readFloat(), 4.5)
        self.assertEqual(stream.readFloat(), 5.5)
        self.assertEqual(stream.readFloat(), 6.5)
Пример #2
0
    def testReadWriteFloatFromStream(self):
        stream = MemoryStream()
        stream.writeFloat(1.5)
        stream.resetPos()

        v = FloatValue()
        v.readFromStream(stream)
        self.assertEqual(v.getVal(), 1.5)

        v.setVal(2.5)
        stream.resetPos()
        v.writeToStream(stream)

        self.assertEqual(stream.tellg(), 4)
        stream.resetPos()
        self.assertEqual(stream.readFloat(), 2.5)