## Creature Project ## CSC323: Group 1: Nora, Terian, Josh, and Jordan ## 4/7/10 ## testclass.py: Contains general unit tests. from localworld import * class WorldTests: """Unit Tests for LocalWorld""" def __init__(self): pass def initTests(self): """Initialization tests for LocalWorld""" #Smoke Tests and Tests of various default creatures test1 = LocalWorld(5,7, "Nora") test2 = LocalWorld(1,1,"Dead") test3 = LocalWorld(4,4,"Simple") test4 = LocalWorld(3,2,"Bob") print (test1, test2, test3, test4) print("Expected weird stuff:") #Test of Negative and Boundary and Large Values test5 = LocalWorld(0,0,"Simple") test6 = LocalWorld(-3,4, "Dead") test7 = LocalWorld(-3,-3, "SamR") test8 = LocalWorld(10, 20000, "C") print (test5, test6, test7) #smoke test- square, rectangle, default, simple, none, dead #null values, negative/boundary valuest def creTests(self): """Tests get and set creature methods of LocalWorld""" world = LocalWorld(10, 24,"T") #please check the exception in setCreature bounds checking. print("Expected bounds error:") world.setCreature(489474,450594, "F") world.setCreature(4,5,"A") world.setCreature(0,0,"B") world.setCreature(9,23,"C") world.setCreature(9,5,"D") world.setCreature(3,23,"E") print("Expect to see: A B C D E") print(world.getCreature(4,5)) print(world.getCreature(0,0)) print(world.getCreature(9,23)) print(world.getCreature(9,5)) print(world.getCreature(3,23)) ## CHECK BOUNDS ERROR PRINTING PROBLEM print("Expected bounds error:") print(world.getCreature(43907,3848)) #setCreature:off grid on grid- edge, middle default, simple #creature getCreature: off grid, on gri default and changed def runTests(self): """Runs unit tests for all of LocalWorld's methods""" print("Running initalization tests...") WorldTests().initTests() print("Initalization test finished") print("Running creatures tests...") WorldTests().creTests() print("All Tests finished.") w = WorldTests() w.runTests() """Test plan: Unit Tests for Local World: toString and fromString: has correct form- can be recreated with to/from methods __expandworld: expand by negative, 0, square, rectangle. getCreature from these points Unit Tests for each method: Unit Tests for Creature: Unit Tests for Species: """