()
| 9 | |
| 10 | @test("malloc and free") |
| 11 | def _(): |
| 12 | ptr = malloc(28) |
| 13 | assert ptr.freed is False |
| 14 | assert ptr.assigned is False |
| 15 | ptr <<= 1 |
| 16 | assert ptr.assigned is True |
| 17 | |
| 18 | with raises(InvalidSizeError): |
| 19 | ptr <<= "hello" |
| 20 | |
| 21 | free(ptr) |
| 22 | |
| 23 | with raises(FreedMemoryError): |
| 24 | print(~ptr) |
| 25 | |
| 26 | with raises(FreedMemoryError): |
| 27 | free(ptr) |
| 28 | |
| 29 | with raises(FreedMemoryError): |
| 30 | ptr.ensure_valid() |
| 31 | |
| 32 | assert ptr.freed is True |
| 33 | |
| 34 | |
| 35 | @test("calloc with enumerations") |