def _testConstraintSetMethods(self): for _ in range(5): constr_a = ConstraintSet(0xF9B3, 0x207CE) if constr_a.isEmpty(): self.error("Constraint %s reported as empty." % constr_a) if constr_a.size() != 69148: self.error( "Constraint %s reported incorrect size; Expected = 69148, " "Actual = %d" % (constr_a, constr_a.size())) val = constr_a.chooseValue() if (val < 0xF9B3) or (val > 0x207CE): self.error("Chosen value %d lies outside of constraint %s" % (val, constr_a)) constr_a.addRange(0xE700, 0xE800) if str(constr_a) != "0xe700-0xe800,0xf9b3-0x207ce": self.error("Constraint %s didn't add range correctly." % constr_a) constr_a.subRange(0xE780, 0x1F390) if str(constr_a) != "0xe700-0xe77f,0x1f391-0x207ce": self.error("Constraint %s didn't subtract range correctly." % constr_a) constr_b = ConstraintSet(0x20800) constr_b.mergeConstraintSet(constr_a) if str(constr_b) != "0xe700-0xe77f,0x1f391-0x207ce,0x20800": self.error( "Constraint %s didn't merge with constraint %s correctly." % (constr_b, constr_a)) constr_c = ConstraintSet("0x20000-0x20600,0x20800") constr_c.applyConstraintSet(constr_a) if str(constr_c) != "0x20000-0x20600": self.error( "Constraint %s didn't apply constraint %s correctly." % (constr_c, constr_a)) constr_d = ConstraintSet(constr_a) if constr_d != constr_a: self.error( "Constraint %s didn't copy from constraint %s correctly." % (constr_d, constr_a))
def generate(self, **kargs): constr_a = ConstraintSet(0x23, 0x87) if constr_a.isEmpty(): self.error('Constraint %s reported as empty.' % constr_a) if constr_a.size() != 101: self.error( 'Constraint %s reported incorrect size; Expected = 101, Actual = %d' % (constr_a, constr_a.size())) val = constr_a.chooseValue() if (val < 0x23) or (val > 0x87): self.error('Chosen value %d lies outside of constraint %s' % (val, constr_a)) constr_a.addRange(0x35, 0x100) if str(constr_a) != '0x23-0x100': self.error('Constraint %s didn\'t add range correctly.' % constr_a) constr_a.subRange(0x4F, 0x6F) if str(constr_a) != '0x23-0x4e,0x70-0x100': self.error('Constraint %s didn\'t subtract range correctly.' % constr_a) constr_b = ConstraintSet('0x18, 0x22-0x5C') constr_b.mergeConstraintSet(constr_a) if str(constr_b) != '0x18,0x22-0x5c,0x70-0x100': self.error( 'Constraint %s didn\'t merge with constraint %s correctly.' % (constr_b, constr_a)) constr_c = ConstraintSet(0x5B) constr_c.applyConstraintSet(constr_a) if not constr_c.isEmpty(): self.error('Constraint %s didn\'t apply constraint %s correctly.' % (constr_c, constr_a)) constr_d = ConstraintSet(constr_a) if constr_d != constr_a: self.error( 'Constraint %s didn\'t copy from constraint %s correctly.' % (constr_d, constr_a))