Fix build of unit-tests with gcc4.

This commit is contained in:
Oliver Tappe
2014-06-11 11:43:12 +02:00
parent bab4c96c5c
commit 77aa0e2a5e
35 changed files with 126 additions and 82 deletions
@@ -212,18 +212,21 @@ TranslateTests(STXTTranslatorTest *ptest, BTranslatorRoster *proster,
styled_path = new char[nlongest + 6];
plain_path = new char[nlongest + 6];
BFile styled_file, plain_file;
// Perform translations on every file in the array
for (int32 i = 0; i < len; i++) {
strcpy(styled_path, paths[i]);
strcat(styled_path, ".stxt");
strcpy(plain_path, paths[i]);
strcat(plain_path, ".txt");
// Setup input files
// Setup input files
ptest->NextSubTest();
BFile styled_file, plain_file, *pinput_file;
CPPUNIT_ASSERT(styled_file.SetTo(styled_path, B_READ_ONLY) == B_OK);
CPPUNIT_ASSERT(plain_file.SetTo(plain_path, B_READ_ONLY) == B_OK);
BFile *pinput_file;
if (bplain) {
printf(" [%s] ", plain_path);
pinput_file = &plain_file;
@@ -231,9 +234,9 @@ TranslateTests(STXTTranslatorTest *ptest, BTranslatorRoster *proster,
printf(" [%s] ", styled_path);
pinput_file = &styled_file;
}
BMallocIO mallio, dmallio;
// Convert to B_TRANSLATOR_ANY_TYPE (should be B_TRANSLATOR_TEXT)
ptest->NextSubTest();
CPPUNIT_ASSERT(mallio.Seek(0, SEEK_SET) == 0);
@@ -241,7 +244,7 @@ TranslateTests(STXTTranslatorTest *ptest, BTranslatorRoster *proster,
CPPUNIT_ASSERT(proster->Translate(pinput_file, NULL, NULL, &mallio,
B_TRANSLATOR_ANY_TYPE) == B_OK);
CPPUNIT_ASSERT(CompareStreams(mallio, plain_file) == true);
// Convert to B_TRANSLATOR_TEXT
ptest->NextSubTest();
CPPUNIT_ASSERT(mallio.Seek(0, SEEK_SET) == 0);
@@ -249,7 +252,7 @@ TranslateTests(STXTTranslatorTest *ptest, BTranslatorRoster *proster,
CPPUNIT_ASSERT(proster->Translate(pinput_file, NULL, NULL, &mallio,
B_TRANSLATOR_TEXT) == B_OK);
CPPUNIT_ASSERT(CompareStreams(mallio, plain_file) == true);
// Convert plain mallio to B_TRANSLATOR_TEXT dmallio
ptest->NextSubTest();
CPPUNIT_ASSERT(dmallio.Seek(0, SEEK_SET) == 0);
@@ -257,7 +260,7 @@ TranslateTests(STXTTranslatorTest *ptest, BTranslatorRoster *proster,
CPPUNIT_ASSERT(proster->Translate(&mallio, NULL, NULL, &dmallio,
B_TRANSLATOR_TEXT) == B_OK);
CPPUNIT_ASSERT(CompareStreams(dmallio, plain_file) == true);
// Convert to B_STYLED_TEXT_FORMAT
ptest->NextSubTest();
CPPUNIT_ASSERT(mallio.Seek(0, SEEK_SET) == 0);
@@ -265,7 +268,7 @@ TranslateTests(STXTTranslatorTest *ptest, BTranslatorRoster *proster,
CPPUNIT_ASSERT(proster->Translate(pinput_file, NULL, NULL, &mallio,
B_STYLED_TEXT_FORMAT) == B_OK);
CPPUNIT_ASSERT(CompareStreams(mallio, styled_file) == true);
// Convert styled mallio to B_TRANSLATOR_TEXT dmallio
ptest->NextSubTest();
CPPUNIT_ASSERT(dmallio.Seek(0, SEEK_SET) == 0);
@@ -273,7 +276,7 @@ TranslateTests(STXTTranslatorTest *ptest, BTranslatorRoster *proster,
CPPUNIT_ASSERT(proster->Translate(&mallio, NULL, NULL, &dmallio,
B_TRANSLATOR_TEXT) == B_OK);
CPPUNIT_ASSERT(CompareStreams(dmallio, plain_file) == true);
// Convert styled mallio to B_STYLED_TEXT_FORMAT dmallio
ptest->NextSubTest();
CPPUNIT_ASSERT(dmallio.Seek(0, SEEK_SET) == 0);
@@ -341,7 +341,7 @@ LaunchContext::AppMessengerFor(team_id team) const
{
BAutolock _lock(fLock);
BMessenger result;
if (AppInfo *info = AppInfoFor(team)) {
if (AppInfoFor(team)) {
// We need to do some hacking.
BMessenger messenger;
struct fake_messenger {
@@ -3,7 +3,6 @@
#include <cppunit/Test.h>
#include <cppunit/TestCaller.h>
#include <cppunit/TestSuite.h>
#include <iostream.h>
#include <stdio.h>
#include <string.h>
#include <Application.h>
@@ -13,6 +12,9 @@
#include <Button.h>
#include <Rect.h>
#include <iostream>
using std::ostream;
#define ASSERT_DEQUAL(x,y) CPPUNIT_ASSERT_DOUBLES_EQUAL((x),(y),0.01)
const char *k20X = "XXXXXXXXXXXXXXXXXXXX";
@@ -17,6 +17,8 @@
#include <Entry.h>
#include <image.h>
#include <assert.h>
const char *appName = "application/x-vnd.jsr-additemtest";
const char *pulsePath = "/boot/system/apps/Pulse";
@@ -14,6 +14,8 @@
#include "DeskbarGetItemTest.h"
#include <Deskbar.h>
#include <assert.h>
/*
* Method: DeskbarGetItemTest::DeskbarGetItemTest()
@@ -15,6 +15,8 @@
#include <Deskbar.h>
#include <InterfaceDefs.h>
#include <assert.h>
/*
* Method: DeskbarLocationTest::DeskbarLocationTest()
@@ -22,6 +22,8 @@
#include <Rect.h>
#include <Polygon.h>
#include <assert.h>
/*
* Method: CreatePolygonTest::CreatePolygonTest()
@@ -15,6 +15,8 @@
#include <Rect.h>
#include <Polygon.h>
#include <assert.h>
/*
* Method: MapPolygonTest::MapPolygonTest()
@@ -11,6 +11,8 @@
#include <Region.h>
#include <Rect.h>
#include <assert.h>
/*
* Method: RegionConstruction::RegionConstruction()
@@ -11,6 +11,8 @@
#include <Region.h>
#include <Rect.h>
#include <assert.h>
/*
* Method: RegionExclude::RegionExclude()
@@ -11,6 +11,8 @@
#include <Region.h>
#include <Rect.h>
#include <assert.h>
/*
* Method: RegionInclude::RegionInclude()
@@ -11,6 +11,8 @@
#include <Region.h>
#include <Rect.h>
#include <assert.h>
/*
* Method: RegionIntersect::RegionIntersect()
@@ -11,6 +11,8 @@
#include <Region.h>
#include <Rect.h>
#include <assert.h>
/*
* Method: RegionOffsetBy::RegionOffsetBy()
@@ -10,6 +10,8 @@
#include "RegionTestcase.h"
#include <Region.h>
#include <Rect.h>
#include <assert.h>
#include <math.h>
+4 -2
View File
@@ -1,13 +1,15 @@
// BasicTest.cpp
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string>
#include <set>
using std::set;
#include "BasicTest.h"
// count_available_fds
#include <set>
static
int32
count_available_fds()
+6 -1
View File
@@ -6,9 +6,14 @@
#include <SupportDefs.h>
#include <TestCase.h>
#include <TestShell.h>
#include <set>
#include <stdio.h>
#include <set>
using std::set;
#include <string>
using std::string;
class BasicTest : public BTestCase
{
public:
+4 -1
View File
@@ -1,10 +1,13 @@
// DirectoryTest.cpp
#include <stdio.h>
#include <string>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <string>
using std::string;
#include <Directory.h>
#include <Entry.h>
#include <File.h>
+8 -3
View File
@@ -1,12 +1,17 @@
// EntryTest.cpp
#include <errno.h>
#include <list>
#include <map>
#include <set>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <list>
using std::list;
#include <map>
using std::map;
#include <set>
using std::set;
#include <cppunit/TestCaller.h>
#include <cppunit/TestSuite.h>
+4 -1
View File
@@ -2,9 +2,12 @@
#include <errno.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <unistd.h>
#include <string>
using std::string;
#include "FindDirectoryTest.h"
#include <FindDirectory.h>
+8 -5
View File
@@ -13,7 +13,10 @@
#include <TestUtils.h>
#include <stdio.h>
#include <string>
#include <iostream>
using std::cout;
using std::endl;
using namespace BPrivate::Storage::Sniffer;
@@ -736,10 +739,10 @@ MimeSnifferTest::ScannerTest() {
};
// Undefine our nasty macros
#undef T(type)
#undef S(str)
#undef I(val)
#undef F(val)
#undef T
#undef S
#undef I
#undef F
const int testCaseCount = sizeof(testCases) / sizeof(test_case);
for (int i = 0; i < testCaseCount; i++) {
+4 -1
View File
@@ -1,9 +1,12 @@
// NodeInfoTest.cpp
#include <stdio.h>
#include <string>
#include <string.h>
#include <unistd.h>
#include <string>
using std::string;
#include <Application.h>
#include <Bitmap.h>
#include <Directory.h>
+5 -1
View File
@@ -9,9 +9,13 @@
#include <Path.h>
#include <TypeConstants.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <unistd.h>
#include <string>
using std::string;
// Suite
CppUnit::Test*
PathTest::Suite() {
+2
View File
@@ -95,6 +95,7 @@ public:
};
// float specialization
template<>
BString
ValueNode<float>::toString() const
{
@@ -104,6 +105,7 @@ ValueNode<float>::toString() const
}
// double specialization
template<>
BString
ValueNode<double>::toString() const
{
+5 -1
View File
@@ -1,9 +1,13 @@
// ResourcesTest.cpp
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <unistd.h>
#include <string>
using std::string;
#include <vector>
using std::vector;
#include <ByteOrder.h>
#include <File.h>
+6 -6
View File
@@ -7,7 +7,7 @@
#include <cppunit/TestSuite.h>
#include <list>
#include <string>
using std::list;
#include "BasicTest.h"
@@ -27,7 +27,7 @@ struct TestEntries
void delete_all()
{
for (list<C*>::iterator it = entries.begin();
for (typename list<C*>::iterator it = entries.begin();
it != entries.end();
it++) {
// Arghh, BStatable has no virtual destructor!
@@ -74,10 +74,10 @@ struct TestEntries
entryNameIt = entryNames.begin();
}
list<C*> entries;
list<string> entryNames;
list<C*>::iterator entryIt;
list<string>::iterator entryNameIt;
list<C*> entries;
list<string> entryNames;
typename list<C*>::iterator entryIt;
typename list<string>::iterator entryNameIt;
};
typedef TestEntries<BStatable> TestStatables;
+3
View File
@@ -1,7 +1,10 @@
// SymLinkTest.cpp
#include <stdio.h>
#include <string.h>
#include <string>
using std::string;
#include <Directory.h>
#include <Entry.h>
+1
View File
@@ -1,6 +1,7 @@
// TestApp.cpp
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <Autolock.h>
@@ -31,11 +31,14 @@
// DEALINGS IN THE SOFTWARE.
/*****************************************************************************/
#include "BitmapStreamTest.h"
#include <stdio.h>
#include <TranslatorRoster.h>
#include <Application.h>
#include <Bitmap.h>
#include <stdio.h>
#include <string.h>
/* cppunit framework */
#include <cppunit/Test.h>
#include <cppunit/TestCaller.h>
@@ -31,7 +31,6 @@
// DEALINGS IN THE SOFTWARE.
/*****************************************************************************/
#include "TranslationUtilsTest.h"
#include <stdio.h>
#include <TranslatorFormats.h>
// for B_TRANSLATOR_EXT_*
#include <TranslatorRoster.h>
@@ -44,6 +43,9 @@
#include <Entry.h>
#include <OS.h>
#include <stdio.h>
#include <string.h>
/* cppunit framework */
#include <cppunit/Test.h>
#include <cppunit/TestCaller.h>
@@ -33,6 +33,7 @@
#include "TranslatorRosterTest.h"
#include <stdio.h>
#include <string.h>
#include <Application.h>
#include <Archivable.h>
@@ -106,7 +106,8 @@ DoublyLinkedListTest::TestList()
// count items in list
int count = 0;
DoublyLinkedList<Item, DoublyLinkedListMemberGetLink<Item> >::Iterator
typename DoublyLinkedList<Item,
DoublyLinkedListMemberGetLink<Item> >::Iterator
iterator = list.GetIterator();
while (iterator.Next() != NULL)
count++;
+3 -29
View File
@@ -6,6 +6,8 @@
#include <stdio.h>
#include <stdlib.h>
using std::map;
#include <TestCase.h>
#include <TestUtils.h>
#include <cppunit/Test.h>
@@ -601,7 +603,7 @@ public:
typedef typename KeyStrategy::Value Key;
typedef typename ValueStrategy::Value Value;
// typedef _CompareStrategy<Key> Compare;
typedef typename CompareStrategyWrapper::Strategy<Key> Compare;
typedef typename CompareStrategyWrapper::template Strategy<Key> Compare;
typedef CompareWrapper<Key, Compare> BoolCompare;
typedef _MyMap<Compare> MyMap;
typedef map<Key, Value, BoolCompare> ReferenceMap;
@@ -664,8 +666,6 @@ void
GenericInsertTest(int32 maxNumber)
{
typedef typename _TestStrategy::EntryStrategy EntryStrategy;
typedef typename _TestStrategy::KeyStrategy KeyStrategy;
typedef typename _TestStrategy::ValueStrategy ValueStrategy;
typedef typename _TestStrategy::Key Key;
typedef typename _TestStrategy::Value Value;
typedef typename _TestStrategy::TestClass TestClass;
@@ -707,8 +707,6 @@ void
GenericPutTest(int32 maxNumber)
{
typedef typename _TestStrategy::EntryStrategy EntryStrategy;
typedef typename _TestStrategy::KeyStrategy KeyStrategy;
typedef typename _TestStrategy::ValueStrategy ValueStrategy;
typedef typename _TestStrategy::Key Key;
typedef typename _TestStrategy::Value Value;
typedef typename _TestStrategy::TestClass TestClass;
@@ -750,13 +748,10 @@ void
GenericGetTest(int32 maxNumber)
{
typedef typename _TestStrategy::EntryStrategy EntryStrategy;
typedef typename _TestStrategy::KeyStrategy KeyStrategy;
typedef typename _TestStrategy::ValueStrategy ValueStrategy;
typedef typename _TestStrategy::Key Key;
typedef typename _TestStrategy::Value Value;
typedef typename _TestStrategy::TestClass TestClass;
typedef typename TestClass::Iterator Iterator;
typedef typename TestClass::ConstIterator ConstIterator;
EntryStrategy entryStrategy;
TestClass v;
GenericFill(v, entryStrategy, maxNumber);
@@ -818,10 +813,7 @@ void
GenericRemoveTest(int32 maxNumber)
{
typedef typename _TestStrategy::EntryStrategy EntryStrategy;
typedef typename _TestStrategy::KeyStrategy KeyStrategy;
typedef typename _TestStrategy::ValueStrategy ValueStrategy;
typedef typename _TestStrategy::Key Key;
typedef typename _TestStrategy::Value Value;
typedef typename _TestStrategy::TestClass TestClass;
EntryStrategy entryStrategy;
TestClass v;
@@ -862,10 +854,6 @@ void
GenericEraseTest(int32 maxNumber)
{
typedef typename _TestStrategy::EntryStrategy EntryStrategy;
typedef typename _TestStrategy::KeyStrategy KeyStrategy;
typedef typename _TestStrategy::ValueStrategy ValueStrategy;
typedef typename _TestStrategy::Key Key;
typedef typename _TestStrategy::Value Value;
typedef typename _TestStrategy::TestClass TestClass;
EntryStrategy entryStrategy;
TestClass v;
@@ -904,10 +892,6 @@ void
GenericMakeEmptyTest(int32 maxNumber)
{
typedef typename _TestStrategy::EntryStrategy EntryStrategy;
typedef typename _TestStrategy::KeyStrategy KeyStrategy;
typedef typename _TestStrategy::ValueStrategy ValueStrategy;
typedef typename _TestStrategy::Key Key;
typedef typename _TestStrategy::Value Value;
typedef typename _TestStrategy::TestClass TestClass;
EntryStrategy entryStrategy;
TestClass v;
@@ -945,10 +929,7 @@ void
GenericFindTest(int32 maxNumber)
{
typedef typename _TestStrategy::EntryStrategy EntryStrategy;
typedef typename _TestStrategy::KeyStrategy KeyStrategy;
typedef typename _TestStrategy::ValueStrategy ValueStrategy;
typedef typename _TestStrategy::Key Key;
typedef typename _TestStrategy::Value Value;
typedef typename _TestStrategy::TestClass TestClass;
typedef typename TestClass::Iterator Iterator;
typedef typename TestClass::ConstIterator ConstIterator;
@@ -1010,10 +991,7 @@ void
GenericFindCloseTest(int32 maxNumber)
{
typedef typename _TestStrategy::EntryStrategy EntryStrategy;
typedef typename _TestStrategy::KeyStrategy KeyStrategy;
typedef typename _TestStrategy::ValueStrategy ValueStrategy;
typedef typename _TestStrategy::Key Key;
typedef typename _TestStrategy::Value Value;
typedef typename _TestStrategy::TestClass TestClass;
typedef typename TestClass::Iterator Iterator;
typedef typename TestClass::ConstIterator ConstIterator;
@@ -1093,10 +1071,6 @@ void
GenericIteratorTest(int32 maxNumber)
{
typedef typename _TestStrategy::EntryStrategy EntryStrategy;
typedef typename _TestStrategy::KeyStrategy KeyStrategy;
typedef typename _TestStrategy::ValueStrategy ValueStrategy;
typedef typename _TestStrategy::Key Key;
typedef typename _TestStrategy::Value Value;
typedef typename _TestStrategy::TestClass TestClass;
typedef typename TestClass::Iterator Iterator;
typedef typename TestClass::ConstIterator ConstIterator;
@@ -83,7 +83,7 @@ string_hash(const char *name)
{
uint32 h = 0;
for (; *name; name++) {
if (uint32 g = g & 0xf0000000)
if (uint32 g = h & 0xf0000000)
h ^= g >> 24;
h = (h << 4) + *name;
}
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <set>
using std::set;
#include <TestUtils.h>
#include <cppunit/Test.h>
@@ -518,7 +519,6 @@ void
GenericInsertTest(int32 maxNumber)
{
typedef typename _TestStrategy::ValueStrategy ValueStrategy;
typedef typename _TestStrategy::Value Value;
typedef typename _TestStrategy::TestClass TestClass;
ValueStrategy strategy;
TestClass v;
@@ -610,7 +610,6 @@ void
GenericEraseTest(int32 maxNumber)
{
typedef typename _TestStrategy::ValueStrategy ValueStrategy;
typedef typename _TestStrategy::Value Value;
typedef typename _TestStrategy::TestClass TestClass;
ValueStrategy strategy;
TestClass v;
@@ -650,7 +649,6 @@ void
GenericMakeEmptyTest(int32 maxNumber)
{
typedef typename _TestStrategy::ValueStrategy ValueStrategy;
typedef typename _TestStrategy::Value Value;
typedef typename _TestStrategy::TestClass TestClass;
ValueStrategy strategy;
TestClass v;
@@ -810,7 +808,6 @@ void
GenericIteratorTest(int32 maxNumber)
{
typedef typename _TestStrategy::ValueStrategy ValueStrategy;
typedef typename _TestStrategy::Value Value;
typedef typename _TestStrategy::TestClass TestClass;
typedef typename TestClass::Iterator Iterator;
typedef typename TestClass::ConstIterator ConstIterator;
+12 -11
View File
@@ -190,10 +190,10 @@ public:
template<typename Value>
class TestVector {
public:
typedef Vector<Value>::Iterator MyIterator;
typedef vector<Value>::iterator ReferenceIterator;
typedef Vector<Value>::ConstIterator MyConstIterator;
typedef vector<Value>::const_iterator ReferenceConstIterator;
typedef typename Vector<Value>::Iterator MyIterator;
typedef typename vector<Value>::iterator ReferenceIterator;
typedef typename Vector<Value>::ConstIterator MyConstIterator;
typedef typename vector<Value>::const_iterator ReferenceConstIterator;
typedef TestIterator<Value, TestVector<Value>, MyIterator,
ReferenceIterator> Iterator;
typedef TestIterator<const Value, const TestVector<Value>, MyConstIterator,
@@ -238,7 +238,7 @@ public:
{
if (index >= 0 && index <= Count()) {
CHK(fMyVector.Insert(value, index) == B_OK);
vector<Value>::iterator it = fReferenceVector.begin();
typename vector<Value>::iterator it = fReferenceVector.begin();
for (int32 i = 0; i < index; i++)
++it;
fReferenceVector.insert(it, value);
@@ -873,9 +873,10 @@ GenericFindTest(ValueStrategy strategy, int32 maxNumber)
// find the values in the vector
const TestVector<Value> &cv = v;
for (int32 i = 0; i < maxNumber; i++) {
TestVector<Value>::ConstIterator cit = cv.Begin();
typename TestVector<Value>::ConstIterator cit = cv.Begin();
int32 index = 0;
for (TestVector<Value>::Iterator it = v.Begin(); it != v.End(); ) {
for (typename TestVector<Value>::Iterator it = v.Begin();
it != v.End(); ) {
CHK(&v[index] == &*it);
CHK(&cv[index] == &*cit);
CHK(*it == *cit);
@@ -887,8 +888,8 @@ GenericFindTest(ValueStrategy strategy, int32 maxNumber)
// try to find some random values
for (int32 i = 0; i < maxNumber; i++) {
Value value = strategy.Generate();
TestVector<Value>::Iterator it = v.Find(value);
TestVector<Value>::ConstIterator cit = cv.Find(value);
typename TestVector<Value>::Iterator it = v.Find(value);
typename TestVector<Value>::ConstIterator cit = cv.Find(value);
if (it != v.End())
CHK(&*it == &*cit);
}
@@ -926,8 +927,8 @@ GenericIteratorTest(ValueStrategy strategy, int32 maxNumber)
TestVector<Value> v;
GenericFill(v, strategy, maxNumber);
const TestVector<Value> &cv = v;
TestVector<Value>::Iterator it = v.Begin();
TestVector<Value>::ConstIterator cit = cv.Begin();
typename TestVector<Value>::Iterator it = v.Begin();
typename TestVector<Value>::ConstIterator cit = cv.Begin();
for (; it != v.End(); ++it, ++cit) {
CHK(&*it == &*cit);
CHK(&*it == it.operator->());