test_PointerEvalAnalogToDigitNew.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #include <unity.h>
  2. #include <ClassFlowCNNGeneral.h>
  3. class UnderTestCNNGeneral : public ClassFlowCNNGeneral {
  4. public:
  5. UnderTestCNNGeneral( ClassFlowAlignment *_flowalign, t_CNNType _cnntype) :
  6. ClassFlowCNNGeneral(_flowalign, _cnntype) {};
  7. using ClassFlowCNNGeneral::PointerEvalAnalogToDigitNew;
  8. };
  9. /**
  10. * @brief
  11. *
  12. * Transition = x.8 - x.2 here no transition in the test cases.
  13. * Offset = dig=x.n, ana= n.y: no offset, because both "n" are the same
  14. */
  15. void test_analogToDigit_Standard() {
  16. UnderTestCNNGeneral* undertest = new UnderTestCNNGeneral(nullptr, Digit100);
  17. // 4.8 is a "hanging" 5, i.e. it has not jumped over to 5.0.
  18. // A "hanging digit" should still be rounded from Transition.
  19. // Transition = yes
  20. // Offset = no
  21. TEST_ASSERT_EQUAL_INT(5, undertest->PointerEvalAnalogToDigitNew(4.8, 8.0, 8, 9.2));
  22. // https://github.com/jomjol/AI-on-the-edge-device/issues/921#issue-1344032217
  23. // Default: dig=9.6, ana=6.8 => erg=9
  24. // Transition = no
  25. // Offset = no
  26. TEST_ASSERT_EQUAL_INT(9, undertest->PointerEvalAnalogToDigitNew( 9.6, 6.8, 6, 9.2));
  27. // https://github.com/jomjol/AI-on-the-edge-device/issues/921#issuecomment-1220365920
  28. // Default: dig=4.6, ana=6.2 => erg=4
  29. // Transition = no
  30. // Offset = no
  31. TEST_ASSERT_EQUAL_INT(4, undertest->PointerEvalAnalogToDigitNew( 4.6, 6.2, 6, 9.2));
  32. // https://github.com/jomjol/AI-on-the-edge-device/issues/1143#issuecomment-1274434805
  33. // Hanging digit ()
  34. // Default: dig=6.8, ana=8.6 => erg=7
  35. // Transition = no
  36. // Offset = no
  37. TEST_ASSERT_EQUAL_INT(7, undertest->PointerEvalAnalogToDigitNew( 6.8, 8.6, 6, 9.2));
  38. // https://github.com/jomjol/AI-on-the-edge-device/issues/1143#issuecomment-1274434805
  39. // Also hanging digit () with small pointer after 0 pass.
  40. // Default: dig=6.8, ana=1.0 => erg=7
  41. // Transition = no
  42. // Offset = no
  43. TEST_ASSERT_EQUAL_INT(7, undertest->PointerEvalAnalogToDigitNew( 6.8, 1.0, 1, 9.2));
  44. }
  45. void test_analogToDigit_Transition() {
  46. UnderTestCNNGeneral* undertest = new UnderTestCNNGeneral(nullptr, Digit100);
  47. // https://github.com/jomjol/AI-on-the-edge-device/issues/921#issuecomment-1222672175
  48. // Default: dig=3.9, ana=9.7 => erg=3
  49. // Transition = yes
  50. // Zero crossing = no
  51. // Offset = no
  52. TEST_ASSERT_EQUAL_INT(3, undertest->PointerEvalAnalogToDigitNew( 3.9, 9.7, 9, 9.2));
  53. // without reference
  54. // Default: dig=4.0, ana=9.1 => erg=4
  55. // Transition = yes
  56. // Zero crossing = no
  57. // Offset = no
  58. // Special feature: Digit has not yet started at analogue 9.1
  59. TEST_ASSERT_EQUAL_INT(4, undertest->PointerEvalAnalogToDigitNew( 4.0, 9.1, 9, 9.2));
  60. // without reference
  61. // Default: dig=9.8, ana=0.1, ana_2=9.9 => erg=9
  62. // transition = yes
  63. // Zero crossing = no
  64. // Offset = no
  65. // Special feature: analogue is set back to 9 by previous analogue
  66. TEST_ASSERT_EQUAL_INT(9, undertest->PointerEvalAnalogToDigitNew( 9.8, 0.1, 9, 9.2));
  67. // https://github.com/jomjol/AI-on-the-edge-device/issues/1110#issuecomment-1277425333
  68. // Default: dig=5.9, ana=9.4 => erg=9
  69. // Transition = yes
  70. // Zero crossing = no
  71. // Offset = no
  72. // Special feature:
  73. TEST_ASSERT_EQUAL_INT(5, undertest->PointerEvalAnalogToDigitNew( 5.9, 9.4, 9, 9.2));
  74. // https://github.com/jomjol/AI-on-the-edge-device/issues/1110#issuecomment-1282168030
  75. // Default: dig=1.8, ana=7.8 => erg=9
  76. // Transition = yes
  77. // Zero crossing = no
  78. // Offset = no
  79. // Special feature: Digit runs with analogue. Therefore 1.8 (vs. 7.8)
  80. TEST_ASSERT_EQUAL_INT(1, undertest->PointerEvalAnalogToDigitNew( 1.8, 7.8, 7, 7.7));
  81. }