tm_test.c 1.5 KB

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