def testWriteWithoutOptional(self):
     field = 0x7ACF
     autoOptionalMemberAlignment = self.api.AutoOptionalMemberAlignment(field_=field)
     bitBuffer = zserio.serialize(autoOptionalMemberAlignment)
     readAutoOptionalMemberAlignment = zserio.deserialize(self.api.AutoOptionalMemberAlignment, bitBuffer)
     self._checkAutoOptionalMemberAlignment(readAutoOptionalMemberAlignment, None, field)
     self.assertTrue(autoOptionalMemberAlignment == readAutoOptionalMemberAlignment)
Exemplo n.º 2
0
 def testFromReader(self):
     testUnion = self.api.TestUnion(True, case3_field_=-1)
     bitBuffer = zserio.serialize(testUnion)
     readTestUnion = zserio.deserialize(self.api.TestUnion, bitBuffer, True)
     self.assertEqual(testUnion.choice_tag, readTestUnion.choice_tag)
     self.assertEqual(testUnion.case3_field, readTestUnion.case3_field)
     self.assertEqual(-1, readTestUnion.case3_field)
Exemplo n.º 3
0
 def _checkVarSizeValue(self, value):
     varSizeRangeCheckCompound = self.api.VarSizeRangeCheckCompound(value)
     bitBuffer = zserio.serialize(varSizeRangeCheckCompound)
     readVarSizeRangeCheckCompound = zserio.deserialize(
         self.api.VarSizeRangeCheckCompound, bitBuffer)
     self.assertEqual(varSizeRangeCheckCompound,
                      readVarSizeRangeCheckCompound)
Exemplo n.º 4
0
 def _checkOptionalBit31Value(self, value):
     optionalBit31RangeCheckCompound = self.api.OptionalBit31RangeCheckCompound(
         has_optional_=True, value_=value)
     bitBuffer = zserio.serialize(optionalBit31RangeCheckCompound)
     readOptionalBit31RangeCheckCompound = zserio.deserialize(
         self.api.OptionalBit31RangeCheckCompound, bitBuffer)
     self.assertEqual(optionalBit31RangeCheckCompound,
                      readOptionalBit31RangeCheckCompound)
Exemplo n.º 5
0
 def testWrite(self):
     numSentences = 13
     wrongArrayLength = False
     message = self._createMessage(numSentences, wrongArrayLength)
     bitBuffer = zserio.serialize(message)
     readMessage = zserio.deserialize(self.api.Message, bitBuffer)
     self._checkMessage(readMessage, numSentences)
     self.assertTrue(message == readMessage)
Exemplo n.º 6
0
 def _checkDynamicBitValue(self, numBits, value):
     dynamicBitRangeCheckCompound = self.api.DynamicBitRangeCheckCompound(
         num_bits_=numBits, value_=value)
     bitBuffer = zserio.serialize(dynamicBitRangeCheckCompound)
     readDynamicBitRangeCheckCompound = zserio.deserialize(
         self.api.DynamicBitRangeCheckCompound, bitBuffer)
     self.assertEqual(dynamicBitRangeCheckCompound,
                      readDynamicBitRangeCheckCompound)
Exemplo n.º 7
0
 def _checkInt7ArrayValue(self, value):
     int7ArrayRangeCheckCompound = self.api.Int7ArrayRangeCheckCompound(
         1, array_=[value])
     bitBuffer = zserio.serialize(int7ArrayRangeCheckCompound)
     readInt7ArrayRangeCheckCompound = zserio.deserialize(
         self.api.Int7ArrayRangeCheckCompound, bitBuffer)
     self.assertEqual(int7ArrayRangeCheckCompound,
                      readInt7ArrayRangeCheckCompound)
 def testWriteWithOptional(self):
     autoOptionalField = 0x9ADB
     field = 0x8ACD
     autoOptionalMemberAlignment = self.api.AutoOptionalMemberAlignment(autoOptionalField, field)
     bitBuffer = zserio.serialize(autoOptionalMemberAlignment)
     readAutoOptionalMemberAlignment = zserio.deserialize(self.api.AutoOptionalMemberAlignment, bitBuffer)
     self._checkAutoOptionalMemberAlignment(readAutoOptionalMemberAlignment, autoOptionalField, field)
     self.assertTrue(autoOptionalMemberAlignment == readAutoOptionalMemberAlignment)
