Index: tests/protocols/CMakeLists.txt =================================================================== --- tests/protocols/CMakeLists.txt +++ tests/protocols/CMakeLists.txt @@ -1 +1,2 @@ add_subdirectory(oscar) +add_subdirectory(qq) Index: tests/protocols/qq/CMakeLists.txt =================================================================== --- /dev/null +++ tests/protocols/qq/CMakeLists.txt @@ -0,0 +1,22 @@ +find_package(Qt5 REQUIRED COMPONENTS Test) +include_directories( + ${CMAKE_SOURCE_DIR}/protocols/qq + ${CMAKE_SOURCE_DIR}/protocols/qq/icons + ${CMAKE_SOURCE_DIR}/protocols/qq/ui + ${KOPETE_SOURCE_DIR} +) + +set( + QQ_TEST_LIBRARIES + KF5::KDELibs4Support + Qt5::Test + ${CMAKE_SOURCE_DIR}/protocols/qq/crypt.cpp +) + +# Test for crypt(TEA) +set(qqcrypttest_SRCS qqcrypttest.cpp) +ecm_add_test( + ${qqcrypttest_SRCS} + LINK_LIBRARIES ${QQ_TEST_LIBRARIES} +) + Index: tests/protocols/qq/qqcrypttest.cpp =================================================================== --- /dev/null +++ tests/protocols/qq/qqcrypttest.cpp @@ -0,0 +1,47 @@ +#include "crypt.h" + +#include +#include + +class QQCryptTest : public QObject +{ + Q_OBJECT + +private slots: + void CryptTest(); +}; + +void QQCryptTest::CryptTest() +{ + char input[2]={'a','b'}; /* This character which is going to encrypt */ + + /* data which is going to encrypt */ + unsigned int a[2]={(unsigned int)input[0],(unsigned int)input[1]}; + + /* encrypted data && input for decipher function */ + unsigned int b[2]={0,0}; + + /* output after decrypt */ + unsigned int c[2]={0,0}; + + /* key which is going to used in encryption */ + const unsigned int k[4]={1,2,3,4}; + + /* void TEA::encipher(unsigned int *const v, const unsigned int *const k, unsigned int *const w); */ + TEA::encipher(a, k, b); + + char encrypted[2]={(char)b[0],(char)b[1]}; + + /* void TEA::decipher(unsigned int *const v, const unsigned int *const k, unsigned int *const w); */ + TEA::decipher(b, k, c); + + char output[2]={(char)c[0],(char)c[1]}; + + QVERIFY(input[0] != encrypted[0]); + QVERIFY(input[1] != encrypted[1]); + QCOMPARE(input[0],output[0]); + QCOMPARE(input[1],output[1]); +} + +QTEST_MAIN(QQCryptTest) +#include "qqcrypttest.moc"