Added unit test for Hasta protocol

This commit is contained in:
Stefan Persson 2013-05-17 11:41:58 +02:00
parent b56823a6e7
commit b00cbdb37c
3 changed files with 69 additions and 0 deletions

View file

@ -0,0 +1,42 @@
#include "ProtocolHastaTest.h"
#include "service/ProtocolHasta.h"
CPPUNIT_TEST_SUITE_REGISTRATION (ProtocolHastaTest);
class ProtocolHastaTest::PrivateData {
public:
ProtocolHasta *protocol;
};
void ProtocolHastaTest :: setUp (void) {
d = new PrivateData;
d->protocol = new ProtocolHasta();
}
void ProtocolHastaTest :: tearDown (void) {
delete d->protocol;
delete d;
}
void ProtocolHastaTest :: decodeDataTest (void) {
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Hasta Version 1 26380 1 DOWN",
std::string("class:command;protocol:hasta;model:selflearning;house:26380;unit:1;method:down;"),
d->protocol->decodeData(ControllerMessage("protocol:hasta;model:selflearning;data:0xC671100;"))
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Hasta Version 1 26380 1 UP",
std::string("class:command;protocol:hasta;model:selflearning;house:26380;unit:1;method:up;"),
d->protocol->decodeData(ControllerMessage("protocol:arctech;model:selflearning;data:0xC670100;"))
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Hasta Version 2 19337 15 DOWN",
std::string("class:command;protocol:hasta;model:selflearningv2;house:19337;unit:15;method:down;"),
d->protocol->decodeData(ControllerMessage("protocol:hasta;model:selflearningv2;data:0x4B891F01;"))
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Hasta Version 2 19337 15 UP",
std::string("class:command;protocol:hasta;model:selflearningv2;house:19337;unit:15;method:up;"),
d->protocol->decodeData(ControllerMessage("protocol:hasta;model:selflearningv2;data:0x4B89CF01;"))
);
}

View file

@ -0,0 +1,25 @@
#ifndef PROTOCOLHASTATEST_H
#define PROTOCOLHASTATEST_H
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
class ProtocolHastaTest : public CPPUNIT_NS :: TestFixture
{
CPPUNIT_TEST_SUITE (ProtocolHastaTest);
CPPUNIT_TEST (decodeDataTest);
CPPUNIT_TEST_SUITE_END ();
public:
void setUp (void);
void tearDown (void);
protected:
void decodeDataTest(void);
private:
class PrivateData;
PrivateData *d;
};
#endif //PROTOCOLHASTATEST_H

View file

@ -2,6 +2,7 @@
#define SERVICETESTS_H
#include "ProtocolEverflourishTest.h"
#include "ProtocolHastaTest.h"
#include "ProtocolNexaTest.h"
#include "ProtocolOregonTest.h"
#include "ProtocolSartanoTest.h"
@ -10,6 +11,7 @@
namespace ServiceTests {
inline void setup() {
CPPUNIT_TEST_SUITE_REGISTRATION (ProtocolEverflourishTest);
CPPUNIT_TEST_SUITE_REGISTRATION (ProtocolHastaTest);
CPPUNIT_TEST_SUITE_REGISTRATION (ProtocolNexaTest);
CPPUNIT_TEST_SUITE_REGISTRATION (ProtocolOregonTest);
CPPUNIT_TEST_SUITE_REGISTRATION (ProtocolSartanoTest);