Changeset 3022


Ignore:
Timestamp:
May 30, 2006, 4:26:26 PM (18 years ago)
Author:
steve
Message:

Slight problem with triangle test, had to change import command for windows

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/triangle/test_triangmodule.py

    r3020 r3022  
    55
    66import unittest
    7 import triang
     7from triangle import triang
    88
    99
     
    1111    def setUp(self):
    1212        pass
    13        
     13
    1414    def tearDown(self):
    1515        pass
    16  
     16
    1717    def testrectangle(self):
    1818
     
    4646                                                      (3.0, 0.0), (3.0, 10.0)],
    4747                        ' is wrong!')
    48        
     48
    4949        #print "data['generatedtriangleneighborlist']",
    50         #data['generatedtriangleneighborlist'] 
     50        #data['generatedtriangleneighborlist']
    5151        self.failUnless(data['generatedtriangleneighborlist'] ==[(-1, 1, -1),
    5252                                                                 (-1, 0, -1)],
    5353                        'generatedtriangleneighborlist is wrong!')
    5454
    55        
     55
    5656    def testrectangleII(self):
    5757
     
    7070        data = triang.genMesh(points,seglist,holelist,regionlist,
    7171                              pointattlist,segattlist,trilist, mode)
    72        
     72
    7373        self.failUnless(data['generatedtrianglelist'] ==[(1, 0, 2), (2, 3, 1)],
    7474                        'trianglelist is wrong!')
     
    7979                                                      (3.0, 0.0), (3.0, 10.0)],
    8080                        ' is wrong!')
    81    
     81
    8282    def testsegmarker(self):
    8383
     
    9696        data = triang.genMesh(points,seglist,holelist,regionlist,
    9797                              pointattlist,segattlist,trilist, mode)
    98        
     98
    9999        self.failUnless(data['generatedtrianglelist'] ==[(1, 0, 2), (2, 3, 1)],
    100100                        'trianglelist is wrong!')
     
    107107        self.failUnless(data['generatedsegmentmarkerlist'] ==[1,2,3,4],
    108108                        ' is wrong!')
    109              
     109
    110110    def testbad_region(self):
    111111
     
    125125                                  regionlist,pointattlist,segattlist,
    126126                                  trilist, mode)
    127            
     127
    128128        except TypeError:
    129129            pass
     
    131131            self.failUnless(0 ==1,
    132132                        'bad region list did not raise error!')
    133      
     133
    134134    def testregion_with_maxarea(self):
    135135
     
    147147        data = triang.genMesh(points,seglist,holelist,regionlist,
    148148                              pointattlist,segattlist, trilist, mode)
    149        
     149
    150150        self.failUnless(len(data['generatedtrianglelist']) == 2,
    151151                        'testregion_with_maxarea 1: # of tris is wrong!')
    152         ## Another test case   
     152        ## Another test case
    153153        regionlist = [(3,1,1.0),(1,3,1.0,8.0)]
    154154        mode = "Qzp21na36a"
     
    163163        # causing the different results, and we are treating
    164164        # triangle as a back box.
    165        
     165
    166166        self.failUnless(len(data['generatedtrianglelist']) >= 6,
    167167                        'testregion_with_maxarea 2: # of tris is wrong!')
    168         ## Another test case   
     168        ## Another test case
    169169        regionlist = [(3,1,1.0,8.0),(1,3,1.0,8.0)]
    170170        mode = "Qzpna36a"
     
    176176        self.failUnless(len(data['generatedtrianglelist']) >= 8,
    177177                        'testregion_with_maxarea 3: # of tris is wrong!')
    178                  
    179         ## Another test case   
     178
     179        ## Another test case
    180180        regionlist = [(3,1,1.0),(1,3,1.0,8.0)]
    181181        mode = "Qzpna8a"
     
    185185        # On unix this returns a 10 triangle result.
    186186        # Windows returns a 8 triangle result.
    187        
     187
    188188        self.failUnless(len(data['generatedtrianglelist']) >= 8,
    189189                        'testregion_with_maxarea 4: # of tris is wrong!')
    190                  
     190
    191191    def testbad_point(self):
    192192
     
    203203            data = triang.genMesh(points,seglist,holelist,regionlist,
    204204                                  pointattlist,segattlist, trilist, mode)
    205            
     205
    206206        except TypeError:
    207207            pass
     
    209209            self.failUnless(0 ==1,
    210210                        'bad point list did not raise error!')
    211      
     211
    212212    def testbad_hole(self):
    213213
     
    224224            data = triang.genMesh(points,seglist,holelist,regionlist,
    225225                                  pointattlist,segattlist, trilist, mode)
    226            
     226
    227227        except TypeError:
    228228            pass
     
    230230            self.failUnless(0 ==1,
    231231                        'bad hole list did not raise error!')
    232      
     232
    233233    def testbad_segment(self):
    234234
     
    245245            data = triang.genMesh(points,seglist,holelist,regionlist,
    246246                                  pointattlist,segattlist, trilist, mode)
    247            
     247
    248248        except TypeError:
    249249            pass
     
    251251            self.failUnless(0 ==1,
    252252                        'bad segment list did not raise error!')
    253      
     253
    254254    def testbad_segattlist(self):
    255255
     
    266266            data = triang.genMesh(points,seglist,holelist,regionlist,
    267267                                  pointattlist,segattlist, trilist, mode)
    268            
     268
    269269            self.failUnless(data['trianglelist'] ==[(1, 0, 2), (2, 3, 1)],
    270270                        'trianglelist is wrong!')
     
    274274            self.failUnless(0 ==1,
    275275                        'bad segment attribute list did not raise error!')
    276            
     276
    277277    def testrectangle_regions(self):
    278278
     
    294294        data = triang.genMesh(points,seglist,holelist,regionlist,
    295295                              pointattlist,segattlist, trilist, mode)
    296            
     296
    297297        self.failUnless(data['generatedtriangleattributelist'] ==[[77.0], [77.0], [77.0], [77.0]],
    298298                        'triangleattributelist is wrong!')
    299        
    300      
     299
     300
    301301    def test_lone_verts(self):
    302302
     
    328328                        'lonepointlist is wrong!')
    329329        #print "", data['lonepointlist']
    330    
     330
    331331    def test_lone_vertsII(self):
    332332
     
    338338        points = [(0.0,0.0),(0.0,0.0),(0.0,10.0),(0.0,10.0),(10.0,10.0),
    339339                  (10.0,10.0),(0.0,10.0),(10.0,0.0)]
    340        
     340
    341341        pointattlist = []
    342342        for point in points:
    343343            pointattlist.append([])
    344         seglist = [(0,1),(1,2),(2,3),(3,4),(4,5),(5,7),(7,0)]       
     344        seglist = [(0,1),(1,2),(2,3),(3,4),(4,5),(5,7),(7,0)]
    345345        segattlist = []
    346346        for seg in seglist:
     
    374374        points = [(0.0,0.0),(0.0,0.0),(0.0,10.0),(0.0,10.0),(10.0,10.0),
    375375                  (10.0,10.0),(0.0,10.0),(10.0,0.0)]
    376        
     376
    377377        pointattlist = []
    378378        for point in points:
    379379            pointattlist.append([])
    380         seglist = []       
     380        seglist = []
    381381        segattlist = []
    382382        for seg in seglist:
     
    386386        data = triang.genMesh(points,seglist,holelist,regionlist,
    387387                              pointattlist,segattlist,trilist, mode)
    388        
     388
    389389        self.failUnless(data['lonepointlist'] ==[0,1,2,3,4,5,6,7],
    390390                        'lonepointlist is wrong!')
Note: See TracChangeset for help on using the changeset viewer.