示例#1
0
    def testSideShortStr_withRotation(self):
        side = Side("bob", self.makeEdgeDict())
        self.assertEqualsStripped("bob (rot=)", side.shortStr())

        side = side.rotated(ROT.CLOCKW)
        self.assertEqualsStripped("bob (rot=-90)", side.shortStr())

        side = side.rotated(ROT.CLOCKW)
        self.assertEqualsStripped("bob (rot=180)", side.shortStr())
示例#2
0
    def testEdgeRotation_cw(self):
        side = Side.parse("actual","""
XX    
 oooo 
 ooooX
 oooo 
 oooo 
 X X X
""".splitlines(), 6)
        rotated = side.rotated(ROT.CLOCKW)
        expected = Side.parse("expected", """
     X
XooooX
 oooo 
Xoooo 
 oooo 
X  X  
""".splitlines(), 6)
        for d in DIR.ALL:
            self.assertEquals(str(expected.getEdge(d)), str(rotated.getEdge(d)), 
                "Direction %s: %s != %s (expected)"%(d, rotated.getEdge(d), expected.getEdge(d),))
示例#3
0
 def testHorizontalRuleMatch_ccw_right(self):
     leftside = Side("left", self.makeEdgeDict(Edge("X  XXX", DIR.RIGHT)))
     rightside = Side("right", self.makeEdgeDict(Edge("   XX ", DIR.TOP)))
     rule = HorizontalRule('A', ROT.NONE, 'B', ROT.FROM_CODE['-'])
     check = rule.check(Arrangement([leftside, rightside]))
     if not check: dump(leftside, rightside, leftside.getEdge(DIR.RIGHT), rightside.getEdge(DIR.TOP))
     self.assertTrue(check)
示例#4
0
 def testHorizontalRuleMatch_cw_left(self):
     leftside = Side("left", self.makeEdgeDict(Edge("X  XXX", DIR.TOP)))
     rightside = Side("right", self.makeEdgeDict(Edge(" XX   ", DIR.LEFT)))
     rule = HorizontalRule('A', ROT.FROM_CODE['+'], 'B', ROT.NONE)
     check = rule.check(Arrangement([leftside, rightside]))
     self.assertTrue(check)
示例#5
0
 def testHorizontalRuleMatch_noRotation(self):
     leftside = Side("left", self.makeEdgeDict(Edge("X  XXX", DIR.RIGHT)))
     rightside = Side("right", self.makeEdgeDict(Edge(" XX   ", DIR.LEFT)))
     rule = HorizontalRule('A', ROT.NONE, 'B', ROT.NONE)
     check = rule.check(Arrangement([leftside, rightside]))
     self.assertTrue(check)
示例#6
0
 def testVerticalRuleMatch_noRotation(self):
     topside = Side("top", self.makeEdgeDict(Edge("X  XXX", DIR.BOTTOM)))
     bottomside = Side("bottom", self.makeEdgeDict(Edge(" XX   ", DIR.TOP)))
     rule = VerticalRule('A', 'B')
     check = rule.check(Arrangement([topside, bottomside]))
     self.assertTrue(check)