days_between_years.cpp 757 B

1234567891011121314151617181920212223242526272829303132
  1. #include<__vic/date_time.h>
  2. #include<iostream>
  3. #include<exception>
  4. #include<cassert>
  5. void run_tests()
  6. {
  7. assert(__vic::days_between_years(0,0) == 0);
  8. assert(!__vic::is_leap_year(2003));
  9. assert(__vic::days_between_years(2003, 2004) == 365);
  10. assert(__vic::days_between_years(2004, 2003) == -365);
  11. assert(__vic::is_leap_year(2012));
  12. assert(__vic::days_between_years(2012, 2013) == 366);
  13. assert(!__vic::is_leap_year(2013));
  14. assert(__vic::days_between_years(2012, 2014) == 366 + 365);
  15. assert(__vic::days_between_years(2012, 2019) == 365 * 7 + 2);
  16. }
  17. int main()
  18. {
  19. try
  20. {
  21. run_tests();
  22. return 0;
  23. }
  24. catch(const std::exception &ex)
  25. {
  26. std::cerr << ex.what() << '\n';
  27. }
  28. return 1;
  29. }