Ejemplo n.º 1
0
 def test_encode_ros_handshake_header(self):
     from rosgraph.network import encode_ros_handshake_header
     d = {}
     assert struct.pack('<I', 0) == encode_ros_handshake_header(d)
     s = b"a=b"
     d['a'] = 'b'
     encoded = struct.pack('<I', len(s)) + s
     assert struct.pack('<I', len(encoded))+encoded == \
         encode_ros_handshake_header({'a': 'b'})
     d['c'] = 'd'
     s = b"c=d"
     encoded = encoded + struct.pack('<I', len(s)) + s
     assert struct.pack('<I', len(encoded))+encoded == \
         encode_ros_handshake_header(d)
     d['rawtype'] = '#line 1\nline 2\nline 3\nline\t4\r\r\n'
     s = b"rawtype=#line 1\nline 2\nline 3\nline\t4\r\r\n"
     encoded = encoded + struct.pack('<I', len(s)) + s
     assert struct.pack('<I', len(encoded))+encoded == \
         encode_ros_handshake_header(d)
     if sys.version_info > (3, 0):
         assert \
             encode_ros_handshake_header(
                 {'a': 'b', 'c': 'd', 'e': 'f'}) == \
             encode_ros_handshake_header(
                 {b'a': 'b', 'c': b'd', b'e': b'f'})
     else:
         assert \
             encode_ros_handshake_header(
                 {'a': 'b', 'c': 'd', 'e': 'f'}) == \
             encode_ros_handshake_header(
                 {u'a': 'b', 'c': u'd', u'e': u'f'})
Ejemplo n.º 2
0
 def test_encode_ros_handshake_header(self):
     from rosgraph.network import encode_ros_handshake_header
     d = {}
     assert struct.pack('<I', 0) == encode_ros_handshake_header(d)
     s = "a=b"
     d['a'] = 'b'
     encoded = struct.pack('<I', len(s)) + s
     assert struct.pack('<I', len(encoded))+encoded == \
         encode_ros_handshake_header({'a': 'b'})
     d['c'] = 'd'
     s = "c=d"
     encoded = encoded + struct.pack('<I', len(s)) + s
     assert struct.pack('<I', len(encoded))+encoded == \
         encode_ros_handshake_header(d)
     d['rawtype'] = '#line 1\nline 2\nline 3\nline\t4\r\r\n'
     s = "rawtype=#line 1\nline 2\nline 3\nline\t4\r\r\n"
     encoded = encoded + struct.pack('<I', len(s)) + s
     assert struct.pack('<I', len(encoded))+encoded == \
         encode_ros_handshake_header(d)
Ejemplo n.º 3
0
 def test_encode_ros_handshake_header(self):
     from rosgraph.network import encode_ros_handshake_header
     d = {}
     assert struct.pack('<I', 0) == encode_ros_handshake_header(d)
     s = "a=b"
     d['a'] = 'b'
     encoded = struct.pack('<I', len(s))+s
     assert struct.pack('<I', len(encoded))+encoded == \
         encode_ros_handshake_header({'a': 'b'})
     d['c'] = 'd' 
     s = "c=d"
     encoded = encoded+struct.pack('<I', len(s))+s    
     assert struct.pack('<I', len(encoded))+encoded == \
         encode_ros_handshake_header(d)
     d['rawtype'] = '#line 1\nline 2\nline 3\nline\t4\r\r\n'
     s = "rawtype=#line 1\nline 2\nline 3\nline\t4\r\r\n"
     encoded = encoded+struct.pack('<I', len(s))+s        
     assert struct.pack('<I', len(encoded))+encoded == \
         encode_ros_handshake_header(d)