Ejemplo n.º 1
0
 def setUp(self):
     random.seed()
     self.testobject = Chunk(
         random.randint(-sys.maxint - 1, sys.maxint - 1),
         random.randint(-sys.maxint - 1, sys.maxint - 1))
     try:
         chunk = Chunk("1", None)
     except Exception as e:
         pass
     else:
         self.fail("chunk constructor should fail on bad input ")
Ejemplo n.º 2
0
 def setUp(self):
     random.seed()
     self.testobject = Chunk(random.randint(-sys.maxint-1, sys.maxint - 1),random.randint(-sys.maxint -1, sys.maxint - 1))
     try:
         chunk = Chunk( "1", None )
     except Exception as e:
         pass
     else:
         self.fail("chunk constructor should fail on bad input ")
Ejemplo n.º 3
0
class ChunkTestCase(unittest.TestCase):
    """
    Chunk is a class that contains a single chunk of minecraft map data. Acts as a transport class between layers and filters
    - it should contain a square, chunk-sized array of blocks and data.
    - it should have valid integer values for cx and cz. 
    - When copied, none of its fields should affect the fields of the original chunk.
    """
    testobject = None  # this gets set in setUp, and tested in the subsequent tests. This allows subclassing of the tested object!

    def setUp(self):
        random.seed()
        self.testobject = Chunk(
            random.randint(-sys.maxint - 1, sys.maxint - 1),
            random.randint(-sys.maxint - 1, sys.maxint - 1))
        try:
            chunk = Chunk("1", None)
        except Exception as e:
            pass
        else:
            self.fail("chunk constructor should fail on bad input ")

    def test_valid_fields(self):
        validate_chunk_fields(self.testobject)

    def test_copy(self):
        chunkcopy = self.testobject.copy()
        validate_chunk_fields(chunkcopy)
        chunkcopy.cx += 1
        chunkcopy.cz += 1
        for rowix in xrange(CHUNK_WIDTH_IN_BLOCKS):
            for colix in xrange(CHUNK_WIDTH_IN_BLOCKS):
                for heightix in xrange(CHUNK_HEIGHT_IN_BLOCKS):
                    chunkcopy.blocks[rowix][colix][heightix] += 1
                    chunkcopy.data[rowix][colix][heightix] += 1
        for rowix in xrange(CHUNK_WIDTH_IN_BLOCKS):
            for colix in xrange(CHUNK_WIDTH_IN_BLOCKS):
                for heightix in xrange(CHUNK_HEIGHT_IN_BLOCKS):
                    self.assertNotEqual(
                        chunkcopy.blocks[rowix][colix][heightix],
                        self.testobject.blocks[rowix][colix][heightix])
                    self.assertNotEqual(
                        chunkcopy.data[rowix][colix][heightix],
                        self.testobject.data[rowix][colix][heightix])
Ejemplo n.º 4
0
class ChunkTestCase(unittest.TestCase):
    """
    Chunk is a class that contains a single chunk of minecraft map data. Acts as a transport class between layers and filters
    - it should contain a square, chunk-sized array of blocks and data.
    - it should have valid integer values for cx and cz. 
    - When copied, none of its fields should affect the fields of the original chunk.
    """
    testobject = None # this gets set in setUp, and tested in the subsequent tests. This allows subclassing of the tested object!
    def setUp(self):
        random.seed()
        self.testobject = Chunk(random.randint(-sys.maxint-1, sys.maxint - 1),random.randint(-sys.maxint -1, sys.maxint - 1))
        try:
            chunk = Chunk( "1", None )
        except Exception as e:
            pass
        else:
            self.fail("chunk constructor should fail on bad input ")
        
    
    def test_valid_fields(self):
        validate_chunk_fields(self.testobject)

    def test_copy(self):
        chunkcopy = self.testobject.copy()
        validate_chunk_fields(chunkcopy)
        chunkcopy.cx += 1
        chunkcopy.cz += 1
        for rowix in xrange(CHUNK_WIDTH_IN_BLOCKS):
            for colix in xrange(CHUNK_WIDTH_IN_BLOCKS):
                for heightix in xrange(CHUNK_HEIGHT_IN_BLOCKS):
                    chunkcopy.blocks[rowix][colix][heightix] += 1
                    chunkcopy.data[rowix][colix][heightix] += 1
        for rowix in xrange(CHUNK_WIDTH_IN_BLOCKS):
            for colix in xrange(CHUNK_WIDTH_IN_BLOCKS):
                for heightix in xrange(CHUNK_HEIGHT_IN_BLOCKS):
                    self.assertNotEqual(chunkcopy.blocks[rowix][colix][heightix], self.testobject.blocks[rowix][colix][heightix])
                    self.assertNotEqual(chunkcopy.data[rowix][colix][heightix], self.testobject.data[rowix][colix][heightix])