Skip to content
Snippets Groups Projects
Commit 50b3798b authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#3647] Unit test the yaml parser

parent 3fd35272
No related branches found
No related tags found
No related merge requests found
......@@ -154,9 +154,68 @@ void ConfigurationTest::testInitAudioDriver() {
void ConfigurationTest::testYamlParser()
{
YamlParser *parser = new YamlParser();
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;
}
......@@ -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( 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");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment