程序代写代做代考 COM2001 2016-17 Semester 1 Assignment 2

COM2001 2016-17 Semester 1 Assignment 2
Testing your Enigma Simulation
I’m not supplying test data for assignment 2:
 In real life you can’t expect someone to provide the right answer for you
 You have to devise your own test cases.
 Organising the testing of your code is part of a programmer’s skill.
Here’s how you should proceed:
You design top-down, implement bottom-up and test as you go In this case the design is essentially given to you:
enigmaEncodeMessage calls enigmaEncode, which calls
encode, reverseEncode and whatever you’ve called the fns for the Reflector, Stecker and advancing the offsets – say reflect, stecker and advance
 You’ve already tested encode & reverseEncode in assignment 1 (presumably)
 It’s easy to test reflect, stecker and advance on their own.
 Then you can use these trusted fns to work out what enigmaEncode
should return for a given letter, rotors& offsets, in the steckered and
unsteckered cases. This gives you test data.
 once you’re happy with enigmaEncode it’s easy to devise test data for
enigmaEncodeMessage
Finally you perform ‘sanity checks’ based on what you know about how the programme should behave. In this case you know that Enigma encoding is reversible – if ABC encodes to XYZ then XYZ should encode to ABC.