Guest User

BRL-CAD combination test case

a guest
Mar 8th, 2014
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.74 KB | None | 0 0
  1. import unittest
  2.  
  3. from brlcad.primitives.combination import union, intersect, subtract, negate, xor, LeafNode
  4.  
  5.  
  6. class CombinationTestCase(unittest.TestCase):
  7.     def test_union(self):
  8.         self.assertEqual(
  9.             "u[1, 2, 3, 4]",
  10.             str(union("1", "2", "3", "4")),
  11.         )
  12.  
  13.     def test_intersect(self):
  14.         self.assertEqual(
  15.             "n[1, 2, 3]",
  16.             str(intersect("1", "2", LeafNode("3"))),
  17.         )
  18.  
  19.     def test_subtract(self):
  20.         self.assertEqual(
  21.             "(1 - 2)",
  22.             str(subtract("1", "2")),
  23.         )
  24.  
  25.     def test_negate(self):
  26.         self.assertEqual(
  27.             "not(1)",
  28.             str(negate("1")),
  29.         )
  30.  
  31.     def test_xor(self):
  32.         self.assertEqual(
  33.             "^[1, 2, 3, 4]",
  34.             str(xor("1", "2", "3", "4")),
  35.         )
  36.  
  37.     def test_complex_condition(self):
  38.         self.assertEqual(
  39.             "u[3, 4, 1, 2, 5, 6, (not(7) - (8 - 9)), 10, 11, ^[15, 16, 12, 13, 14, n[19, 20, 21, 17, 18]]]",
  40.             str(
  41.                 union(
  42.                     "1", "2",
  43.                     union("3", "4"),
  44.                     union("5", "6"),
  45.                     subtract(
  46.                         negate("7"),
  47.                         subtract("8", "9")
  48.                     ),
  49.                     union("10"),
  50.                     "11",
  51.                     xor(
  52.                         "12", negate(negate("13")), "14",
  53.                         xor("15", "16"),
  54.                         intersect(
  55.                             "17", "18",
  56.                             intersect("19", "20", "21")
  57.                         )
  58.                     )
  59.                 )
  60.             )
  61.         )
  62.  
  63. if __name__ == "__main__":
  64.     unittest.main()
Advertisement
Add Comment
Please, Sign In to add comment