Changeset 5843


Ignore:
Timestamp:
Oct 17, 2008, 9:12:51 AM (16 years ago)
Author:
rwilson
Message:

Added test to check index range checking.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/abstract_2d_finite_volumes/test_general_mesh.py

    r4839 r5843  
    292292       
    293293
     294    def test_assert_index_in_nodes(self):
     295        """test_assert_index_in_nodes -
     296
     297        Test that node indices in triangles are within nodes array.
     298
     299        """
     300       
     301        x0 = 314036.58727982
     302        y0 = 6224951.2960092
     303        geo = Geo_reference(56, x0, y0)
     304       
     305        a = [0.0, 0.0]
     306        b = [0.0, 2.0]
     307        c = [2.0, 0.0]
     308        d = [0.0, 4.0]
     309        e = [2.0, 2.0]
     310        f = [4.0, 0.0]
     311
     312        nodes = array([a, b, c, d, e, f])
     313
     314        nodes_absolute = geo.get_absolute(nodes)
     315       
     316        # max index is 5, use 5, expect success
     317        triangles = array([[1,5,2], [1,2,4], [4,2,5], [3,1,4]])
     318        General_mesh(nodes, triangles, geo_reference=geo)
     319       
     320        # max index is 5, use 6, expect assert failure
     321        triangles = array([[1,6,2], [1,2,4], [4,2,5], [3,1,4]])
     322        self.failUnlessRaises(AssertionError, General_mesh,
     323                              nodes, triangles, geo_reference=geo)
     324       
     325        # max index is 5, use 10, expect assert failure
     326        triangles = array([[1,10,2], [1,2,4], [4,2,5], [3,1,4]])
     327        self.failUnlessRaises(AssertionError, General_mesh,
     328                              nodes, triangles, geo_reference=geo)
     329       
     330
    294331
    295332#-------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.