Exemplo n.º 1
0
class TestMemory(unittest.TestCase):
    
    def setUp(self):
        self.memory = Memory()  
        for n in range(10):
            self.memory.put(n, "instruction" + str(n))

    def test_get_gets_instruction_from_specified_address(self):
        instruction = self.memory.get(1)
        self.assertEqual("instruction1", instruction , "Instruction not found in memory cell")    

    def test_put_adds_instruction_in_specified_address(self):
        self.memory.put(10, "ins")
        self.assertEqual("ins", self.memory.get(10), "Instruction not found in memory cell")    

    def test_memory_error(self):    
        with self.assertRaises(InvalidAddressException):
            self.memory.get(-1) 
Exemplo n.º 2
0
class TestMemory(unittest.TestCase):
    
    def setUp(self):
        self.memory = Memory()

    def test_put_adds_instruction_in_specified_address(self):
        self.memory.put(00000, "instruccion1")
        self.assertEqual("instruccion1", self.memory.get(00000), "Instruction not found in memory cell")    

    def test_get_gets_instruction_from_specified_address(self):
        instruction = self.memory.put(00000, "instruccion1")
        self.assertEqual("instruccion1", instruction, "Instruction not found in memory cell")    
Exemplo n.º 3
0
class TestMemory(unittest.TestCase):
    def setUp(self):
        self.memory = Memory()

    def test_put_adds_instruction_in_specified_address(self):
        self.memory.put(00000, "instruccion1")
        self.assertEqual("instruccion1", self.memory.get(00000),
                         "Instruction not found in memory cell")

    def test_get_gets_instruction_from_specified_address(self):
        instruction = self.memory.put(00000, "instruccion1")
        self.assertEqual("instruccion1", instruction,
                         "Instruction not found in memory cell")