Commit 31b9e458 authored by Mickaël Turnel's avatar Mickaël Turnel Committed by Ghislain MARY
Browse files

Removed useless asserts

parent aaec49c6
......@@ -133,8 +133,8 @@ string Cpim::MessageIdHeader::asString () const {
class Cpim::DateTimeHeaderPrivate : public HeaderPrivate {
public:
tm timeT;
tm timeTOffset;
tm dateTime;
tm dateTimeOffset;
string signOffset;
};
......@@ -151,13 +151,13 @@ Cpim::DateTimeHeader::DateTimeHeader (const tm &time, const tm &timeOffset, cons
time_t Cpim::DateTimeHeader::getTime () const {
L_D();
tm result = d->timeT;
tm result = d->dateTime;
result.tm_year -= 1900;
result.tm_isdst = 0;
if (d->signOffset == "+") {
result.tm_hour += d->timeTOffset.tm_hour;
result.tm_min += d->timeTOffset.tm_min;
result.tm_hour += d->dateTimeOffset.tm_hour;
result.tm_min += d->dateTimeOffset.tm_min;
while (result.tm_min > 59) {
result.tm_hour++;
......@@ -165,8 +165,8 @@ time_t Cpim::DateTimeHeader::getTime () const {
}
}
else if (d->signOffset == "-") {
result.tm_hour -= d->timeTOffset.tm_hour;
result.tm_hour -= d->timeTOffset.tm_min;
result.tm_hour -= d->dateTimeOffset.tm_hour;
result.tm_hour -= d->dateTimeOffset.tm_min;
while (result.tm_min < 0) {
result.tm_hour--;
......@@ -181,8 +181,8 @@ bool Cpim::DateTimeHeader::setTime (const time_t time) {
L_D();
d->signOffset = "Z";
d->timeT = Utils::getTimeTAsTm(time);
d->timeT.tm_year += 1900;
d->dateTime = Utils::getTimeTAsTm(time);
d->dateTime.tm_year += 1900;
return true;
}
......@@ -190,8 +190,8 @@ bool Cpim::DateTimeHeader::setTime (const time_t time) {
bool Cpim::DateTimeHeader::setTime (const tm &time, const tm &timeOffset, const string &signOffset) {
L_D();
d->timeT = time;
d->timeTOffset = timeOffset;
d->dateTime = time;
d->dateTimeOffset = timeOffset;
d->signOffset = signOffset;
return true;
......@@ -201,17 +201,17 @@ string Cpim::DateTimeHeader::getValue () const {
L_D();
stringstream ss;
ss << setfill('0') << setw(4) << d->timeT.tm_year << "-"
<< setfill('0') << setw(2) << d->timeT.tm_mon << "-"
<< setfill('0') << setw(2) << d->timeT.tm_mday << "T"
<< setfill('0') << setw(2) << d->timeT.tm_hour << ":"
<< setfill('0') << setw(2) << d->timeT.tm_min << ":"
<< setfill('0') << setw(2) << d->timeT.tm_sec;
ss << setfill('0') << setw(4) << d->dateTime.tm_year << "-"
<< setfill('0') << setw(2) << d->dateTime.tm_mon << "-"
<< setfill('0') << setw(2) << d->dateTime.tm_mday << "T"
<< setfill('0') << setw(2) << d->dateTime.tm_hour << ":"
<< setfill('0') << setw(2) << d->dateTime.tm_min << ":"
<< setfill('0') << setw(2) << d->dateTime.tm_sec;
ss << d->signOffset;
if (d->signOffset != "Z")
ss << setfill('0') << setw(2) << d->timeTOffset.tm_hour << ":"
<< setfill('0') << setw(2) << d->timeTOffset.tm_min;
ss << setfill('0') << setw(2) << d->dateTimeOffset.tm_hour << ":"
<< setfill('0') << setw(2) << d->dateTimeOffset.tm_min;
return ss.str();
}
......@@ -222,12 +222,12 @@ string Cpim::DateTimeHeader::asString () const {
struct tm Cpim::DateTimeHeader::getTimeStruct () const {
L_D();
return d->timeT;
return d->dateTime;
}
struct tm Cpim::DateTimeHeader::getTimeOffset () const {
L_D();
return d->timeTOffset;
return d->dateTimeOffset;
}
string Cpim::DateTimeHeader::getSignOffset () const {
......
......@@ -149,38 +149,33 @@ static void build_message () {
// Set message headers.
Cpim::FromHeader fromHeader("im:piglet@100akerwood.com", "MR SANDERS");
//if (!BC_ASSERT_TRUE(fromHeader.setValue("MR SANDERS <im:piglet@100akerwood.com>"))) return;
Cpim::ToHeader toHeader("im:eeyore@100akerwood.com", "Depressed Donkey");
//if (!BC_ASSERT_TRUE(toHeader.setValue("Depressed Donkey <im:eeyore@100akerwood.com>"))) return;
//Cpim::DateTimeHeader dateTimeHeader; //TODO value
//if (!BC_ASSERT_TRUE(dateTimeHeader.setValue("2000-12-13T13:40:00-08:00"))) return;
tm dateTime = { 0 }, offset = { 0 };
dateTime.tm_year = 2000;
dateTime.tm_mon = 12;
dateTime.tm_mday = 13;
dateTime.tm_hour = 13;
dateTime.tm_min = 40;
offset.tm_hour = 8;
Cpim::DateTimeHeader dateTimeHeader(dateTime, offset, "-");
Cpim::SubjectHeader subjectHeader("the weather will be fine today");
//if (!BC_ASSERT_TRUE(subjectHeader.setValue("the weather will be fine today"))) return;
Cpim::SubjectHeader subjectWithLanguageHeader("beau temps prevu pour aujourd'hui", "fr");
//if (!BC_ASSERT_TRUE(subjectWithLanguageHeader.setValue("beau temps prevu pour aujourd'hui"))) return;
//if (!BC_ASSERT_TRUE(subjectWithLanguageHeader.setLanguage("fr"))) return;
Cpim::NsHeader nsHeader("mid:MessageFeatures@id.foo.com", "MyFeatures");
//if (!BC_ASSERT_TRUE(nsHeader.setValue("MyFeatures <mid:MessageFeatures@id.foo.com>"))) return;
Cpim::RequireHeader requireHeader("MyFeatures.VitalMessageOption");
//if (!BC_ASSERT_TRUE(requireHeader.setValue("MyFeatures.VitalMessageOption"))) return;
Cpim::GenericHeader vitalMessageHeader("MyFeatures.VitalMessageOption", "Confirmation-requested");
//if (!BC_ASSERT_TRUE(vitalMessageHeader.setName("MyFeatures.VitalMessageOption"))) return;
//if (!BC_ASSERT_TRUE(vitalMessageHeader.setValue("Confirmation-requested"))) return;
Cpim::GenericHeader wackyMessageHeader("MyFeatures.WackyMessageOption", "Use-silly-font");
//if (!BC_ASSERT_TRUE(wackyMessageHeader.setName("MyFeatures.WackyMessageOption"))) return;
//if (!BC_ASSERT_TRUE(wackyMessageHeader.setValue("Use-silly-font"))) return;
if (!BC_ASSERT_TRUE(message.addMessageHeader(fromHeader))) return;
if (!BC_ASSERT_TRUE(message.addMessageHeader(toHeader))) return;
//if (!BC_ASSERT_TRUE(message.addMessageHeader(dateTimeHeader))) return;
if (!BC_ASSERT_TRUE(message.addMessageHeader(dateTimeHeader))) return;
if (!BC_ASSERT_TRUE(message.addMessageHeader(subjectHeader))) return;
if (!BC_ASSERT_TRUE(message.addMessageHeader(subjectWithLanguageHeader))) return;
if (!BC_ASSERT_TRUE(message.addMessageHeader(nsHeader))) return;
......@@ -190,13 +185,9 @@ static void build_message () {
// Set Content headers.
Cpim::GenericHeader contentTypeHeader("Content-Type", "text/xml; charset=utf-8");
//if (!BC_ASSERT_TRUE(contentTypeHeader.setName("Content-Type"))) return;
//if (!BC_ASSERT_TRUE( contentTypeHeader.setValue("text/xml; charset=utf-8"))) return;
if (!BC_ASSERT_TRUE(message.addContentHeader(contentTypeHeader))) return;
Cpim::GenericHeader contentIdHeader("Content-ID", "<1234567890@foo.com>");
//if (!BC_ASSERT_TRUE(contentIdHeader.setName("Content-ID"))) return;
//if (!BC_ASSERT_TRUE( contentIdHeader.setValue("<1234567890@foo.com>"))) return;
if (!BC_ASSERT_TRUE(message.addContentHeader(contentIdHeader))) return;
const string content = "<body>"
......@@ -208,7 +199,7 @@ static void build_message () {
const string strMessage = message.asString();
const string expectedMessage = "From: \"MR SANDERS\"<im:piglet@100akerwood.com>\r\n"
"To: \"Depressed Donkey\"<im:eeyore@100akerwood.com>\r\n"
//"DateTime: 2000-12-13T13:40:00-08:00\r\n"
"DateTime: 2000-12-13T13:40:00-08:00\r\n"
"Subject: the weather will be fine today\r\n"
"Subject:;lang=fr beau temps prevu pour aujourd'hui\r\n"
"NS: MyFeatures <mid:MessageFeatures@id.foo.com>\r\n"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment