/usr/lib/Wt/test/wdatetime/WDateTimeTest.C is in witty-examples 3.1.10-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | /*
* Copyright (C) 2009 Emweb bvba, Kessel-Lo, Belgium.
*
* See the LICENSE file for terms of use.
*/
#include <boost/test/unit_test.hpp>
#include <Wt/WDate>
#include <Wt/WTime>
#include <Wt/WDateTime>
BOOST_AUTO_TEST_CASE( WDateTime_test_WDate )
{
Wt::WDate wd(2009, 10, 1);
BOOST_REQUIRE(wd.toString() == "Thu Oct 1 2009");
}
BOOST_AUTO_TEST_CASE( WDateTime_test_WTime )
{
Wt::WTime wt(12, 11, 31);
BOOST_REQUIRE(wt.toString() == "12:11:31");
}
BOOST_AUTO_TEST_CASE( WDateTime_test_WDateTime )
{
Wt::WDate wd(2009, 10, 1);
Wt::WTime wt(12, 11, 31, 499);
Wt::WDateTime wdt(wd, wt);
BOOST_REQUIRE(wdt.toString() == "Thu Oct 1 12:11:31 2009");
BOOST_REQUIRE(wdt.toString("ddd MMM d HH:mm:ss:zzz yyyy")
== "Thu Oct 1 12:11:31:499 2009");
BOOST_REQUIRE(wdt.time().msec() == 499);
Wt::WDateTime wdt2 = wdt.addMSecs(1600);
BOOST_REQUIRE(wdt.toString("ddd MMM d HH:mm:ss:zzz yyyy")
== "Thu Oct 1 12:11:31:499 2009");
BOOST_REQUIRE(wdt2.toString("ddd MMM d HH:mm:ss:zzz yyyy")
== "Thu Oct 1 12:11:33:099 2009");
Wt::WDateTime d = Wt::WDateTime::fromString("2000-06-14 13:05:12",
"yyyy-MM-dd hh:mm:ss");
BOOST_REQUIRE(d.date().year() == 2000);
BOOST_REQUIRE(d.date().month() == 6);
BOOST_REQUIRE(d.date().day() == 14);
BOOST_REQUIRE(d.time().hour() == 13);
BOOST_REQUIRE(d.time().minute() == 05);
BOOST_REQUIRE(d.time().second() == 12);
d = Wt::WDateTime::fromString("2000-06-14 13:05:12",
"yyyy-MM-dd HH:mm:ss");
BOOST_REQUIRE(d.date().year() == 2000);
BOOST_REQUIRE(d.date().month() == 6);
BOOST_REQUIRE(d.date().day() == 14);
BOOST_REQUIRE(d.time().hour() == 13);
BOOST_REQUIRE(d.time().minute() == 05);
BOOST_REQUIRE(d.time().second() == 12);
d = Wt::WDateTime::fromString("2000-06-14 1:05:12 AM",
"yyyy-MM-dd h:mm:ss AP");
BOOST_REQUIRE(d.date().year() == 2000);
BOOST_REQUIRE(d.date().month() == 6);
BOOST_REQUIRE(d.date().day() == 14);
BOOST_REQUIRE(d.time().hour() == 1);
BOOST_REQUIRE(d.time().minute() == 05);
BOOST_REQUIRE(d.time().second() == 12);
d = Wt::WDateTime::fromString("2000-06-14 1:05:12 pm",
"yyyy-MM-dd h:mm:ss ap");
BOOST_REQUIRE(d.date().year() == 2000);
BOOST_REQUIRE(d.date().month() == 6);
BOOST_REQUIRE(d.date().day() == 14);
BOOST_REQUIRE(d.time().hour() == 13);
BOOST_REQUIRE(d.time().minute() == 05);
BOOST_REQUIRE(d.time().second() == 12);
d = Wt::WDateTime::fromString("2000-06-14 1:05:12 PM",
"yyyy-MM-dd h:mm:ss a");
BOOST_REQUIRE(d.date().year() == 2000);
BOOST_REQUIRE(d.date().month() == 6);
BOOST_REQUIRE(d.date().day() == 14);
BOOST_REQUIRE(d.time().hour() == 13);
BOOST_REQUIRE(d.time().minute() == 05);
BOOST_REQUIRE(d.time().second() == 12);
d = Wt::WDateTime::fromString("2000-06-14 1:05:12 AM",
"yyyy-MM-dd h:mm:ss a");
BOOST_REQUIRE(d.date().year() == 2000);
BOOST_REQUIRE(d.date().month() == 6);
BOOST_REQUIRE(d.date().day() == 14);
BOOST_REQUIRE(d.time().hour() == 1);
BOOST_REQUIRE(d.time().minute() == 05);
BOOST_REQUIRE(d.time().second() == 12);
d = Wt::WDateTime::fromString("2000-06-14 1:05:12",
"yyyy-MM-dd h:mm:ss");
BOOST_REQUIRE(d.date().year() == 2000);
BOOST_REQUIRE(d.date().month() == 6);
BOOST_REQUIRE(d.date().day() == 14);
BOOST_REQUIRE(d.time().hour() == 1);
BOOST_REQUIRE(d.time().minute() == 05);
BOOST_REQUIRE(d.time().second() == 12);
d = Wt::WDateTime::fromString("2000-06-14 13:05:12",
"yyyy-MM-dd h:mm:ss");
BOOST_REQUIRE(d.date().year() == 2000);
BOOST_REQUIRE(d.date().month() == 6);
BOOST_REQUIRE(d.date().day() == 14);
BOOST_REQUIRE(d.time().hour() == 13);
BOOST_REQUIRE(d.time().minute() == 05);
BOOST_REQUIRE(d.time().second() == 12);
BOOST_REQUIRE(Wt::WDateTime::fromString(d.toString()) == d);
}
|