SLjc@sdZdZyddlZWnek r;ddlZnXddlmZddlmZdej fdYZ e dkrej ndS( s.Test for google.protobuf.internal.wire_format.s#robinson@google.com (Will Robinson)iN(tmessage(t wire_formattWireFormatTestcBs>eZdZdZdZdZdZdZRS(cCsod}d}|j|d>|Btj||tj}|jtj||d|jtj||ddS(Ni iiii(t assertEqualRtPackTagt assertRaisesRt EncodeError(tselft field_numberttag_typeR((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/wire_format_test.pyt testPackTag/s cCsxfd D]^}xUtdD]G}tjtj||\}}|j|||j||qWqW|jttjd|jttjd|jttjd|jttjtdS( Niiiiiitabcg(iiiii( trangeRt UnpackTagRRRt TypeErrortNonetobject(Rtexpected_field_numbertexpected_wire_typeRt wire_type((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/wire_format_test.pyt testUnpackTag:s cCs"tj}|jd|d|jd|d|jd|d|jd|d|jd|d|jd|d |jd |d |jd |d |jd|d|jt|d|jt|d|jt|d|jt|tdS(Niiiiiiilililllltabcdg(Rt ZigZagEncodeRRRRR(RtZ((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/wire_format_test.pyttestZigZagEncodeHs cCs"tj}|jd|d|jd|d|jd|d|jd|d|jd|d|jd|d |jd |d |jd |d |jd|d|jt|d|jt|d|jt|d|jt|tdS(NiiiiiiiililllllRg(Rt ZigZagDecodeRRRRR(RR((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/wire_format_test.pyttestZigZagDecodeYs c Csfx_d d d d fD]K\}}||}|||}|j||d|||||fqWdS( NiiiiiiisFbyte_size_fn: %s, field_number: %d, value: %r Expected: %d, Actual: %d(ii(ii(ii(ii(R(Rt byte_size_fntvaluetexpected_value_sizeRt tag_bytest expected_sizet actual_size((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/wire_format_test.pytNumericByteSizeTestHelperjs   c6CsTtjddgtjddgtjddgtjddgtjddgtjddgtjddgtjddgtjddgtjddgtjddgtjtjdgtjddgtjddgtjddgtjtjdgtjddgtjddgtjddgtjd dgtjd dgtjd dgtjd dgtjddgtjddgtjddgtjd dgtjd dgtjd dgtjd dgtj dd gtj tjd gtj ddgtj tjdgtj dd gtj tj d gtj tj d gtjddgtjtjdgtjtjdgtjdd gtjdd gtjdd gtjddgtjddgtjddgtjtdgtjtdgtjddgtjddgtjddgtjtjdgg4}x|D]}|j|q4WxitjtjfD]U}|jd|dd|jd|dd|jd|dddq^W|jdtjddjddtfdY}d}|d|}|jd|tjd||jd |tjd||jd|jtjd||jd|jtjd|d|_|jd |jtjd|d|_|j|jdtj d|d|_|j|jdtj d||j|jdtj d||j!t"j#tjdddS(Niiiiiii iii?ii@iiggeAgeR iiitasТестsutf-8t MockMessagecBseZdZdZRS(cSs ||_dS(N(t byte_size(RR$((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/wire_format_test.pyt__init__scSs|jS(N(R$(R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/wire_format_test.pytByteSizes(t__name__t __module__R%R&(((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/wire_format_test.pyR#s R$iil ($Rt Int32ByteSizet Int64ByteSizetUInt32ByteSizet UINT32_MAXtUInt64ByteSizet UINT64_MAXtSInt32ByteSizetSInt64ByteSizetFixed32ByteSizetFixed64ByteSizetSFixed32ByteSizet INT32_MINt INT32_MAXtSFixed64ByteSizet INT64_MINt INT64_MAXt FloatByteSizetDoubleByteSizet BoolByteSizetFalsetTruet EnumByteSizeR!tStringByteSizet BytesByteSizeRtdecodeRt GroupByteSizeR$tMessageByteSizetMessageSetItemByteSizeRRR(Rt NUMERIC_ARGStargsRR#tmessage_byte_sizet mock_message((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/wire_format_test.pyttestByteSizeFunctionsts !      (R'R(R RRRR!RI(((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/wire_format_test.pyR-s     t__main__( t__doc__t __author__t unittest2tunittestt ImportErrortgoogle.protobufRtgoogle.protobuf.internalRtTestCaseRR'tmain(((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/wire_format_test.pyt s