Exemplo n.º 9
0
 def _checkWrite(self, numElements):
     uint8Array = list(range(numElements))
     autoArray = self.api.AutoArray(uint8Array)
     bitBuffer = zserio.serialize(autoArray)
     readAutoArray = zserio.deserialize(self.api.AutoArray, bitBuffer)
     readUint8Array = readAutoArray.uint8_array
     self.assertEqual(numElements, len(readUint8Array))
     for i in range(numElements):
         self.assertEqual(i, readUint8Array[i])
    def testWriteRead(self):
        packedAutoArray = self._createPackedAutoArray()
        bitBuffer = zserio.serialize(packedAutoArray)

        self.assertEqual(bitBuffer.bitsize, packedAutoArray.bitsizeof())
        self.assertEqual(bitBuffer.bitsize, packedAutoArray.initialize_offsets(0))

        readPackedAutoArray = zserio.deserialize(self.api.PackedAutoArray, bitBuffer)
        self.assertEqual(packedAutoArray, readPackedAutoArray)
Exemplo n.º 11
0
 def testWrite(self):
     uint8Array = list(range(self.FIXED_ARRAY_LENGTH))
     fixedArray = self.api.FixedArray(uint8Array)
     bitBuffer = zserio.serialize(fixedArray)
     readFixedArray = zserio.deserialize(self.api.FixedArray, bitBuffer)
     readUint8Array = readFixedArray.uint8_array
     self.assertEqual(self.FIXED_ARRAY_LENGTH, len(readUint8Array))
     for i in range(self.FIXED_ARRAY_LENGTH):
         self.assertEqual(i, readUint8Array[i])
Exemplo n.º 12
0
    def testParamConstructor(self):
        testUnion = self.api.TestUnion(True)
        self.assertTrue(testUnion.case1_allowed)

        testUnion.case1_field = 11
        bitBuffer = zserio.serialize(testUnion)
        readTestUnion = zserio.deserialize(self.api.TestUnion, bitBuffer, True)
        self.assertEqual(testUnion.case1_allowed, readTestUnion.case1_allowed)
        self.assertEqual(testUnion.case1_field, readTestUnion.case1_field)
Exemplo n.º 13
0
    def testWriteCorrectConstraints(self):
        arrayLengthofConstraint = self.api.ArrayLengthofConstraint()
        arrayLengthofConstraint.array = list(range(self.CORRECT_LENGTH))

        bitBuffer = zserio.serialize(arrayLengthofConstraint)
        readArrayLengthofConstraint = zserio.deserialize(
            self.api.ArrayLengthofConstraint, bitBuffer)
        self.assertEqual(self.CORRECT_LENGTH,
                         len(readArrayLengthofConstraint.array))
        self.assertEqual(arrayLengthofConstraint, readArrayLengthofConstraint)
Exemplo n.º 14
0
 def _checkChoiceBit4Value(self, value):
     selector = True
     choiceBit4RangeCheckCompound = self.api.ChoiceBit4RangeCheckCompound(
         selector)
     choiceBit4RangeCheckCompound.value = value
     bitBuffer = zserio.serialize(choiceBit4RangeCheckCompound)
     readChoiceBit4RangeCheckCompound = zserio.deserialize(
         self.api.ChoiceBit4RangeCheckCompound, bitBuffer, selector)
     self.assertEqual(choiceBit4RangeCheckCompound,
                      readChoiceBit4RangeCheckCompound)
Exemplo n.º 15
0
 def testWrite(self):
     numElements = 55
     array = list(range(numElements))
     implicitArray = self.api.ImplicitArray(array)
     bitBuffer = zserio.serialize(implicitArray)
     readImplicitArray = zserio.deserialize(self.api.ImplicitArray, bitBuffer)
     readArray = readImplicitArray.array
     self.assertEqual(numElements, len(readArray))
     for i in range(numElements):
         self.assertEqual(i, readArray[i])
Exemplo n.º 16
0
    def testPackageNameConflictImported(self):
        # just test that PackageNameConflictImported uses correct Blob
        packageNameConflictImported = self.api.PackageNameConflictImported(
            self.api.package_name_conflict.Blob("test"))
        bitBuffer = zserio.serialize(packageNameConflictImported)
        readPackageNameConflictImported = zserio.deserialize(
            self.api.PackageNameConflictImported, bitBuffer)

        self.assertEqual("test", packageNameConflictImported.blob.value)
        self.assertEqual(packageNameConflictImported.blob.value,
                         readPackageNameConflictImported.blob.value)
Exemplo n.º 17
0
 def _checkWrite(self, numElements):
     array = list(range(numElements))
     subtypedBuiltinAutoArray = self.api.SubtypedBuiltinAutoArray(
         array_=array)
     bitBuffer = zserio.serialize(subtypedBuiltinAutoArray)
     readAutoArray = zserio.deserialize(self.api.SubtypedBuiltinAutoArray,
                                        bitBuffer)
     readArray = readAutoArray.array
     self.assertEqual(numElements, len(readArray))
     for i in range(numElements):
         self.assertEqual(i, readArray[i])
