Advertisement
ksoltan

rotor-test.rkt

May 21st, 2015
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 4.01 KB | None | 0 0
  1. #lang racket
  2. (require rackunit)
  3. (require "rotor.rkt" "accessors.rkt")
  4.  
  5. (define rots (set-rotor-ground-settings (string->list "GUX") rIII rII rI))
  6. (define rots2 (set-rotor-ground-settings (string->list "XDR") rIII rII rI))
  7. (printf "~a\n~a\n~a\n\n" (car rots2) (cadr rots2) (caddr rots2))
  8. ;; check getting idx forward
  9. (check-equal? (get-idx-next-letter-forward (rotate rI) rII 4) 3)
  10. (check-equal? (get-idx-next-letter-forward rII rIII 4) 4)
  11. (check-equal? (get-idx-next-letter-forward (rotate (rotate rI)) rII 6) 4)
  12. (check-equal? (get-idx-next-letter-forward (rotate rI) (rotate rII) 4) 4)
  13. (check-equal? (get-idx-next-letter-forward (rotate (rotate rI)) (rotate rII) 6) 5)
  14. (check-equal? (get-idx-next-letter-forward rI (rotate (rotate rII)) 2) 4)
  15.  
  16. (check-equal? (get-idx-next-letter-forward a (rotate (car rots)) 1) 8)
  17. (check-equal? (get-idx-next-letter-forward (rotate (car rots)) (cadr rots) 16) 3)
  18.  
  19. ;; check getting idx backward
  20. (check-equal? (get-idx-next-letter-backward  rII (rotate rI) 5) 6)
  21. (check-equal? (get-idx-next-letter-backward rIII rII 19) 19)
  22. (check-equal? (get-idx-next-letter-backward rII (rotate (rotate rI)) 4) 6)
  23. (check-equal? (get-idx-next-letter-backward (rotate rII) (rotate rI)  15) 15)
  24. (check-equal? (get-idx-next-letter-backward (rotate rII) (rotate (rotate rI)) 19) 20)
  25. (check-equal? (get-idx-next-letter-backward (rotate (rotate rII)) rI 21) 19)
  26. (check-equal? (get-idx-next-letter-backward rB (rotate rI) 25) 26)
  27.  
  28. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  29. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  30.  
  31. (check-equal? (pass-through-rotor-forward (rotate rIII) 1) 4)
  32. (check-equal? (pass-through-rotor-forward rII 4 (rotate rIII)) 4)
  33. (check-equal? (pass-through-rotor-forward rI 4 rII) 6)
  34. (check-equal? (pass-through-ref rB rI 6) 19)
  35. (check-equal? (pass-through-rotor-backward rI 19 rB) 19)
  36. (check-equal? (pass-through-rotor-backward rII 19 rI) 5)
  37. (check-equal? (pass-through-rotor-backward (rotate rIII) 5 rII) 3)
  38.  
  39. (check-equal? (pass-through-rotor-forward (cadr rots) 16 (rotate (car rots))) 4)
  40. (check-equal? (pass-through-rotor-forward (caddr rots) 4 (cadr rots)) 4)
  41. (check-equal? (pass-through-rotor-forward (rotate (car rots)) 1) 16)
  42. (check-equal? (pass-through-ref rB (caddr rots) 4) 12)
  43. (check-equal? (pass-through-rotor-backward (caddr rots) 12 rB) 22)
  44. (check-equal? (pass-through-rotor-backward (cadr rots) 22 (caddr rots)) 5)
  45. (check-equal? (pass-through-rotor-backward (rotate (car rots)) 5 (cadr rots)) 9)
  46.  
  47. (check-equal? (pass-through (rotate rIII) rII rI rB (car (string->list "A"))) (car (string->list "B")))
  48. (check-equal? (pass-through (rotate (car rots)) (cadr rots) (caddr rots) rB (car (string->list "A")))
  49.               (car (string->list "B")))
  50.  
  51. (check-equal? (get-plug (list (string->list "SB")) (car (string->list "S"))) (car (string->list "B")))
  52. (check-equal? (get-plug (list (string->list "SB") (string->list "AD")) (car (string->list "D"))) (car (string->list "A")))
  53. (check-equal? (get-plug (list (string->list "SB") (string->list "AD")) (car (string->list "A"))) (car (string->list "D")))
  54. (check-equal? (get-plug (list (string->list "SB") (string->list "AD")) (car (string->list "S"))) (car (string->list "B")))
  55. (check-equal? (get-plug (list (string->list "SB") (string->list "AD")) (car (string->list "B"))) (car (string->list "S")))
  56.  
  57.  
  58. (check-equal? (get-plug (list (string->list "AB") (string->list "CD") (string->list "FK"))
  59.                         (car (string->list "A"))) (car (string->list "B")))
  60. (check-equal? (get-plug (list (string->list "AB") (string->list "CD") (string->list "FK"))
  61.                         (car (string->list "H"))) (car (string->list "H")))
  62. (check-equal? (get-plug (list (string->list "AB") (string->list "CD") (string->list "FK"))
  63.                         (car (string->list "B"))) (car (string->list "A")))
  64. (check-equal? (get-plug (list (string->list "AB") (string->list "CD") (string->list "FK"))
  65.                         (car (string->list "K"))) (car (string->list "F")))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement