added a few assertions, just to be safe
This commit is contained in:
@@ -154,7 +154,7 @@ PRInt32 nsCRT::strlen(const PRUnichar* s)
|
|||||||
* NOTE: If both are null, we return 0.
|
* NOTE: If both are null, we return 0.
|
||||||
* @update gess7/30/98
|
* @update gess7/30/98
|
||||||
* @param s1 and s2 both point to unichar strings
|
* @param s1 and s2 both point to unichar strings
|
||||||
* @return 1 if they match, 0 if not
|
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
|
||||||
*/
|
*/
|
||||||
PRInt32 nsCRT::strcmp(const PRUnichar* s1, const PRUnichar* s2)
|
PRInt32 nsCRT::strcmp(const PRUnichar* s1, const PRUnichar* s2)
|
||||||
{
|
{
|
||||||
@@ -177,7 +177,7 @@ PRInt32 nsCRT::strcmp(const PRUnichar* s1, const PRUnichar* s2)
|
|||||||
* NOTE: If either is null, we return 0.
|
* NOTE: If either is null, we return 0.
|
||||||
* @update gess7/30/98
|
* @update gess7/30/98
|
||||||
* @param s1 and s2 both point to unichar strings
|
* @param s1 and s2 both point to unichar strings
|
||||||
* @return 1 if they match, 0 if not
|
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
|
||||||
*/
|
*/
|
||||||
PRInt32 nsCRT::strncmp(const PRUnichar* s1, const PRUnichar* s2, PRInt32 n)
|
PRInt32 nsCRT::strncmp(const PRUnichar* s1, const PRUnichar* s2, PRInt32 n)
|
||||||
{
|
{
|
||||||
@@ -204,7 +204,7 @@ PRInt32 nsCRT::strncmp(const PRUnichar* s1, const PRUnichar* s2, PRInt32 n)
|
|||||||
* NOTE: If both are null, we return 0.
|
* NOTE: If both are null, we return 0.
|
||||||
* @update gess7/30/98
|
* @update gess7/30/98
|
||||||
* @param s1 and s2 both point to unichar strings
|
* @param s1 and s2 both point to unichar strings
|
||||||
* @return 1 if they match, 0 if not
|
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
|
||||||
*/
|
*/
|
||||||
PRInt32 nsCRT::strcasecmp(const PRUnichar* s1, const PRUnichar* s2)
|
PRInt32 nsCRT::strcasecmp(const PRUnichar* s1, const PRUnichar* s2)
|
||||||
{
|
{
|
||||||
@@ -232,7 +232,7 @@ PRInt32 nsCRT::strcasecmp(const PRUnichar* s1, const PRUnichar* s2)
|
|||||||
* NOTE: If both are null, we return 0.
|
* NOTE: If both are null, we return 0.
|
||||||
* @update gess7/30/98
|
* @update gess7/30/98
|
||||||
* @param s1 and s2 both point to unichar strings
|
* @param s1 and s2 both point to unichar strings
|
||||||
* @return 1 if they match, 0 if not
|
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
|
||||||
*/
|
*/
|
||||||
PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const PRUnichar* s2, PRInt32 n)
|
PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const PRUnichar* s2, PRInt32 n)
|
||||||
{
|
{
|
||||||
@@ -263,7 +263,7 @@ PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const PRUnichar* s2, PRInt32 n)
|
|||||||
* @update gess7/30/98
|
* @update gess7/30/98
|
||||||
* @param s1 points to unichar string
|
* @param s1 points to unichar string
|
||||||
* @param s2 points to cstring
|
* @param s2 points to cstring
|
||||||
* @return 1 if they match, 0 if not
|
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
|
||||||
*/
|
*/
|
||||||
PRInt32 nsCRT::strcmp(const PRUnichar* s1, const char* s2)
|
PRInt32 nsCRT::strcmp(const PRUnichar* s1, const char* s2)
|
||||||
{
|
{
|
||||||
@@ -288,7 +288,7 @@ PRInt32 nsCRT::strcmp(const PRUnichar* s1, const char* s2)
|
|||||||
* @update gess7/30/98
|
* @update gess7/30/98
|
||||||
* @param s1 points to unichar string
|
* @param s1 points to unichar string
|
||||||
* @param s2 points to cstring
|
* @param s2 points to cstring
|
||||||
* @return 1 if they match, 0 if not
|
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
|
||||||
*/
|
*/
|
||||||
PRInt32 nsCRT::strncmp(const PRUnichar* s1, const char* s2, PRInt32 n)
|
PRInt32 nsCRT::strncmp(const PRUnichar* s1, const char* s2, PRInt32 n)
|
||||||
{
|
{
|
||||||
@@ -314,7 +314,7 @@ PRInt32 nsCRT::strncmp(const PRUnichar* s1, const char* s2, PRInt32 n)
|
|||||||
* @update gess7/30/98
|
* @update gess7/30/98
|
||||||
* @param s1 points to unichar string
|
* @param s1 points to unichar string
|
||||||
* @param s2 points to cstring
|
* @param s2 points to cstring
|
||||||
* @return 1 if they match, 0 if not
|
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
|
||||||
*/
|
*/
|
||||||
PRInt32 nsCRT::strcasecmp(const PRUnichar* s1, const char* s2)
|
PRInt32 nsCRT::strcasecmp(const PRUnichar* s1, const char* s2)
|
||||||
{
|
{
|
||||||
@@ -342,7 +342,7 @@ PRInt32 nsCRT::strcasecmp(const PRUnichar* s1, const char* s2)
|
|||||||
* @update gess7/30/98
|
* @update gess7/30/98
|
||||||
* @param s1 points to unichar string
|
* @param s1 points to unichar string
|
||||||
* @param s2 points to cstring
|
* @param s2 points to cstring
|
||||||
* @return 1 if they match, 0 if not
|
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
|
||||||
*/
|
*/
|
||||||
PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const char* s2, PRInt32 n)
|
PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const char* s2, PRInt32 n)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -61,8 +61,10 @@ nsString::nsString() {
|
|||||||
NS_ASSERTION(kCommonEmptyBuffer[0]==0,kFoolMsg);
|
NS_ASSERTION(kCommonEmptyBuffer[0]==0,kFoolMsg);
|
||||||
mLength = mCapacity = 0;
|
mLength = mCapacity = 0;
|
||||||
mStr = kCommonEmptyBuffer;
|
mStr = kCommonEmptyBuffer;
|
||||||
if(!mSelfTested)
|
if(!mSelfTested) {
|
||||||
|
mSelfTested=PR_TRUE;
|
||||||
SelfTest();
|
SelfTest();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1869,7 +1871,7 @@ NS_BASE int fputs(const nsString& aString, FILE* out)
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void nsString::SelfTest(void) {
|
void nsString::SelfTest(void) {
|
||||||
#if 1
|
#if 0
|
||||||
|
|
||||||
static const char* kConstructorError = kConstructorError;
|
static const char* kConstructorError = kConstructorError;
|
||||||
static const char* kComparisonError = "Comparision error!";
|
static const char* kComparisonError = "Comparision error!";
|
||||||
@@ -1884,6 +1886,10 @@ void nsString::SelfTest(void) {
|
|||||||
|
|
||||||
//first, let's test the constructors...
|
//first, let's test the constructors...
|
||||||
nsString empty;
|
nsString empty;
|
||||||
|
empty="";
|
||||||
|
empty="xxx";
|
||||||
|
empty="";
|
||||||
|
|
||||||
nsString a(temp);
|
nsString a(temp);
|
||||||
nsString* a_=new nsString(a); //test copy constructor
|
nsString* a_=new nsString(a); //test copy constructor
|
||||||
nsString b("world!");
|
nsString b("world!");
|
||||||
@@ -1961,6 +1967,7 @@ void nsString::SelfTest(void) {
|
|||||||
const char* bbbb="bbbb";
|
const char* bbbb="bbbb";
|
||||||
|
|
||||||
//First test the string compare routines...
|
//First test the string compare routines...
|
||||||
|
|
||||||
NS_ASSERTION(0>temp8.Compare(temp9),kComparisonError);
|
NS_ASSERTION(0>temp8.Compare(temp9),kComparisonError);
|
||||||
NS_ASSERTION(0<temp9.Compare(temp8),kComparisonError);
|
NS_ASSERTION(0<temp9.Compare(temp8),kComparisonError);
|
||||||
NS_ASSERTION(0==temp8.Compare(temp8a,PR_TRUE),kComparisonError);
|
NS_ASSERTION(0==temp8.Compare(temp8a,PR_TRUE),kComparisonError);
|
||||||
|
|||||||
@@ -61,8 +61,10 @@ nsString::nsString() {
|
|||||||
NS_ASSERTION(kCommonEmptyBuffer[0]==0,kFoolMsg);
|
NS_ASSERTION(kCommonEmptyBuffer[0]==0,kFoolMsg);
|
||||||
mLength = mCapacity = 0;
|
mLength = mCapacity = 0;
|
||||||
mStr = kCommonEmptyBuffer;
|
mStr = kCommonEmptyBuffer;
|
||||||
if(!mSelfTested)
|
if(!mSelfTested) {
|
||||||
|
mSelfTested=PR_TRUE;
|
||||||
SelfTest();
|
SelfTest();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1869,7 +1871,7 @@ NS_BASE int fputs(const nsString& aString, FILE* out)
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void nsString::SelfTest(void) {
|
void nsString::SelfTest(void) {
|
||||||
#if 1
|
#if 0
|
||||||
|
|
||||||
static const char* kConstructorError = kConstructorError;
|
static const char* kConstructorError = kConstructorError;
|
||||||
static const char* kComparisonError = "Comparision error!";
|
static const char* kComparisonError = "Comparision error!";
|
||||||
@@ -1884,6 +1886,10 @@ void nsString::SelfTest(void) {
|
|||||||
|
|
||||||
//first, let's test the constructors...
|
//first, let's test the constructors...
|
||||||
nsString empty;
|
nsString empty;
|
||||||
|
empty="";
|
||||||
|
empty="xxx";
|
||||||
|
empty="";
|
||||||
|
|
||||||
nsString a(temp);
|
nsString a(temp);
|
||||||
nsString* a_=new nsString(a); //test copy constructor
|
nsString* a_=new nsString(a); //test copy constructor
|
||||||
nsString b("world!");
|
nsString b("world!");
|
||||||
@@ -1961,6 +1967,7 @@ void nsString::SelfTest(void) {
|
|||||||
const char* bbbb="bbbb";
|
const char* bbbb="bbbb";
|
||||||
|
|
||||||
//First test the string compare routines...
|
//First test the string compare routines...
|
||||||
|
|
||||||
NS_ASSERTION(0>temp8.Compare(temp9),kComparisonError);
|
NS_ASSERTION(0>temp8.Compare(temp9),kComparisonError);
|
||||||
NS_ASSERTION(0<temp9.Compare(temp8),kComparisonError);
|
NS_ASSERTION(0<temp9.Compare(temp8),kComparisonError);
|
||||||
NS_ASSERTION(0==temp8.Compare(temp8a,PR_TRUE),kComparisonError);
|
NS_ASSERTION(0==temp8.Compare(temp8a,PR_TRUE),kComparisonError);
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ PRInt32 nsCRT::strlen(const PRUnichar* s)
|
|||||||
* NOTE: If both are null, we return 0.
|
* NOTE: If both are null, we return 0.
|
||||||
* @update gess7/30/98
|
* @update gess7/30/98
|
||||||
* @param s1 and s2 both point to unichar strings
|
* @param s1 and s2 both point to unichar strings
|
||||||
* @return 1 if they match, 0 if not
|
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
|
||||||
*/
|
*/
|
||||||
PRInt32 nsCRT::strcmp(const PRUnichar* s1, const PRUnichar* s2)
|
PRInt32 nsCRT::strcmp(const PRUnichar* s1, const PRUnichar* s2)
|
||||||
{
|
{
|
||||||
@@ -177,7 +177,7 @@ PRInt32 nsCRT::strcmp(const PRUnichar* s1, const PRUnichar* s2)
|
|||||||
* NOTE: If either is null, we return 0.
|
* NOTE: If either is null, we return 0.
|
||||||
* @update gess7/30/98
|
* @update gess7/30/98
|
||||||
* @param s1 and s2 both point to unichar strings
|
* @param s1 and s2 both point to unichar strings
|
||||||
* @return 1 if they match, 0 if not
|
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
|
||||||
*/
|
*/
|
||||||
PRInt32 nsCRT::strncmp(const PRUnichar* s1, const PRUnichar* s2, PRInt32 n)
|
PRInt32 nsCRT::strncmp(const PRUnichar* s1, const PRUnichar* s2, PRInt32 n)
|
||||||
{
|
{
|
||||||
@@ -204,7 +204,7 @@ PRInt32 nsCRT::strncmp(const PRUnichar* s1, const PRUnichar* s2, PRInt32 n)
|
|||||||
* NOTE: If both are null, we return 0.
|
* NOTE: If both are null, we return 0.
|
||||||
* @update gess7/30/98
|
* @update gess7/30/98
|
||||||
* @param s1 and s2 both point to unichar strings
|
* @param s1 and s2 both point to unichar strings
|
||||||
* @return 1 if they match, 0 if not
|
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
|
||||||
*/
|
*/
|
||||||
PRInt32 nsCRT::strcasecmp(const PRUnichar* s1, const PRUnichar* s2)
|
PRInt32 nsCRT::strcasecmp(const PRUnichar* s1, const PRUnichar* s2)
|
||||||
{
|
{
|
||||||
@@ -232,7 +232,7 @@ PRInt32 nsCRT::strcasecmp(const PRUnichar* s1, const PRUnichar* s2)
|
|||||||
* NOTE: If both are null, we return 0.
|
* NOTE: If both are null, we return 0.
|
||||||
* @update gess7/30/98
|
* @update gess7/30/98
|
||||||
* @param s1 and s2 both point to unichar strings
|
* @param s1 and s2 both point to unichar strings
|
||||||
* @return 1 if they match, 0 if not
|
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
|
||||||
*/
|
*/
|
||||||
PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const PRUnichar* s2, PRInt32 n)
|
PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const PRUnichar* s2, PRInt32 n)
|
||||||
{
|
{
|
||||||
@@ -263,7 +263,7 @@ PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const PRUnichar* s2, PRInt32 n)
|
|||||||
* @update gess7/30/98
|
* @update gess7/30/98
|
||||||
* @param s1 points to unichar string
|
* @param s1 points to unichar string
|
||||||
* @param s2 points to cstring
|
* @param s2 points to cstring
|
||||||
* @return 1 if they match, 0 if not
|
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
|
||||||
*/
|
*/
|
||||||
PRInt32 nsCRT::strcmp(const PRUnichar* s1, const char* s2)
|
PRInt32 nsCRT::strcmp(const PRUnichar* s1, const char* s2)
|
||||||
{
|
{
|
||||||
@@ -288,7 +288,7 @@ PRInt32 nsCRT::strcmp(const PRUnichar* s1, const char* s2)
|
|||||||
* @update gess7/30/98
|
* @update gess7/30/98
|
||||||
* @param s1 points to unichar string
|
* @param s1 points to unichar string
|
||||||
* @param s2 points to cstring
|
* @param s2 points to cstring
|
||||||
* @return 1 if they match, 0 if not
|
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
|
||||||
*/
|
*/
|
||||||
PRInt32 nsCRT::strncmp(const PRUnichar* s1, const char* s2, PRInt32 n)
|
PRInt32 nsCRT::strncmp(const PRUnichar* s1, const char* s2, PRInt32 n)
|
||||||
{
|
{
|
||||||
@@ -314,7 +314,7 @@ PRInt32 nsCRT::strncmp(const PRUnichar* s1, const char* s2, PRInt32 n)
|
|||||||
* @update gess7/30/98
|
* @update gess7/30/98
|
||||||
* @param s1 points to unichar string
|
* @param s1 points to unichar string
|
||||||
* @param s2 points to cstring
|
* @param s2 points to cstring
|
||||||
* @return 1 if they match, 0 if not
|
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
|
||||||
*/
|
*/
|
||||||
PRInt32 nsCRT::strcasecmp(const PRUnichar* s1, const char* s2)
|
PRInt32 nsCRT::strcasecmp(const PRUnichar* s1, const char* s2)
|
||||||
{
|
{
|
||||||
@@ -342,7 +342,7 @@ PRInt32 nsCRT::strcasecmp(const PRUnichar* s1, const char* s2)
|
|||||||
* @update gess7/30/98
|
* @update gess7/30/98
|
||||||
* @param s1 points to unichar string
|
* @param s1 points to unichar string
|
||||||
* @param s2 points to cstring
|
* @param s2 points to cstring
|
||||||
* @return 1 if they match, 0 if not
|
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
|
||||||
*/
|
*/
|
||||||
PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const char* s2, PRInt32 n)
|
PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const char* s2, PRInt32 n)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -61,8 +61,10 @@ nsString::nsString() {
|
|||||||
NS_ASSERTION(kCommonEmptyBuffer[0]==0,kFoolMsg);
|
NS_ASSERTION(kCommonEmptyBuffer[0]==0,kFoolMsg);
|
||||||
mLength = mCapacity = 0;
|
mLength = mCapacity = 0;
|
||||||
mStr = kCommonEmptyBuffer;
|
mStr = kCommonEmptyBuffer;
|
||||||
if(!mSelfTested)
|
if(!mSelfTested) {
|
||||||
|
mSelfTested=PR_TRUE;
|
||||||
SelfTest();
|
SelfTest();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1869,7 +1871,7 @@ NS_BASE int fputs(const nsString& aString, FILE* out)
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void nsString::SelfTest(void) {
|
void nsString::SelfTest(void) {
|
||||||
#if 1
|
#if 0
|
||||||
|
|
||||||
static const char* kConstructorError = kConstructorError;
|
static const char* kConstructorError = kConstructorError;
|
||||||
static const char* kComparisonError = "Comparision error!";
|
static const char* kComparisonError = "Comparision error!";
|
||||||
@@ -1884,6 +1886,10 @@ void nsString::SelfTest(void) {
|
|||||||
|
|
||||||
//first, let's test the constructors...
|
//first, let's test the constructors...
|
||||||
nsString empty;
|
nsString empty;
|
||||||
|
empty="";
|
||||||
|
empty="xxx";
|
||||||
|
empty="";
|
||||||
|
|
||||||
nsString a(temp);
|
nsString a(temp);
|
||||||
nsString* a_=new nsString(a); //test copy constructor
|
nsString* a_=new nsString(a); //test copy constructor
|
||||||
nsString b("world!");
|
nsString b("world!");
|
||||||
@@ -1961,6 +1967,7 @@ void nsString::SelfTest(void) {
|
|||||||
const char* bbbb="bbbb";
|
const char* bbbb="bbbb";
|
||||||
|
|
||||||
//First test the string compare routines...
|
//First test the string compare routines...
|
||||||
|
|
||||||
NS_ASSERTION(0>temp8.Compare(temp9),kComparisonError);
|
NS_ASSERTION(0>temp8.Compare(temp9),kComparisonError);
|
||||||
NS_ASSERTION(0<temp9.Compare(temp8),kComparisonError);
|
NS_ASSERTION(0<temp9.Compare(temp8),kComparisonError);
|
||||||
NS_ASSERTION(0==temp8.Compare(temp8a,PR_TRUE),kComparisonError);
|
NS_ASSERTION(0==temp8.Compare(temp8a,PR_TRUE),kComparisonError);
|
||||||
|
|||||||
@@ -61,8 +61,10 @@ nsString::nsString() {
|
|||||||
NS_ASSERTION(kCommonEmptyBuffer[0]==0,kFoolMsg);
|
NS_ASSERTION(kCommonEmptyBuffer[0]==0,kFoolMsg);
|
||||||
mLength = mCapacity = 0;
|
mLength = mCapacity = 0;
|
||||||
mStr = kCommonEmptyBuffer;
|
mStr = kCommonEmptyBuffer;
|
||||||
if(!mSelfTested)
|
if(!mSelfTested) {
|
||||||
|
mSelfTested=PR_TRUE;
|
||||||
SelfTest();
|
SelfTest();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1869,7 +1871,7 @@ NS_BASE int fputs(const nsString& aString, FILE* out)
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void nsString::SelfTest(void) {
|
void nsString::SelfTest(void) {
|
||||||
#if 1
|
#if 0
|
||||||
|
|
||||||
static const char* kConstructorError = kConstructorError;
|
static const char* kConstructorError = kConstructorError;
|
||||||
static const char* kComparisonError = "Comparision error!";
|
static const char* kComparisonError = "Comparision error!";
|
||||||
@@ -1884,6 +1886,10 @@ void nsString::SelfTest(void) {
|
|||||||
|
|
||||||
//first, let's test the constructors...
|
//first, let's test the constructors...
|
||||||
nsString empty;
|
nsString empty;
|
||||||
|
empty="";
|
||||||
|
empty="xxx";
|
||||||
|
empty="";
|
||||||
|
|
||||||
nsString a(temp);
|
nsString a(temp);
|
||||||
nsString* a_=new nsString(a); //test copy constructor
|
nsString* a_=new nsString(a); //test copy constructor
|
||||||
nsString b("world!");
|
nsString b("world!");
|
||||||
@@ -1961,6 +1967,7 @@ void nsString::SelfTest(void) {
|
|||||||
const char* bbbb="bbbb";
|
const char* bbbb="bbbb";
|
||||||
|
|
||||||
//First test the string compare routines...
|
//First test the string compare routines...
|
||||||
|
|
||||||
NS_ASSERTION(0>temp8.Compare(temp9),kComparisonError);
|
NS_ASSERTION(0>temp8.Compare(temp9),kComparisonError);
|
||||||
NS_ASSERTION(0<temp9.Compare(temp8),kComparisonError);
|
NS_ASSERTION(0<temp9.Compare(temp8),kComparisonError);
|
||||||
NS_ASSERTION(0==temp8.Compare(temp8a,PR_TRUE),kComparisonError);
|
NS_ASSERTION(0==temp8.Compare(temp8a,PR_TRUE),kComparisonError);
|
||||||
|
|||||||
Reference in New Issue
Block a user