Commit 56743fcd authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Factorized some methods + more tests

parent a3aa029f
......@@ -33,6 +33,8 @@
#include "belcard_calendar.hpp"
#include "belcard_rfc6474.hpp"
#include "bctoolbox/logging.h"
#include <string>
#include <list>
......@@ -93,6 +95,15 @@ namespace belcard {
list<shared_ptr<BelCardProperty>> _extended_properties;
list<shared_ptr<BelCardProperty>> _properties;
template<typename T>
void set(shared_ptr<T> &p, const shared_ptr<T> &property);
template<typename T>
void add(list<shared_ptr<T>> &property_list, const shared_ptr<T> &property);
template<typename T>
void remove(list<shared_ptr<T>> &property_list, const shared_ptr<T> &property);
public:
BELCARD_PUBLIC static void setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser);
......
This diff is collapsed.
......@@ -21,8 +21,6 @@
#include "belcard/belcard_utils.hpp"
#include <belr/parser-impl.cc>
#include "bctoolbox/logging.h"
#include <iostream>
#include <fstream>
#include <sstream>
......
......@@ -91,6 +91,12 @@ static void create_vcard_from_api(void) {
fn->setValue("Sylvain Berfini");
belCard->setFullName(fn);
BC_ASSERT_TRUE(belCard->assertRFCCompliance());
BC_ASSERT_STRING_EQUAL(belCard->getFullName()->toString().c_str(), fn->toString().c_str());
fn = BelCard::create<BelCardFullName>();
fn->setValue("Belcard Tester");
belCard->setFullName(fn);
BC_ASSERT_STRING_EQUAL(belCard->getFullName()->toString().c_str(), fn->toString().c_str());
string vcard = belCard->toString();
BelCardParser *parser = new BelCardParser();
......@@ -119,6 +125,13 @@ static void property_sort_using_pref_param(void) {
BC_ASSERT_EQUAL((unsigned int)imppList.size(), 2, unsigned int, "%u");
BC_ASSERT_TRUE(imppList.front() == impp2);
BC_ASSERT_TRUE(imppList.back() == impp1);
const list<shared_ptr<BelCardProperty>> propertiesList = belCard->getProperties();
BC_ASSERT_EQUAL((unsigned int)propertiesList.size(), 2, unsigned int, "%u");
belCard->removeImpp(impp1);
BC_ASSERT_EQUAL((unsigned int)belCard->getImpp().size(), 1, unsigned int, "%u");
BC_ASSERT_EQUAL((unsigned int)belCard->getProperties().size(), 1, unsigned int, "%u");
}
static test_t tests[] = {
......
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