diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-05-18 00:06:37 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-05-18 00:06:37 +0100 |
commit | fcdca58617caf6a8c034a91588d6abb399be6b57 (patch) | |
tree | ad77f8e954a2ed05cd26237a7c665f3adc82b9fe /test/helpers.h | |
download | mygrate-fcdca58617caf6a8c034a91588d6abb399be6b57.tar.bz2 mygrate-fcdca58617caf6a8c034a91588d6abb399be6b57.tar.xz mygrate-fcdca58617caf6a8c034a91588d6abb399be6b57.zip |
Initial commit, still lots to do!
Diffstat (limited to 'test/helpers.h')
-rw-r--r-- | test/helpers.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/helpers.h b/test/helpers.h new file mode 100644 index 0000000..107eda5 --- /dev/null +++ b/test/helpers.h @@ -0,0 +1,44 @@ +#ifndef MYGRATE_TEST_HELPERS_H +#define MYGRATE_TEST_HELPERS_H + +#include <concepts> +#include <cstddef> +#include <ctime> + +inline constexpr std::byte operator""_b(const unsigned long long hex) +{ + return std::byte(hex); +} + +inline constexpr bool +operator==(const struct tm & a, const struct tm & b) +{ + return (a.tm_year == b.tm_year) && (a.tm_mon == b.tm_mon) && (a.tm_mday == b.tm_mday) && (a.tm_hour == b.tm_hour) + && (a.tm_min == b.tm_min) && (a.tm_sec == b.tm_sec); +} + +namespace std { + template<integral T> + inline constexpr bool + operator!=(const byte b, const T i) + { + return to_integer<T>(b) != i; + } +} + +inline struct tm +make_tm(int year, int mon, int day, int hr, int min, int sec) +{ + struct tm tm { + }; + tm.tm_year = year - 1900; + tm.tm_mon = mon - 1; + tm.tm_mday = day; + tm.tm_hour = hr; + tm.tm_min = min; + tm.tm_sec = sec; + mktime(&tm); + return tm; +} + +#endif |