make string tests build on unix

git-svn-id: svn://10.0.0.236/trunk@64090 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
pavlov%netscape.com
2000-03-25 01:59:19 +00:00
parent 700229a0c8
commit 550e39bc3f
3 changed files with 474 additions and 19 deletions

View File

@@ -5,8 +5,11 @@
#include <iostream.h>
#include <string>
#include <iomanip>
#include <sys/time.h>
#ifdef XP_MAC
#include "Profiler.h"
#endif
#ifndef TEST_STD_STRING
#include "nsString.h"
@@ -15,8 +18,6 @@
typedef nsStdCString nsCString;
#endif
#include <Timer.h>
static const int kTestSucceeded = 0;
static const int kTestFailed = 1;
@@ -55,37 +56,31 @@ Find( const string& text, const string& pattern )
return text.find(pattern);
}
#ifndef HAVE_LONG_LONG
inline
UnsignedWide
operator-( const UnsignedWide& lhs, const UnsignedWide& rhs )
PRUint64
operator-( const PRUint64& lhs, const PRUint64& rhs )
{
PRInt64 a = LL_INIT(lhs.hi, lhs.lo);
PRInt64 b = LL_INIT(rhs.hi, rhs.lo);
PRInt64 c;
LL_SUB(c, a, b);
UnsignedWide result = {c.hi, c.lo};
PRInt64 result;
LL_SUB(result, lhs, rhs);
return result;
}
#endif
class TestTimer
{
public:
TestTimer() { Microseconds(&mStartTime); }
TestTimer() : mStartTime(PR_Now()) { }
~TestTimer()
{
UnsignedWide stopTime;
Microseconds(&stopTime);
UnsignedWide totalTime = stopTime - mStartTime;
if ( totalTime.hi )
cout << "*";
cout << setw(10) << totalTime.lo << " µs : ";
PRTime stopTime = PR_Now();
PRTime totalTime = stopTime - mStartTime;
cout << setw(10) << totalTime << " µs : ";
}
private:
UnsignedWide mStartTime;
PRTime mStartTime;
};
static
@@ -335,6 +330,11 @@ class Profiler
#endif
}
void
Dump( const char* output_name )
{
}
void
Dump( const unsigned char* output_name )
{