~DNSResourceRecord(){};
void setContent(const string& content);
- string getZoneRepresentation();
+ string getZoneRepresentation() const;
// data
}
}
-string DNSResourceRecord::getZoneRepresentation() {
+string DNSResourceRecord::getZoneRepresentation() const {
ostringstream ret;
switch(qtype.getCode()) {
case QType::SRV:
case QType::MX:
ret<<priority;
- ret<<" "<<content<<".";
+ ret<<" "<<content;
+ if (*(content.rbegin()) != '.') ret<<".";
break;
case QType::CNAME:
case QType::NS:
- ret<<content<<".";
+ ret<<content;
+ if (*(content.rbegin()) != '.') ret<<".";
break;
default:
ret<<content;
BOOST_CHECK_EQUAL(rr.qname, host);
BOOST_CHECK_EQUAL(rr.ttl, ttl);
BOOST_CHECK_EQUAL(rr.qtype.getName(), type);
- BOOST_CHECK_EQUAL(rr.getZoneRepresentation(), data);
+ if (*(rr.content.rbegin()) != '.' && *(data.rbegin()) == '.')
+ BOOST_CHECK_EQUAL(rr.content, std::string(data.begin(),data.end()-1));
+ else
+ BOOST_CHECK_EQUAL(rr.content, data);
}
}
case QType::MX:
stringtok(recparts, rr.content);
if(recparts.size()==2) {
- recparts[1] = stripDot(toCanonic(d_zonename, recparts[1]));
+ if (recparts[1]!=".")
+ recparts[1] = stripDot(toCanonic(d_zonename, recparts[1]));
rr.content=recparts[0]+" "+recparts[1];
}
break;