aboutsummaryrefslogtreecommitdiff
path: root/MicSim/test
diff options
context:
space:
mode:
authorLoic GUEGAN <loic.guegan@yahoo.fr>2018-09-02 23:10:31 +0200
committerLoic GUEGAN <loic.guegan@yahoo.fr>2018-09-02 23:10:31 +0200
commit878c2b84a97411fad9179b1dfcc8ded75bc9ebe8 (patch)
treec04753b4a57aa9c99742bde9ceccb0804121c358 /MicSim/test
parentfbd6725e84fe27d1bc764efbec2142f710855b03 (diff)
Debug caretaker
Diffstat (limited to 'MicSim/test')
-rw-r--r--MicSim/test/test_caretaker.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/MicSim/test/test_caretaker.py b/MicSim/test/test_caretaker.py
index 5cc7483..e4b8dfb 100644
--- a/MicSim/test/test_caretaker.py
+++ b/MicSim/test/test_caretaker.py
@@ -16,13 +16,16 @@ class CaretakerTest(unittest.TestCase):
"""
Test if getitem operation follow Mic-1 rules
"""
- toWrite=randint(0,126) # Only 7 bit for signed MBR (2^7=127)
- self.c["MBR"]=-toWrite
- self.assertEqual(self.c["MBRU"],toWrite,"Tested with {}".format(-toWrite))
- self.assertEqual(self.c["MBR"],-(-((toWrite-1)^0xFF)),"Tested with {}".format(-toWrite))
- self.c["MBR"]=toWrite
- self.assertEqual(self.c["MBRU"],toWrite,"Tested with {}".format(toWrite))
- self.assertEqual(self.c["MBR"],toWrite,"Tested with {}".format(toWrite))
+ for toWrite in range(0,127):# Only 7 bit for signed MBR (2^7=127)
+ self.c["MBR"]=-toWrite
+ self.assertEqual(self.c["MBRU"],toWrite,"Tested with {}".format(-toWrite))
+ self.assertEqual(self.c["MBR"],-toWrite,"Tested with {}".format(-toWrite))
+
+ for toWrite in range(0,255):# Only 2^8 value for unsigned
+ self.c["MBR"]=toWrite
+ self.assertEqual(self.c["MBRU"],toWrite,"Tested with {}".format(toWrite))
+ if toWrite>127: # We enter in the zone of negative number at 127
+ self.assertEqual(self.c["MBR"],-(toWrite&0x7F),"Tested with {}".format(toWrite))
with self.assertRaises(KeyError): # Check it returns a KeyError
self.c["kjhkjhkoih"+str(randint(0,7698))]