00001
00033 #include "linden_common.h"
00034 #include "lltut.h"
00035
00036 #include "lldate.h"
00037 #include "llframetimer.h"
00038
00039 namespace tut
00040 {
00041 struct httpdate_data
00042 {
00043 LLDate some_date;
00044 };
00045 typedef test_group<httpdate_data> httpdate_test;
00046 typedef httpdate_test::object httpdate_object;
00047 tut::httpdate_test httpdate("httpdate");
00048
00049 template<> template<>
00050 void httpdate_object::test<1>()
00051 {
00052 static std::string epoch_expected = "Thursday, 01 Jan 1970 00:00:00 GMT" ;
00053 ensure("Check Epoch in RFC 1123", ( epoch_expected == some_date.asRFC1123()));
00054 }
00055
00056 template<> template<>
00057 void httpdate_object::test<2>()
00058 {
00059 static std::string expected = "Wednesday, 18 Jul 2007 22:17:24 GMT" ;
00060 some_date = LLDate(1184797044.037586);
00061 ensure("Check some timestamp in RFC 1123", ( expected == some_date.asRFC1123()));
00062 }
00063
00064
00065 template<> template<>
00066 void httpdate_object::test<3>()
00067 {
00068
00069 time_t sometime;
00070 time(&sometime);
00071 some_date = LLDate((F64) sometime);
00072 struct tm result;
00073 char expected[255], *actual;
00074
00075 gmtime_r((time_t *)&sometime, &result);
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 strftime(expected, 255, "%A, %d %h %Y %H:%M:%S GMT", &result);
00088 actual = (char *) some_date.asRFC1123().c_str();
00089
00090 ensure("Current time in RFC 1123", (strcmp(expected, actual) == 0));
00091 }
00092 }