Exemplo n.º 18
0
    def testPackageNameConflictLocal(self):
        # just test that PackageNameConflictLocal uses correct Blob
        packageNameConflictLocal = self.api.PackageNameConflictLocal(
            self.api.Blob(13))
        bitBuffer = zserio.serialize(packageNameConflictLocal)
        readPackageNameConflictLocal = zserio.deserialize(
            self.api.PackageNameConflictLocal, bitBuffer)

        self.assertEqual(13, packageNameConflictLocal.blob.value)
        self.assertEqual(packageNameConflictLocal.blob.value,
                         readPackageNameConflictLocal.blob.value)
Exemplo n.º 19
0
 def testWriteWithoutOptional(self):
     hasOptional = False
     field = 0x7ACF
     optionalMemberAlignment = self.api.OptionalMemberAlignment(
         has_optional_=hasOptional, field_=field)
     bitBuffer = zserio.serialize(optionalMemberAlignment)
     readOptionalMemberAlignment = zserio.deserialize(
         self.api.OptionalMemberAlignment, bitBuffer)
     self._checkOptionalMemberAlignment(readOptionalMemberAlignment,
                                        hasOptional, None, field)
     self.assertTrue(optionalMemberAlignment == readOptionalMemberAlignment)
Exemplo n.º 20
0
    def _checkWriteRead(self, numElements):
        uint8Array = self._createAutoArray(numElements)
        packedAutoArray = self.api.PackedAutoArray(uint8Array)
        bitBuffer = zserio.serialize(packedAutoArray)

        self.assertEqual(packedAutoArray.bitsizeof(), bitBuffer.bitsize)
        self.assertEqual(packedAutoArray.initialize_offsets(0), bitBuffer.bitsize)

        readPackedAutoArray = zserio.deserialize(self.api.PackedAutoArray, bitBuffer)
        readUint8Array = readPackedAutoArray.uint8_array
        self._checkPackedAutoArray(readUint8Array, numElements)
Exemplo n.º 21
0
    def _checkWriteRead(self, numElements):
        packedVariableArray = self._createPackedVariableArray(numElements)
        bitBuffer = zserio.serialize(packedVariableArray)

        self.assertEqual(packedVariableArray.bitsizeof(), bitBuffer.bitsize)
        self.assertEqual(packedVariableArray.initialize_offsets(0),
                         bitBuffer.bitsize)

        readPackedVariableArray = zserio.deserialize(
            self.api.PackedVariableArray, bitBuffer)
        self.assertEqual(packedVariableArray, readPackedVariableArray)
Exemplo n.º 22
0
    def _checkWriteRead(self, numElements):
        autoArrayRecursion = self._createAutoArrayRecursion(numElements)
        bitBuffer = zserio.serialize(autoArrayRecursion)

        self.assertEqual(autoArrayRecursion.bitsizeof(), bitBuffer.bitsize)
        self.assertEqual(autoArrayRecursion.initialize_offsets(0),
                         bitBuffer.bitsize)

        readAutoArrayRecursion = zserio.deserialize(
            self.api.AutoArrayRecursion, bitBuffer)
        self._checkAutoArrayRecursion(readAutoArrayRecursion, numElements)
Exemplo n.º 23
0
 def testWriteWithoutOptional(self):
     hasOptional = False
     optionalFieldOffset = 0xABCE
     field = 0x7ACF
     optionalMemberOffset = self.api.OptionalMemberOffset(
         hasOptional, optionalFieldOffset, None, field)
     bitBuffer = zserio.serialize(optionalMemberOffset)
     readOptionalMemberOffset = zserio.deserialize(
         self.api.OptionalMemberOffset, bitBuffer)
     self._checkOptionalMemberOffset(readOptionalMemberOffset, hasOptional,
                                     optionalFieldOffset, None, field)
     self.assertTrue(optionalMemberOffset == readOptionalMemberOffset)
Exemplo n.º 24
0
 def testWriteCorrectConstraints(self):
     structureBitmaskConstraints = self.api.StructureBitmaskConstraints(
         self.api.Availability.Values.COORD_X
         | self.api.Availability.Values.COORD_Y, 1, 1, 0)
     bitBuffer = zserio.serialize(structureBitmaskConstraints)
     readStructureBitmaskConstraints = zserio.deserialize(
         self.api.StructureBitmaskConstraints, bitBuffer)
     self.assertEqual(1, readStructureBitmaskConstraints.coord_x)
     self.assertEqual(1, readStructureBitmaskConstraints.coord_y)
     self.assertEqual(0, readStructureBitmaskConstraints.coord_z)
     self.assertEqual(structureBitmaskConstraints,
                      readStructureBitmaskConstraints)
