Commit ef16fe85 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Added more tests

parent 97435b08
......@@ -191,8 +191,8 @@ namespace belcard {
const list<shared_ptr<BelCardProperty>> &getProperties() const;
void removeProperty(const shared_ptr<BelCardProperty> &property);
const string toFoldedString();
const bool assertRFCCompliance();
const string toFoldedString() const;
const bool assertRFCCompliance() const;
virtual void serialize(ostream &output) const;
};
......
......@@ -420,14 +420,13 @@ void BelCard::serialize(ostream& output) const {
output << "END:VCARD\r\n";
}
const string BelCard::toFoldedString() {
const string BelCard::toFoldedString() const {
string vcard = this->toString();
return belcard_fold(vcard);
}
const bool BelCard::assertRFCCompliance() {
const bool BelCard::assertRFCCompliance() const {
if (!_fn) {
cerr << "FN is not set" << endl;
return false;
}
......
......@@ -6,6 +6,7 @@ using namespace::belcard;
static void fn_property(void) {
test_property<BelCardFullName>("FN:Sylvain Berfini\r\n");
test_property<BelCardFullName>("FN:François Grisez\r\n");
}
static void n_property(void) {
......
......@@ -61,10 +61,29 @@ static void vcard_parsing(void) {
delete parser;
}
static void create_vcard_from_api(void) {
shared_ptr<BelCard> belCard = BelCard::create<BelCard>();
BC_ASSERT_TRUE_FATAL(belCard != NULL);
BC_ASSERT_FALSE(belCard->assertRFCCompliance());
shared_ptr<BelCardFullName> fn = BelCard::create<BelCardFullName>();
fn->setValue("Sylvain Berfini");
belCard->setFullName(fn);
BC_ASSERT_TRUE(belCard->assertRFCCompliance());
string vcard = belCard->toString();
BelCardParser *parser = new BelCardParser();
shared_ptr<BelCard> belCard2 = parser->parse(vcard);
BC_ASSERT_TRUE_FATAL(belCard2 != NULL);
string vcard2 = belCard2->toString();
BC_ASSERT_TRUE(vcard.compare(vcard2) == 0);
}
static test_t tests[] = {
{ "Folding", folding },
{ "Unfolding", unfolding },
{ "VCard parsing", vcard_parsing },
{ "VCard created from scratch", create_vcard_from_api },
};
test_suite_t vcard_test_suite = {
......
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