(length, negative=kRandom)
| 47 | }""" |
| 48 | |
| 49 | def GenRandom(length, negative=kRandom): |
| 50 | if length == 0: return "0n" |
| 51 | s = [] |
| 52 | if negative == kYes or (negative == kRandom and (random.randint(0, 1) == 0)): |
| 53 | s.append("-") # 50% chance of negative. |
| 54 | s.append("0x") |
| 55 | s.append(kChars[random.randint(1, kBase - 1)]) # No leading zero. |
| 56 | for i in range(1, length): |
| 57 | s.append(kChars[random.randint(0, kBase - 1)]) |
| 58 | s.append("n") |
| 59 | return "".join(s) |
| 60 | |
| 61 | def Parse(x): |
| 62 | assert x[-1] == 'n', x |
no test coverage detected
searching dependent graphs…