utils: update date/size parsing, factor out format

And update tests
This commit is contained in:
Dirk-Jan C. Binnema
2022-04-28 22:49:45 +03:00
parent 4b9c663ded
commit b7a30c0a36
6 changed files with 284 additions and 165 deletions

View File

@ -76,6 +76,25 @@ Err(const Error& err)
return tl::unexpected(err);
}
template<typename T>
static inline tl::unexpected<Error>
Err(const Result<T>& res)
{
return res.error();
}
template <typename T>
static inline Result<void>
Ok(const T& t)
{
if (t)
return Ok();
else
return Err(t.error());
}
/*
* convenience
@ -115,6 +134,9 @@ Err(Error::Code errcode, GError **err, const char* frm, ...)
return Err(errcode, std::move(str));
}
#define assert_valid_result(R) do { \
if(!R) { \
g_critical("error-result: %s", (R).error().what()); \