(self)
| 148 | self.assertTrue(asy) |
| 149 | |
| 150 | def test_calcsize(self): |
| 151 | expected_size = { |
| 152 | 'b': 1, 'B': 1, |
| 153 | 'h': 2, 'H': 2, |
| 154 | 'i': 4, 'I': 4, |
| 155 | 'l': 4, 'L': 4, |
| 156 | 'q': 8, 'Q': 8, |
| 157 | } |
| 158 | |
| 159 | # standard integer sizes |
| 160 | for code, byteorder in iter_integer_formats(('=', '<', '>', '!')): |
| 161 | format = byteorder+code |
| 162 | size = struct.calcsize(format) |
| 163 | self.assertEqual(size, expected_size[code]) |
| 164 | |
| 165 | # native integer sizes |
| 166 | native_pairs = 'bB', 'hH', 'iI', 'lL', 'nN', 'qQ' |
| 167 | for format_pair in native_pairs: |
| 168 | for byteorder in '', '@': |
| 169 | signed_size = struct.calcsize(byteorder + format_pair[0]) |
| 170 | unsigned_size = struct.calcsize(byteorder + format_pair[1]) |
| 171 | self.assertEqual(signed_size, unsigned_size) |
| 172 | |
| 173 | # bounds for native integer sizes |
| 174 | self.assertEqual(struct.calcsize('b'), 1) |
| 175 | self.assertLessEqual(2, struct.calcsize('h')) |
| 176 | self.assertLessEqual(4, struct.calcsize('l')) |
| 177 | self.assertLessEqual(struct.calcsize('h'), struct.calcsize('i')) |
| 178 | self.assertLessEqual(struct.calcsize('i'), struct.calcsize('l')) |
| 179 | self.assertLessEqual(8, struct.calcsize('q')) |
| 180 | self.assertLessEqual(struct.calcsize('l'), struct.calcsize('q')) |
| 181 | self.assertGreaterEqual(struct.calcsize('n'), struct.calcsize('i')) |
| 182 | self.assertGreaterEqual(struct.calcsize('n'), struct.calcsize('P')) |
| 183 | |
| 184 | def test_integers(self): |
| 185 | # Integer tests (bBhHiIlLqQnN). |
nothing calls this directly
no test coverage detected