moved CompareStreams function from STXTTranslatorTest to this file so that multiple translators tests could use it
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3123 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
25b288e0dd
commit
1f52e8a2df
@ -1,11 +1,50 @@
|
||||
#include <TestSuite.h>
|
||||
#include <TestSuiteAddon.h>
|
||||
// TranslatorTestAddOn.cpp
|
||||
|
||||
#include <stdio.h>
|
||||
#include "TranslatorTestAddOn.h"
|
||||
|
||||
// ##### Include headers for your tests here #####
|
||||
#include "bmptranslator/BMPTranslatorTest.h"
|
||||
#include "stxttranslator/STXTTranslatorTest.h"
|
||||
#include "tifftranslator/TIFFTranslatorTest.h"
|
||||
|
||||
// helper function used by multiple tests to
|
||||
// determine if the given streams are exactly
|
||||
// the same
|
||||
bool
|
||||
CompareStreams(BPositionIO &a, BPositionIO &b)
|
||||
{
|
||||
off_t alen = 0, blen = 0;
|
||||
uint8 *abuf = NULL, *bbuf = NULL;
|
||||
|
||||
a.Seek(0, SEEK_END);
|
||||
alen = a.Position();
|
||||
b.Seek(0, SEEK_END);
|
||||
blen = b.Position();
|
||||
|
||||
if (alen != blen)
|
||||
return false;
|
||||
|
||||
bool bresult = false;
|
||||
abuf = new uint8[alen];
|
||||
bbuf = new uint8[blen];
|
||||
if (a.ReadAt(0, abuf, alen) == alen) {
|
||||
if (b.ReadAt(0, bbuf, blen) == blen) {
|
||||
if (memcmp(abuf, bbuf, alen) == 0)
|
||||
bresult = true;
|
||||
else
|
||||
bresult = false;
|
||||
}
|
||||
}
|
||||
|
||||
delete[] abuf;
|
||||
abuf = NULL;
|
||||
delete[] bbuf;
|
||||
bbuf = NULL;
|
||||
|
||||
return bresult;
|
||||
}
|
||||
|
||||
BTestSuite *
|
||||
getTestSuite()
|
||||
{
|
||||
|
12
src/tests/add-ons/translators/TranslatorTestAddOn.h
Normal file
12
src/tests/add-ons/translators/TranslatorTestAddOn.h
Normal file
@ -0,0 +1,12 @@
|
||||
// TranslatorTestAddOn.h
|
||||
|
||||
#ifndef TRANSLATOR_TEST_ADD_ON_H
|
||||
#define TRANSLATOR_TEST_ADD_ON_H
|
||||
|
||||
#include <TestSuite.h>
|
||||
#include <TestSuiteAddon.h>
|
||||
#include <DataIO.h>
|
||||
|
||||
bool CompareStreams(BPositionIO &a, BPositionIO &b);
|
||||
|
||||
#endif // #ifndef TRANSLATOR_TEST_ADD_ON_H
|
Loading…
Reference in New Issue
Block a user