aboutsummaryrefslogtreecommitdiffstats
path: root/libtests/qutil.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2021-02-09 20:56:35 +0100
committerJay Berkenbilt <ejb@ql.org>2021-02-09 23:50:24 +0100
commitbf0e6eb3022bf2fde5623a0a3d151c07f5e82945 (patch)
tree72a4c73a318fd7020ad1a01ffb2469b0f2b7d62e /libtests/qutil.cc
parentbfbeec5497c04e58e25fa207773ece1d29b67000 (diff)
downloadqpdf-bf0e6eb3022bf2fde5623a0a3d151c07f5e82945.tar.zst
Add QUtil methods for dealing with PDF timestamp strings
Diffstat (limited to 'libtests/qutil.cc')
-rw-r--r--libtests/qutil.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/libtests/qutil.cc b/libtests/qutil.cc
index 94454374..b67b7580 100644
--- a/libtests/qutil.cc
+++ b/libtests/qutil.cc
@@ -581,6 +581,27 @@ void rename_delete_test()
assert_no_file("old\xcf\x80.~tmp");
}
+void timestamp_test()
+{
+ auto check = [](QUtil::QPDFTime const& t) {
+ std::string pdf = QUtil::qpdf_time_to_pdf_time(t);
+ std::cout << pdf << std::endl;
+ QUtil::QPDFTime t2;
+ assert(QUtil::pdf_time_to_qpdf_time(pdf, &t2));
+ assert(QUtil::qpdf_time_to_pdf_time(t2) == pdf);
+ };
+ check(QUtil::QPDFTime(2021, 2, 9, 14, 49, 25, 300));
+ check(QUtil::QPDFTime(2021, 2, 10, 1, 19, 25, -330));
+ check(QUtil::QPDFTime(2021, 2, 9, 19, 19, 25, 0));
+ assert(! QUtil::pdf_time_to_qpdf_time("potato"));
+ // Round trip on the current time without actually printing it.
+ // Manual testing was done to ensure that we are actually getting
+ // back the current time in various timezones.
+ assert(QUtil::pdf_time_to_qpdf_time(
+ QUtil::qpdf_time_to_pdf_time(
+ QUtil::get_current_qpdf_time())));
+}
+
int main(int argc, char* argv[])
{
try
@@ -611,6 +632,8 @@ int main(int argc, char* argv[])
hex_encode_decode_test();
std::cout << "---- rename/delete" << std::endl;
rename_delete_test();
+ std::cout << "---- timestamp" << std::endl;
+ timestamp_test();
}
catch (std::exception& e)
{