random ai stuff
This commit is contained in:
9
telldus-core/tests/service/CMakeLists.txt
Normal file
9
telldus-core/tests/service/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
FILE(GLOB SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*Test.cpp" )
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
|
||||
|
||||
ADD_LIBRARY(TelldusServiceTests STATIC ${SRCS} )
|
||||
|
||||
TARGET_LINK_LIBRARIES( TelldusServiceTests TelldusServiceStatic ${CPPUNIT} )
|
||||
ADD_DEPENDENCIES( TelldusServiceTests ${telldus-service_TARGET} )
|
||||
|
||||
30
telldus-core/tests/service/ProtocolEverflourishTest.cpp
Normal file
30
telldus-core/tests/service/ProtocolEverflourishTest.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "ProtocolEverflourishTest.h"
|
||||
#include "service/ProtocolEverflourish.h"
|
||||
|
||||
class ProtocolEverflourishTest::PrivateData {
|
||||
public:
|
||||
ProtocolEverflourish *protocol;
|
||||
};
|
||||
|
||||
void ProtocolEverflourishTest :: setUp (void) {
|
||||
d = new PrivateData;
|
||||
d->protocol = new ProtocolEverflourish();
|
||||
}
|
||||
|
||||
void ProtocolEverflourishTest :: tearDown (void) {
|
||||
delete d->protocol;
|
||||
delete d;
|
||||
}
|
||||
|
||||
void ProtocolEverflourishTest :: decodeDataTest (void) {
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
||||
"Everflourish 4242:3 ON",
|
||||
std::string("class:command;protocol:everflourish;model:selflearning;house:4242;unit:3;method:turnon;"),
|
||||
d->protocol->decodeData(ControllerMessage("protocol:everflourish;data:0x424A6F;"))
|
||||
);
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
||||
"Everflourish 5353:4 OFF",
|
||||
std::string("class:command;protocol:everflourish;model:selflearning;house:5353;unit:4;method:turnoff;"),
|
||||
d->protocol->decodeData(ControllerMessage("protocol:everflourish;data:0x53A7E0;"))
|
||||
);
|
||||
}
|
||||
25
telldus-core/tests/service/ProtocolEverflourishTest.h
Normal file
25
telldus-core/tests/service/ProtocolEverflourishTest.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef PROTOCOLEVERFLOURISHTEST_H
|
||||
#define PROTOCOLEVERFLOURISHTEST_H
|
||||
|
||||
#include <cppunit/TestFixture.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
class ProtocolEverflourishTest : public CPPUNIT_NS :: TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE (ProtocolEverflourishTest);
|
||||
CPPUNIT_TEST (decodeDataTest);
|
||||
CPPUNIT_TEST_SUITE_END ();
|
||||
|
||||
public:
|
||||
void setUp (void);
|
||||
void tearDown (void);
|
||||
|
||||
protected:
|
||||
void decodeDataTest(void);
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d;
|
||||
};
|
||||
|
||||
#endif // PROTOCOLEVERFLOURISHTEST_H
|
||||
40
telldus-core/tests/service/ProtocolHastaTest.cpp
Normal file
40
telldus-core/tests/service/ProtocolHastaTest.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "ProtocolHastaTest.h"
|
||||
#include "service/ProtocolHasta.h"
|
||||
|
||||
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;"))
|
||||
);
|
||||
}
|
||||
25
telldus-core/tests/service/ProtocolHastaTest.h
Normal file
25
telldus-core/tests/service/ProtocolHastaTest.h
Normal 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
|
||||
40
telldus-core/tests/service/ProtocolNexaTest.cpp
Normal file
40
telldus-core/tests/service/ProtocolNexaTest.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "ProtocolNexaTest.h"
|
||||
#include "service/ProtocolNexa.h"
|
||||
|
||||
class ProtocolNexaTest::PrivateData {
|
||||
public:
|
||||
ProtocolNexa *protocol;
|
||||
};
|
||||
|
||||
void ProtocolNexaTest :: setUp (void) {
|
||||
d = new PrivateData;
|
||||
d->protocol = new ProtocolNexa();
|
||||
}
|
||||
|
||||
void ProtocolNexaTest :: tearDown (void) {
|
||||
delete d->protocol;
|
||||
delete d;
|
||||
}
|
||||
|
||||
void ProtocolNexaTest :: decodeDataTest (void) {
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
||||
"Arctech Codeswitch A1 ON",
|
||||
std::string("class:command;protocol:arctech;model:codeswitch;house:A;unit:1;method:turnon;"),
|
||||
d->protocol->decodeData(ControllerMessage("protocol:arctech;model:codeswitch;data:0xE00;"))
|
||||
);
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
||||
"Arctech Codeswitch A1 OFF",
|
||||
std::string("class:command;protocol:arctech;model:codeswitch;house:A;unit:1;method:turnoff;"),
|
||||
d->protocol->decodeData(ControllerMessage("protocol:arctech;model:codeswitch;data:0x600;"))
|
||||
);
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
||||
"Arctech Selflearning 1329110 1 ON",
|
||||
std::string("class:command;protocol:arctech;model:selflearning;house:1329110;unit:1;group:0;method:turnon;"),
|
||||
d->protocol->decodeData(ControllerMessage("protocol:arctech;model:selflearning;data:0x511F590;"))
|
||||
);
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
||||
"Arctech Selflearning 1329110 1 OFF",
|
||||
std::string("class:command;protocol:arctech;model:selflearning;house:1329110;unit:1;group:0;method:turnoff;"),
|
||||
d->protocol->decodeData(ControllerMessage("protocol:arctech;model:selflearning;data:0x511F580;"))
|
||||
);
|
||||
}
|
||||
25
telldus-core/tests/service/ProtocolNexaTest.h
Normal file
25
telldus-core/tests/service/ProtocolNexaTest.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef PROTOCOLNEXATEST_H
|
||||
#define PROTOCOLNEXATEST_H
|
||||
|
||||
#include <cppunit/TestFixture.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
class ProtocolNexaTest : public CPPUNIT_NS :: TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE (ProtocolNexaTest);
|
||||
CPPUNIT_TEST (decodeDataTest);
|
||||
CPPUNIT_TEST_SUITE_END ();
|
||||
|
||||
public:
|
||||
void setUp (void);
|
||||
void tearDown (void);
|
||||
|
||||
protected:
|
||||
void decodeDataTest(void);
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d;
|
||||
};
|
||||
|
||||
#endif //PROTOCOLNEXATEST_H
|
||||
67
telldus-core/tests/service/ProtocolOregonTest.cpp
Normal file
67
telldus-core/tests/service/ProtocolOregonTest.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
#include "ProtocolOregonTest.h"
|
||||
#include "service/ProtocolOregon.h"
|
||||
|
||||
class ProtocolOregonTest::PrivateData {
|
||||
public:
|
||||
};
|
||||
|
||||
void ProtocolOregonTest :: setUp (void) {
|
||||
d = new PrivateData;
|
||||
}
|
||||
|
||||
void ProtocolOregonTest :: tearDown (void) {
|
||||
delete d;
|
||||
}
|
||||
|
||||
void ProtocolOregonTest :: decodeDataTest (void) {
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
||||
"Oregon, id: 119, temp: 77.3",
|
||||
std::string("class:sensor;protocol:oregon;model:EA4C;id:119;temp:77.3;"),
|
||||
ProtocolOregon::decodeData(ControllerMessage("class:sensor;protocol:oregon;model:0xEA4C;data:2177307700E4;"))
|
||||
);
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
||||
"Oregon, id: 119, temp: 74.7",
|
||||
std::string("class:sensor;protocol:oregon;model:EA4C;id:119;temp:74.7;"),
|
||||
ProtocolOregon::decodeData(ControllerMessage("class:sensor;protocol:oregon;model:0xEA4C;data:2177707410A4;"))
|
||||
);
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
||||
"Oregon, id: 119, temp: 77.7",
|
||||
std::string("class:sensor;protocol:oregon;model:EA4C;id:119;temp:77.7;"),
|
||||
ProtocolOregon::decodeData(ControllerMessage("class:sensor;protocol:oregon;model:0xEA4C;data:217770774054;"))
|
||||
);
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
||||
"Oregon, id: 119, temp: 66.5",
|
||||
std::string("class:sensor;protocol:oregon;model:EA4C;id:119;temp:66.5;"),
|
||||
ProtocolOregon::decodeData(ControllerMessage("class:sensor;protocol:oregon;model:0xEA4C;data:2177506600E4;"))
|
||||
);
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
||||
"Oregon, id: 119, temp: 122.5",
|
||||
std::string("class:sensor;protocol:oregon;model:EA4C;id:119;temp:122.5;"),
|
||||
ProtocolOregon::decodeData(ControllerMessage("class:sensor;protocol:oregon;model:0xEA4C;data:2177502291A3;"))
|
||||
);
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
||||
"Oregon, id: 119, temp: 120.1",
|
||||
std::string("class:sensor;protocol:oregon;model:EA4C;id:119;temp:120.1;"),
|
||||
ProtocolOregon::decodeData(ControllerMessage("class:sensor;protocol:oregon;model:0xEA4C;data:2177102031B3;"))
|
||||
);
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
||||
"Oregon, id: 119, temp: 120.6",
|
||||
std::string("class:sensor;protocol:oregon;model:EA4C;id:119;temp:120.6;"),
|
||||
ProtocolOregon::decodeData(ControllerMessage("class:sensor;protocol:oregon;model:0xEA4C;data:217760208193;"))
|
||||
);
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
||||
"Oregon, id: 23, temp: 202.7",
|
||||
std::string("class:sensor;protocol:oregon;model:EA4C;id:23;temp:202.7;"),
|
||||
ProtocolOregon::decodeData(ControllerMessage("class:sensor;protocol:oregon;model:0xEA4C;data:2177702A2D3;"))
|
||||
);
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
||||
"Oregon, id: 119, temp: 202.7",
|
||||
std::string("class:sensor;protocol:oregon;model:EA4C;id:119;temp:202.7;"),
|
||||
ProtocolOregon::decodeData(ControllerMessage("class:sensor;protocol:oregon;model:0xEA4C;data:21777002A2D3;"))
|
||||
);
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
||||
"Oregon, id: 119, temp: -23.1",
|
||||
std::string("class:sensor;protocol:oregon;model:EA4C;id:119;temp:-23.1;"),
|
||||
ProtocolOregon::decodeData(ControllerMessage("class:sensor;protocol:oregon;model:0xEA4C;data:21771023D8B3;"))
|
||||
);
|
||||
}
|
||||
25
telldus-core/tests/service/ProtocolOregonTest.h
Normal file
25
telldus-core/tests/service/ProtocolOregonTest.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef PROTOCOLOREGONTEST_H
|
||||
#define PROTOCOLOREGONTEST_H
|
||||
|
||||
#include <cppunit/TestFixture.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
class ProtocolOregonTest : public CPPUNIT_NS :: TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE (ProtocolOregonTest);
|
||||
CPPUNIT_TEST (decodeDataTest);
|
||||
CPPUNIT_TEST_SUITE_END ();
|
||||
|
||||
public:
|
||||
void setUp (void);
|
||||
void tearDown (void);
|
||||
|
||||
protected:
|
||||
void decodeDataTest(void);
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d;
|
||||
};
|
||||
|
||||
#endif // PROTOCOLOREGONTEST_H
|
||||
25
telldus-core/tests/service/ProtocolSartanoTest.cpp
Normal file
25
telldus-core/tests/service/ProtocolSartanoTest.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include "ProtocolSartanoTest.h"
|
||||
#include "service/ProtocolSartano.h"
|
||||
|
||||
class ProtocolSartanoTest::PrivateData {
|
||||
public:
|
||||
ProtocolSartano *protocol;
|
||||
};
|
||||
|
||||
void ProtocolSartanoTest :: setUp (void) {
|
||||
d = new PrivateData;
|
||||
d->protocol = new ProtocolSartano();
|
||||
}
|
||||
|
||||
void ProtocolSartanoTest :: tearDown (void) {
|
||||
delete d->protocol;
|
||||
delete d;
|
||||
}
|
||||
|
||||
void ProtocolSartanoTest :: decodeDataTest (void) {
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
||||
"Sartano 0101010101 ON",
|
||||
std::string("class:command;protocol:sartano;model:codeswitch;code:0101010101;method:turnon;"),
|
||||
d->protocol->decodeData(ControllerMessage("protocol:arctech;model:codeswitch;data:0x955;"))
|
||||
);
|
||||
}
|
||||
25
telldus-core/tests/service/ProtocolSartanoTest.h
Normal file
25
telldus-core/tests/service/ProtocolSartanoTest.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef PROTOCOLSARTANOTEST_H
|
||||
#define PROTOCOLSARTANOTEST_H
|
||||
|
||||
#include <cppunit/TestFixture.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
class ProtocolSartanoTest : public CPPUNIT_NS :: TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE (ProtocolSartanoTest);
|
||||
CPPUNIT_TEST (decodeDataTest);
|
||||
CPPUNIT_TEST_SUITE_END ();
|
||||
|
||||
public:
|
||||
void setUp (void);
|
||||
void tearDown (void);
|
||||
|
||||
protected:
|
||||
void decodeDataTest(void);
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d;
|
||||
};
|
||||
|
||||
#endif //PROTOCOLSARTANOTEST_H
|
||||
30
telldus-core/tests/service/ProtocolX10Test.cpp
Normal file
30
telldus-core/tests/service/ProtocolX10Test.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "ProtocolX10Test.h"
|
||||
#include "service/ProtocolX10.h"
|
||||
|
||||
class ProtocolX10Test::PrivateData {
|
||||
public:
|
||||
ProtocolX10 *protocol;
|
||||
};
|
||||
|
||||
void ProtocolX10Test :: setUp (void) {
|
||||
d = new PrivateData;
|
||||
d->protocol = new ProtocolX10();
|
||||
}
|
||||
|
||||
void ProtocolX10Test :: tearDown (void) {
|
||||
delete d->protocol;
|
||||
delete d;
|
||||
}
|
||||
|
||||
void ProtocolX10Test :: decodeDataTest (void) {
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
||||
"X10 A1 ON",
|
||||
std::string("class:command;protocol:x10;model:codeswitch;house:A;unit:1;method:turnon;"),
|
||||
d->protocol->decodeData(ControllerMessage("protocol:x10;data:0x609F00FF;"))
|
||||
);
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
||||
"X10 E11 OFF",
|
||||
std::string("class:command;protocol:x10;model:codeswitch;house:E;unit:11;method:turnoff;"),
|
||||
d->protocol->decodeData(ControllerMessage("protocol:x10;data:0x847B28D7;"))
|
||||
);
|
||||
}
|
||||
25
telldus-core/tests/service/ProtocolX10Test.h
Normal file
25
telldus-core/tests/service/ProtocolX10Test.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef PROTOCOLX10TEST_H
|
||||
#define PROTOCOLX10TEST_H
|
||||
|
||||
#include <cppunit/TestFixture.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
class ProtocolX10Test : public CPPUNIT_NS :: TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE (ProtocolX10Test);
|
||||
CPPUNIT_TEST (decodeDataTest);
|
||||
CPPUNIT_TEST_SUITE_END ();
|
||||
|
||||
public:
|
||||
void setUp (void);
|
||||
void tearDown (void);
|
||||
|
||||
protected:
|
||||
void decodeDataTest(void);
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d;
|
||||
};
|
||||
|
||||
#endif //PROTOCOLX10TEST_H
|
||||
21
telldus-core/tests/service/ServiceTests.h
Normal file
21
telldus-core/tests/service/ServiceTests.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef SERVICETESTS_H
|
||||
#define SERVICETESTS_H
|
||||
|
||||
#include "ProtocolEverflourishTest.h"
|
||||
#include "ProtocolHastaTest.h"
|
||||
#include "ProtocolNexaTest.h"
|
||||
#include "ProtocolOregonTest.h"
|
||||
#include "ProtocolSartanoTest.h"
|
||||
#include "ProtocolX10Test.h"
|
||||
|
||||
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);
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION (ProtocolX10Test);
|
||||
}
|
||||
}
|
||||
#endif // SERVICETESTS_H
|
||||
Reference in New Issue
Block a user