def testcase_00(self):
     a = AndGate(2)
     self.assertEqual(False, a.get_input(0),
                      "Class AndGate Testcase 0 failed.")
     self.assertEqual(False, a.get_input(1),
                      "Class AndGate Testcase 0 failed.")
     self.assertEqual(False, a.get_output(0),
                      "Class AndGate Testcase 0 failed.")
 def testcase_03(self):
     a = AndGate(2)
     a.set_input(0, True)
     a.set_input(1, False)
     a.execute()
     self.assertEqual(False, a.get_output(0),
                      "Class AndGate Testcase 3 failed.")
Exemple #3
0
 def assert_test_case(self, in0, in1, out, test_id):
     a = AndGate()
     a.set_inputs([in0, in1])
     a.execute()
     if out:
         self.assertTrue(a.get_output_at(0),
                         "Class AndGate: " + test_id + " failed")
     else:
         self.assertFalse(a.get_output_at(0),
                          "Class AndGate: " + test_id + " failed")
 def testcase_05(self):
     a = AndGate(3)
     testdatas = [[False, False, False, False], [False, False, True, False],
                  [False, True, False, False], [False, True, True, False],
                  [True, False, False, False], [True, False, True, False],
                  [True, True, False, False], [True, True, True, True]]
     for testdata in testdatas:
         for i in range(0, 3):
             a.set_input(i, testdata[i])
         a.execute()
         self.assertEqual(
             testdata[3], a.get_output(0),
             "Class AndGate Testcase 5 failed: " + testdata.__str__())
Exemple #5
0
    def testcase_01(self):
        a = AndGate()

        a.input0 = False

        a.input1 = False

        a.execute()

        self.assertFalse(a.output, "AndGate, Testcase 01 failed!")
Exemple #6
0
    def testcase_04(self):
        a = AndGate()

        a.input0 = True

        a.input1 = True

        a.execute()

        self.assertTrue(a.output, "AndGate, Testcase 04 failed!")
Exemple #7
0
    def execute(self):

        #Workaround: Die LogFunc-Klasse ruft bei __init__ die execute-Methode auf um manche Logikgatter zu initialisieren. Zu dem Zeipunkt sind noch keine Input-Werte gesetzt
        if len(self._Inputs) == 0:
            return

        sum = XOrGate()
        sum.set_inputs([self.get_input_at(0), self.get_input_at(1)])
        sum.execute()

        carry = AndGate()
        carry.set_inputs([self.get_input_at(0), self.get_input_at(1)])
        carry.execute()

        sum_result = sum.get_output_at(0)
        carry_result = carry.get_output_at(0)

        self._Outputs = [carry_result, sum_result]
 def testcase_01(self):
     a = AndGate()
     a.Input0 = False
     a.Input1 = False
     a.execute()
     self.assertFalse(a.Output, "Class AndGate Testcase 1 failed.")                     # so
 def testcase_04(self):
     a = AndGate()
     a.Input0 = True
     a.Input1 = True
     a.execute()
     self.assertEqual(True, a.Output, "Class AndGate Testcase 4 failed.")
 def testcase_03(self):
     a = AndGate()
     a.Input0 = True
     a.Input1 = False
     a.execute()
     self.assertEqual(False, a.Output, "Class AndGate Testcase 3 failed.")
 def testcase_00(self):
     a = AndGate()
     self.assertEqual(False, a.Input0, "Class AndGate Testcase 0 failed.")
     self.assertEqual(False, a.Input1, "Class AndGate Testcase 0 failed.")
     self.assertEqual(False, a.Output, "Class AndGate Testcase 0 failed.")
Exemple #12
0
 def testcase_01(self):
     a = AndGate()
     a.setInput0(False)
     a.setInput1(False)
     a.execute()
     self.assertFalse(a._Output, "Class AndGate: TestCase01 failed")
Exemple #13
0
 def testcase_04(self):
     a = AndGate()
     a.setInput0(True)
     a.setInput1(True)
     a.execute()
     self.assertTrue(a._Output, "Class AndGate: TestCase04 failed")
Exemple #14
0
 def testcase_04(self):
     a = AndGate()
     a.Input0 = True
     a.Input1 = True
     a.execute()
     self.assertTrue(a.Output, "Class AndGate: TestCase04 failed")
Exemple #15
0
 def testcase_03(self):
     a = AndGate()
     a.Input0 = False
     a.Input1 = True
     a.execute()
     self.assertFalse(a.Output, "Class AndGate: TestCase03 failed")