Exemplo n.º 25
0
 def testWriteWithOptional(self):
     hasOptional = True
     optionalField = 0x9ADB
     field = 0x8ACD
     optionalMemberAlignment = self.api.OptionalMemberAlignment(
         hasOptional, optionalField, field)
     bitBuffer = zserio.serialize(optionalMemberAlignment)
     readOptionalMemberAlignment = zserio.deserialize(
         self.api.OptionalMemberAlignment, bitBuffer)
     self._checkOptionalMemberAlignment(readOptionalMemberAlignment,
                                        hasOptional, optionalField, field)
     self.assertTrue(optionalMemberAlignment == readOptionalMemberAlignment)
Exemplo n.º 26
0
    def testWriteCorrectConstraints(self):
        selector = False
        value16 = self.VALUE16_CORRECT_CONSTRAINT
        choiceConstraints = self.api.ChoiceConstraints(selector)
        choiceConstraints.value16 = value16

        bitBuffer = zserio.serialize(choiceConstraints)
        readChoiceConstraints = zserio.deserialize(self.api.ChoiceConstraints,
                                                   bitBuffer, selector)
        self.assertEqual(selector, readChoiceConstraints.selector)
        self.assertEqual(value16, readChoiceConstraints.value16)
        self.assertEqual(choiceConstraints, readChoiceConstraints)
Exemplo n.º 27
0
    def testWriteCorrectConstraints(self):
        value16 = self.VALUE16_CORRECT_CONSTRAINT
        unionConstraints = self.api.UnionConstraints()
        unionConstraints.value16 = value16

        bitBuffer = zserio.serialize(unionConstraints)
        readUnionConstraints = zserio.deserialize(self.api.UnionConstraints,
                                                  bitBuffer)
        self.assertEqual(self.api.UnionConstraints.CHOICE_VALUE16,
                         readUnionConstraints.choice_tag)
        self.assertEqual(value16, readUnionConstraints.value16)
        self.assertEqual(unionConstraints, readUnionConstraints)
Exemplo n.º 28
0
 def testWriteWithoutOptional(self):
     length = 0
     createWrongOffsets = False
     optionalNestedIndexedOffsetArray = self._createOptionalNestedIndexedOffsetArray(
         length, createWrongOffsets)
     bitBuffer = zserio.serialize(optionalNestedIndexedOffsetArray)
     readOptionalNestedIndexedOffsetArray = zserio.deserialize(
         self.api.OptionalNestedIndexedOffsetArray, bitBuffer)
     self._checkOptionalNestedIndexedOffsetArray(
         readOptionalNestedIndexedOffsetArray, length)
     self.assertTrue(optionalNestedIndexedOffsetArray ==
                     readOptionalNestedIndexedOffsetArray)
Exemplo n.º 29
0
 def testWriteWithoutOptional(self):
     hasOptional = False
     createWrongOffsets = False
     optionalIndexedOffsetArray = self._createOptionalIndexedOffsetArray(
         hasOptional, createWrongOffsets)
     bitBuffer = zserio.serialize(optionalIndexedOffsetArray)
     readOptionalIndexedOffsetArray = zserio.deserialize(
         self.api.OptionalIndexedOffsetArray, bitBuffer)
     self._checkOptionalIndexedOffsetArray(readOptionalIndexedOffsetArray,
                                           hasOptional)
     self.assertTrue(
         optionalIndexedOffsetArray == readOptionalIndexedOffsetArray)
Exemplo n.º 30
0
 def testWrite(self):
     numElements = 33
     compoundArray = [self.api.ArrayElement(i, "Name" + str(i)) for i in range(numElements)]
     subtypedStructVariableArray = self.api.SubtypedStructVariableArray(numElements, compoundArray)
     bitBuffer = zserio.serialize(subtypedStructVariableArray)
     readSubtypedStructVariableArray = zserio.deserialize(self.api.SubtypedStructVariableArray, bitBuffer)
     self.assertEqual(numElements, readSubtypedStructVariableArray.num_elements)
     readCompoundArray = readSubtypedStructVariableArray.compound_array
     self.assertEqual(numElements, len(readCompoundArray))
     for i in range(numElements):
         readArrayElement = readCompoundArray[i]
         self.assertEqual(i, readArrayElement.id)
         self.assertTrue(readArrayElement.name == "Name" + str(i))