Commit 4c645906 authored by Tristan Matthews's avatar Tristan Matthews

tests: cleanup

parent 01ac3ab6
......@@ -30,20 +30,7 @@
#include "delaydetectiontest.h"
// Returns the number of elements in a, calculated at compile-time
#define ARRAYSIZE(a) \
((sizeof(a) / sizeof(*(a))) / \
static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
#endif
#include <iostream>
#include <math.h>
#include <string.h>
void DelayDetectionTest::setUp() {}
void DelayDetectionTest::tearDown() {}
#include <cstring>
void DelayDetectionTest::testCrossCorrelation()
{
......@@ -80,7 +67,6 @@ void DelayDetectionTest::testCrossCorrelationDelay()
delaydetect_.crossCorrelate(ref, signal, result, 3, 10);
float expected[10] = {0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0};
}
void DelayDetectionTest::testFirFilter()
......@@ -94,7 +80,7 @@ void DelayDetectionTest::testFirFilter()
-0.02437806, -0.02602213, -0.02373243, -0.01873722, -0.01120109, -0.00266367,
0.00610982, 0.01463477, 0.02244098, 0.02944626, 0.03630817, 0.04448337,
0.05616626, 0.07473655, -0.09870257};
std::vector<double> ird(decimationCoefs, decimationCoefs + sizeof(decimationCoefs) / sizeof(float));
const std::vector<double> ird(decimationCoefs, decimationCoefs + ARRAYSIZE(decimationCoefs));
const float bandpassCoefs[] = {0.06278034, -0.0758545, -0.02274943, -0.0084497, 0.0702427, 0.05986113,
0.06436469, -0.02412049, -0.03433526, -0.07568665, -0.03214543, -0.07236507,
......@@ -102,7 +88,7 @@ void DelayDetectionTest::testFirFilter()
0.15294699, 0.00947243, -0.05530828, -0.12446371, -0.06979052, -0.07236507,
-0.03214543, -0.07568665, -0.03433526, -0.02412049, 0.06436469, 0.05986113,
0.0702427, -0.0084497, -0.02274943, -0.0758545, 0.06278034};
std::vector<double> irb(bandpassCoefs, bandpassCoefs + sizeof(bandpassCoefs) / sizeof(float));
const std::vector<double> irb(bandpassCoefs, bandpassCoefs + ARRAYSIZE(bandpassCoefs));
float impulse[100];
memset(impulse, 0, sizeof(impulse))
......
......@@ -35,33 +35,10 @@
#include <cppunit/TestCase.h>
#include <cppunit/TestSuite.h>
#include <assert.h>
#include <stdio.h>
#include <sstream>
#include <ccrtp/rtp.h>
// pjsip import
#include <pjsip.h>
#include <pjlib.h>
#include <pjsip_ua.h>
#include <pjlib-util.h>
#include <pjnath/stun_config.h>
// Application import
#include "manager.h"
#include "audio/mainbuffer.h"
#include "audio/ringbuffer.h"
#include "call.h"
// #include "config/config.h"
// #include "user_cfg.h"
#include "audio/delaydetection.h"
#ifndef _DELAYDETECTION_TEST_
#define _DELAYDETECTION_TEST_
#ifndef DELAYDETECTION_TEST_
#define DELAYDETECTION_TEST_
/*
* @file delaydetection.cpp
......@@ -83,10 +60,6 @@ class DelayDetectionTest : public CppUnit::TestCase {
DelayDetectionTest() : CppUnit::TestCase("Delay Detection Tests") {}
void setUp();
void tearDown();
void testCrossCorrelation();
void testCrossCorrelationDelay();
......@@ -109,4 +82,4 @@ class DelayDetectionTest : public CppUnit::TestCase {
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(DelayDetectionTest, "DelayDetectionTest");
CPPUNIT_TEST_SUITE_REGISTRATION(DelayDetectionTest);
#endif
#endif // DELAYDETECTION_TEST_
......@@ -33,15 +33,12 @@
#include "echocanceltest.h"
#include "config/config.h"
using namespace std;
EchoCancelTest::EchoCancelTest() : echoCanceller_() {}
void EchoCancelTest::testEchoCancelProcessing()
{
const int nbSamples = 160;
int inputFileLength = 0;
int remainingLength = 0;
using std::ifstream;
using std::ofstream;
SFLDataFormat micData[1000];
SFLDataFormat spkrData[1000];
......@@ -54,13 +51,12 @@ void EchoCancelTest::testEchoCancelProcessing()
// echo cancelled output
ofstream echoCancelFile("sample_echocancel_500ms_8kHz_16bit.raw", ofstream::out);
micFile.seekg(0, ios::end);
inputFileLength = micFile.tellg() / sizeof(SFLDataFormat);
micFile.seekg(0, ios::beg);
remainingLength = inputFileLength;
micFile.seekg(0, std::ios::end);
size_t inputFileLength = micFile.tellg() / sizeof(SFLDataFormat);
micFile.seekg(0, std::ios::beg);
while (remainingLength >= nbSamples) {
const int nbSamples = 160;
for (int remainingLength = inputFileLength; remainingLength >= nbSamples; remainingLength -= nbSamples) {
micFile.read(reinterpret_cast<char *>(micData), nbSamples * sizeof(SFLDataFormat));
spkrFile.read(reinterpret_cast<char *>(spkrData), nbSamples * sizeof(SFLDataFormat));
......@@ -68,8 +64,6 @@ void EchoCancelTest::testEchoCancelProcessing()
echoCanceller_.process(micData, echoCancelData, nbSamples);
echoCancelFile.write(reinterpret_cast<char *>(echoCancelData), nbSamples * sizeof(SFLDataFormat));
remainingLength -= nbSamples;
}
CPPUNIT_ASSERT(true);
......
......@@ -42,8 +42,6 @@
#include <cppunit/TestCase.h>
#include <cppunit/TestSuite.h>
#include <cassert>
#include "audio/speexechocancel.h"
class EchoCancelTest: public CppUnit::TestFixture {
......
......@@ -28,13 +28,10 @@
* as that of the covered work.
*/
#include <iostream>
#include "gaincontroltest.h"
#include "audio/gaincontrol.h"
#include "config/config.h"
using namespace std;
void GainControlTest::testGainProcessing()
{
#if 0
......
......@@ -33,8 +33,8 @@
* @brief Regroups unitary tests related to the plugin manager.
*/
#ifndef _GAINCONTROL_TEST_
#define _GAINCONTROL_TEST_
#ifndef GAINCONTROL_TEST_
#define GAINCONTROL_TEST_
// Cppunit import
#include <cppunit/extensions/HelperMacros.h>
......@@ -42,10 +42,6 @@
#include <cppunit/TestCase.h>
#include <cppunit/TestSuite.h>
#include <assert.h>
#include "audio/gaincontrol.h"
class GainControlTest: public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(GainControlTest);
......@@ -55,12 +51,8 @@ class GainControlTest: public CppUnit::TestFixture {
public:
void testGainProcessing();
private:
};
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(GainControlTest, "GainControlTest");
CPPUNIT_TEST_SUITE_REGISTRATION(GainControlTest);
#endif
#endif // GAINCONTROL_TEST_
......@@ -28,17 +28,12 @@
* as that of the covered work.
*/
#include <cstdio>
#include <sstream>
#include <cstdlib>
#include "historytest.h"
#include "history/history.h"
#include "logger.h"
#include "constants.h"
#include "validator.h"
using std::cout;
using std::endl;
namespace {
void restore()
......
......@@ -38,8 +38,8 @@
// Application import
#include "noncopyable.h"
#include "history/history.h"
class History;
/*
* @file historyTest.h
* @brief Regroups unitary tests related to the phone number cleanup function.
......
......@@ -30,25 +30,22 @@
#include <iostream>
#include <fstream>
#include "test_utils.h"
#include "instantmessagingtest.h"
#include "im/instant_messaging.h"
#include "expat.h"
#include <cstdio>
#define MAXIMUM_SIZE 10
#define DELIMITER_CHAR "\n\n"
using std::cout;
using std::endl;
using namespace sfl::InstantMessaging;
void InstantMessagingTest::testSaveSingleMessage()
{
DEBUG("-------------------- InstantMessagingTest::testSaveSingleMessage --------------------\n");
std::string input, tmp;
TITLE();
std::string callID = "testfile1.txt";
std::string filename = "im:";
......@@ -60,7 +57,9 @@ void InstantMessagingTest::testSaveSingleMessage()
std::ifstream testfile(filename.c_str(), std::ios::in);
CPPUNIT_ASSERT(testfile.is_open());
std::string input;
while (!testfile.eof()) {
std::string tmp;
std::getline(testfile, tmp);
input.append(tmp);
}
......@@ -71,9 +70,8 @@ void InstantMessagingTest::testSaveSingleMessage()
void InstantMessagingTest::testSaveMultipleMessage()
{
DEBUG("-------------------- InstantMessagingTest::testSaveMultipleMessage --------------------\n");
TITLE();
std::string input, tmp;
std::string callID = "testfile2.txt";
std::string filename = "im:";
......@@ -86,7 +84,9 @@ void InstantMessagingTest::testSaveMultipleMessage()
std::ifstream testfile(filename.c_str(), std::ios::in);
CPPUNIT_ASSERT(testfile.is_open());
std::string input;
while (!testfile.eof()) {
std::string tmp;
std::getline(testfile, tmp);
input.append(tmp);
}
......@@ -108,14 +108,12 @@ static void XMLCALL startElementCallback(void *userData, const char *name, const
std::cout << "startElement " << name << std::endl;
int *nbEntry = (int *)userData;
int *nbEntry = (int *) userData;
char attribute[50];
char value[50];
const char **att;
for (att = atts; *att; att += 2) {
for (const char **att = atts; *att; att += 2) {
const char **val = att+1;
......@@ -169,13 +167,11 @@ void InstantMessagingTest::testGenerateXmlUriList()
XML_SetElementHandler(parser, startElementCallback, endElementCallback);
if (XML_Parse(parser, buffer.c_str(), buffer.size(), 1) == XML_STATUS_ERROR) {
std::cout << "Error: " << XML_ErrorString(XML_GetErrorCode(parser))
<< " at line " << XML_GetCurrentLineNumber(parser) << std::endl;
ERROR("%s at line %d", XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser));
CPPUNIT_ASSERT(false);
}
XML_ParserFree(parser);
CPPUNIT_ASSERT(nbEntry == 4);
}
......@@ -197,20 +193,13 @@ void InstantMessagingTest::testXmlUriListParsing()
sfl::InstantMessaging::UriEntry::iterator iterAttr;
// An iterator over list entries
sfl::InstantMessaging::UriList::iterator iterEntry = list.begin();
while (iterEntry != list.end()) {
for (sfl::InstantMessaging::UriList::iterator iterEntry = list.begin();
iterEntry != list.end(); ++iterEntry) {
sfl::InstantMessaging::UriEntry entry = static_cast<sfl::InstantMessaging::UriEntry>(*iterEntry);
iterAttr = entry.find(sfl::IM_XML_URI);
if ((iterAttr->second == std::string("sip:alex@example.com")) ||
(iterAttr->second == std::string("sip:manu@example.com")))
CPPUNIT_ASSERT(true);
else
CPPUNIT_ASSERT(false);
iterEntry++;
CPPUNIT_ASSERT((iterAttr->second == std::string("sip:alex@example.com")) or
(iterAttr->second == std::string("sip:manu@example.com")));
}
}
......@@ -232,8 +221,7 @@ void InstantMessagingTest::testGetTextArea()
formatedText.append("--boundary--");
std::string message(findTextMessage(formatedText));
std::cout << "message " << message << std::endl;
DEBUG("Message %s", message.c_str());
CPPUNIT_ASSERT(message == "Here is the text area");
}
......@@ -270,7 +258,7 @@ void InstantMessagingTest::testGetUriListArea()
sfl::InstantMessaging::UriEntry::iterator iterAttr = entry.find(sfl::IM_XML_URI);
if (iterAttr == entry.end()) {
std::cout << "Error, did not found attribute" << std::endl;
ERROR("Did not find attribute");
CPPUNIT_ASSERT(false);
}
......@@ -303,8 +291,5 @@ void InstantMessagingTest::testIllFormatedMessage()
exceptionCaught = true;
}
if (exceptionCaught)
CPPUNIT_ASSERT(true);
else
CPPUNIT_ASSERT(false);
CPPUNIT_ASSERT(exceptionCaught);
}
......@@ -28,44 +28,15 @@
* as that of the covered work.
*/
#include <stdio.h>
#include <sstream>
#include <ccrtp/rtp.h>
#include <assert.h>
#include <string>
#include <cstring>
#include <math.h>
#include <dlfcn.h>
#include <iostream>
#include <sstream>
#include "mainbuffertest.h"
#include <unistd.h>
using std::cout;
using std::endl;
void MainBufferTest::setUp()
{
}
void MainBufferTest::tearDown()
{
}
void MainBufferTest::testRingBufferCreation()
{
DEBUG("-------------------- MainBufferTest::testRingBufferCreation --------------------\n");
TITLE();
std::string test_id = "1234";
std::string null_id = "null id";
......@@ -111,8 +82,7 @@ void MainBufferTest::testRingBufferCreation()
void MainBufferTest::testRingBufferReadPointer()
{
DEBUG("-------------------- MainBufferTest::testRingBufferReadPointer --------------------\n");
TITLE();
std::string call_id = "call id";
std::string read_id = "read id";
std::string null_id = "null id";
......@@ -158,7 +128,7 @@ void MainBufferTest::testRingBufferReadPointer()
void MainBufferTest::testCallIDSet()
{
DEBUG("-------------------- MainBufferTest::testCallIDSet --------------------\n");
TITLE();
std::string test_id = "set id";
std::string false_id = "false set id";
......@@ -239,7 +209,7 @@ void MainBufferTest::testCallIDSet()
void MainBufferTest::testRingBufferInt()
{
DEBUG("-------------------- MainBufferTest::testRingBufferInt --------------------\n");
TITLE();
// CallID test_id = "test_int";
......@@ -353,7 +323,7 @@ void MainBufferTest::testRingBufferInt()
void MainBufferTest::testRingBufferNonDefaultID()
{
DEBUG("-------------------- MainBufferTest::testRingBufferNonDefaultID --------------------\n");
TITLE();
std::string test_id = "test_int";
......@@ -440,8 +410,7 @@ void MainBufferTest::testRingBufferNonDefaultID()
void MainBufferTest::testRingBufferFloat()
{
DEBUG("-------------------- MainBufferTest::testRingBufferFloat --------------------\n");
TITLE();
float testfloat1 = 12.5;
float testfloat2 = 13.4;
......@@ -474,8 +443,7 @@ void MainBufferTest::testRingBufferFloat()
void MainBufferTest::testTwoPointer()
{
DEBUG("-------------------- MainBufferTest::testTwoPointer --------------------\n");
TITLE();
RingBuffer* input_buffer = mainbuffer_.createRingBuffer(default_id);
input_buffer->createReadPointer(default_id);
RingBuffer* output_buffer = mainbuffer_.getRingBuffer(default_id);
......@@ -491,7 +459,7 @@ void MainBufferTest::testTwoPointer()
void MainBufferTest::testBindUnbindBuffer()
{
DEBUG("-------------------- MainBufferTest::testBindUnbindBuffer --------------------\n");
TITLE();
std::string test_id1 = "bind unbind 1";
std::string test_id2 = "bind unbind 2";
......@@ -890,8 +858,7 @@ void MainBufferTest::testBindUnbindBuffer()
void MainBufferTest::testGetPutDataByID()
{
DEBUG("-------------------- MainBufferTest::testGetPutDataByID --------------------\n");
TITLE();
std::string test_id = "getData putData";
std::string false_id = "false id";
......@@ -942,10 +909,9 @@ void MainBufferTest::testGetPutDataByID()
}
void MainBufferTest::testGetPutData()
{
DEBUG("-------------------- MainBufferTest::testGetPutData --------------------\n");
TITLE();
std::string test_id = "incoming rtp session";
......@@ -993,8 +959,7 @@ void MainBufferTest::testGetPutData()
void MainBufferTest::testDiscardFlush()
{
DEBUG("-------------------- MainBufferTest::testDiscardFlush --------------------\n");
TITLE();
std::string test_id = "flush discard";
// mainbuffer_.createRingBuffer(test_id);
mainbuffer_.bindCallID(test_id);
......@@ -1035,8 +1000,7 @@ void MainBufferTest::testDiscardFlush()
void MainBufferTest::testReadPointerInit()
{
DEBUG("-------------------- MainBufferTest::testReadPointerInit --------------------\n");
TITLE();
std::string test_id = "test read pointer init";
// RingBuffer* test_ring_buffer = mainbuffer_.createRingBuffer(test_id);
......@@ -1063,7 +1027,7 @@ void MainBufferTest::testReadPointerInit()
void MainBufferTest::testRingBufferSeveralPointers()
{
DEBUG("-------------------- MainBufferTest::testRingBufferSeveralPointers --------------------\n");
TITLE();
std::string test_id = "test multiple read pointer";
RingBuffer* test_ring_buffer = mainbuffer_.createRingBuffer(test_id);
......@@ -1176,7 +1140,7 @@ void MainBufferTest::testRingBufferSeveralPointers()
void MainBufferTest::testConference()
{
DEBUG("-------------------- MainBufferTest::testConference --------------------\n");
TITLE();
std::string test_id1 = "participant A";
std::string test_id2 = "participant B";
......
......@@ -34,39 +34,14 @@
#include <cppunit/TestCase.h>
#include <cppunit/TestSuite.h>
#include <assert.h>
#include <stdio.h>
#include <sstream>
#include <ccrtp/rtp.h>
// pjsip import
#include <pjsip.h>
#include <pjlib.h>
#include <pjsip_ua.h>
#include <pjlib-util.h>
#include <pjnath/stun_config.h>
// Application import
#include "manager.h"
#include "audio/mainbuffer.h"
#include "audio/ringbuffer.h"
#include "call.h"
// #include "config/config.h"
// #include "user_cfg.h"
/*
* @file audiorecorderTest.cpp
* @brief Regroups unitary tests related to the plugin manager.
* @brief Regroups unit tests related to the main buffer.
*/
#ifndef _MAINBUFFER_TEST_
#define _MAINBUFFER_TEST_
#ifndef MAINBUFFER_TEST_
#define MAINBUFFER_TEST_
class MainBufferTest : public CppUnit::TestCase {
......@@ -94,18 +69,6 @@ class MainBufferTest : public CppUnit::TestCase {
MainBufferTest() : CppUnit::TestCase("Audio Layer Tests") {}
/*
* Code factoring - Common resources can be initialized here.
* This method is called by unitcpp before each test
*/
void setUp();
/*
* Code factoring - Common resources can be released here.
* This method is called by unitcpp after each test
*/
void tearDown();
void testRingBufferCreation();
void testRingBufferReadPointer();
......
......@@ -34,4 +34,9 @@
#define TITLE() DEBUG("-------------------- %s --------------------\n", \
__PRETTY_FUNCTION__)
// Returns the number of elements in a, calculated at compile-time
#define ARRAYSIZE(a) \
((sizeof(a) / sizeof(*(a))) / \
static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
#endif // TEST_UTILS_H_
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment