diff --git a/sflphone-common/test/configurationtest.cpp b/sflphone-common/test/configurationtest.cpp old mode 100644 new mode 100755 index f42ea1be8342396de0a9dc2c4b6717ca7c2224df..473753e9916d48fc839416c92bfe436883bce034 --- a/sflphone-common/test/configurationtest.cpp +++ b/sflphone-common/test/configurationtest.cpp @@ -154,9 +154,68 @@ void ConfigurationTest::testInitAudioDriver() { void ConfigurationTest::testYamlParser() { - YamlParser *parser = new YamlParser(); - delete parser; - parser = NULL; + Conf::YamlParser *parser; + try { + parser = new Conf::YamlParser("sequence.yml"); + } + catch (Conf::YamlParserException &e) { + _error("ConfigTree: %s", e.what()); + } + + + try { + parser->serializeEvents(); + } + catch(Conf::YamlParserException &e) { + _error("ConfigTree: %s", e.what()); + } + + try { + parser->composeEvents(); + } + catch(Conf::YamlParserException &e) { + _error("ConfigTree: %s", e.what()); + } + + try { + delete parser; + parser = NULL; + } + catch (Conf::YamlParserException &e) { + _error("ConfigTree: %s", e.what()); + } } + + +void ConfigurationTest::testYamlComposition() +{ + + Conf::SequenceNode *seq = new Conf::SequenceNode(); + Conf::MappingNode *map = new Conf::MappingNode(); + Conf::ScalarNode *sclr = new Conf::ScalarNode(); + + CPPUNIT_ASSERT(seq->getType() == Conf::SEQUENCE); + CPPUNIT_ASSERT(map->getType() == Conf::MAPPING); + CPPUNIT_ASSERT(sclr->getType() == Conf::SCALAR); + + seq->addNode(map); + seq->addNode(sclr); + + Conf::Key key("username"); + Conf::ScalarNode *val = new Conf::ScalarNode("alexandre"); + + map->setKeyValue(key, val); + + Conf::YamlNode *node = map->getValue(key); + + CPPUNIT_ASSERT(node->getType() == Conf::SCALAR); + + delete val; + + delete seq; + delete map; + delete sclr; + +} diff --git a/sflphone-common/test/configurationtest.h b/sflphone-common/test/configurationtest.h old mode 100644 new mode 100755 index 1688819ea6231dc5f4dfc27d0042d390d935f66b..8c9ff82fea485e5c36e0334782c6bce506a81404 --- a/sflphone-common/test/configurationtest.h +++ b/sflphone-common/test/configurationtest.h @@ -51,6 +51,7 @@ #include "global.h" #include "user_cfg.h" #include "config/yamlparser.h" +#include "config/yamlnode.h" class ConfigurationTest: public CppUnit::TestFixture { @@ -58,12 +59,13 @@ class ConfigurationTest: public CppUnit::TestFixture { * Use cppunit library macros to add unit test the factory */ CPPUNIT_TEST_SUITE( ConfigurationTest ); - CPPUNIT_TEST( testInitVolume ); - CPPUNIT_TEST( testDefaultValueAudio ); - CPPUNIT_TEST( testDefaultValuePreferences ); - CPPUNIT_TEST( testDefaultValueSignalisation ); - CPPUNIT_TEST( testInitAudioDriver ); - CPPUNIT_TEST( testYamlParser ); +// CPPUNIT_TEST( testInitVolume ); +// CPPUNIT_TEST( testDefaultValueAudio ); +// CPPUNIT_TEST( testDefaultValuePreferences ); +// CPPUNIT_TEST( testDefaultValueSignalisation ); +// CPPUNIT_TEST( testInitAudioDriver ); + CPPUNIT_TEST( testYamlParser ); + CPPUNIT_TEST( testYamlComposition ); CPPUNIT_TEST_SUITE_END(); public: @@ -95,6 +97,8 @@ public: void testInitAudioDriver(); void testYamlParser(); + + void testYamlComposition(); }; /* Register our test module */ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(ConfigurationTest, "ConfigurationTest");