tm_test.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. *******************************************************************************
  3. \file tm_test.c
  4. \brief Tests for time management
  5. \project bee2/test
  6. \author (C) Sergey Agievich [agievich@{bsu.by|gmail.com}]
  7. \created 2014.10.13
  8. \version 2022.07.12
  9. \license This program is released under the GNU General Public License
  10. version 3. See Copyright Notices in bee2/info.h.
  11. *******************************************************************************
  12. */
  13. #include <stdio.h>
  14. #include <bee2/core/mt.h>
  15. #include <bee2/core/tm.h>
  16. /*
  17. *******************************************************************************
  18. Тестирование
  19. *******************************************************************************
  20. */
  21. bool_t tmTest()
  22. {
  23. // время
  24. {
  25. tm_ticks_t freq = tmFreq();
  26. tm_ticks_t ticks = tmTicks();
  27. mtSleep(1000);
  28. ticks = tmTicks() - ticks;
  29. printf("tm::timer: freq = %u vs ticks_per_sec = %u\n",
  30. (u32)freq, (u32)ticks);
  31. printf("tm::timer: test_speed = %u vs freq = %u\n",
  32. (u32)tmSpeed(10, 10), (u32)freq);
  33. printf("tm::timer: time = %u vs test_time_round = %u\n",
  34. (u32)tmTime(), (u32)tmTimeRound(0, 1));
  35. }
  36. // дата
  37. {
  38. size_t y;
  39. size_t m;
  40. size_t d;
  41. octet date[6];
  42. if (!tmDate(&y, &m, &d) || !tmDate2(date) ||
  43. !tmDateIsValid(y, m, d) || !tmDateIsValid2(date) ||
  44. tmDateIsValid(1582, 12, 31) || tmDateIsValid(1583, 9, 31) ||
  45. !tmDateIsValid(1600, 2, 29) || tmDateIsValid(1900, 2, 29))
  46. return FALSE;
  47. printf("tm::date: %04u-%02u-%02u\n",
  48. (unsigned)y, (unsigned)m, (unsigned)d);
  49. }
  50. // все нормально
  51. return TRUE;
  52. }