added a few assertions, just to be safe

This commit is contained in:
rickg%netscape.com 1998-08-03 21:03:49 +00:00
parent a099c35d47
commit 6e9492b121
6 changed files with 52 additions and 24 deletions

View File

@ -154,7 +154,7 @@ PRInt32 nsCRT::strlen(const PRUnichar* s)
* NOTE: If both are null, we return 0.
* @update gess7/30/98
* @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)
{
@ -177,7 +177,7 @@ PRInt32 nsCRT::strcmp(const PRUnichar* s1, const PRUnichar* s2)
* NOTE: If either is null, we return 0.
* @update gess7/30/98
* @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)
{
@ -204,7 +204,7 @@ PRInt32 nsCRT::strncmp(const PRUnichar* s1, const PRUnichar* s2, PRInt32 n)
* NOTE: If both are null, we return 0.
* @update gess7/30/98
* @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)
{
@ -232,7 +232,7 @@ PRInt32 nsCRT::strcasecmp(const PRUnichar* s1, const PRUnichar* s2)
* NOTE: If both are null, we return 0.
* @update gess7/30/98
* @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)
{
@ -263,7 +263,7 @@ PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const PRUnichar* s2, PRInt32 n)
* @update gess7/30/98
* @param s1 points to unichar string
* @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)
{
@ -288,7 +288,7 @@ PRInt32 nsCRT::strcmp(const PRUnichar* s1, const char* s2)
* @update gess7/30/98
* @param s1 points to unichar string
* @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)
{
@ -314,7 +314,7 @@ PRInt32 nsCRT::strncmp(const PRUnichar* s1, const char* s2, PRInt32 n)
* @update gess7/30/98
* @param s1 points to unichar string
* @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)
{
@ -342,7 +342,7 @@ PRInt32 nsCRT::strcasecmp(const PRUnichar* s1, const char* s2)
* @update gess7/30/98
* @param s1 points to unichar string
* @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)
{

View File

@ -61,8 +61,10 @@ nsString::nsString() {
NS_ASSERTION(kCommonEmptyBuffer[0]==0,kFoolMsg);
mLength = mCapacity = 0;
mStr = kCommonEmptyBuffer;
if(!mSelfTested)
if(!mSelfTested) {
mSelfTested=PR_TRUE;
SelfTest();
}
}
@ -1869,7 +1871,7 @@ NS_BASE int fputs(const nsString& aString, FILE* out)
* @return
*/
void nsString::SelfTest(void) {
#if 1
#if 0
static const char* kConstructorError = kConstructorError;
static const char* kComparisonError = "Comparision error!";
@ -1884,6 +1886,10 @@ void nsString::SelfTest(void) {
//first, let's test the constructors...
nsString empty;
empty="";
empty="xxx";
empty="";
nsString a(temp);
nsString* a_=new nsString(a); //test copy constructor
nsString b("world!");
@ -1961,6 +1967,7 @@ void nsString::SelfTest(void) {
const char* bbbb="bbbb";
//First test the string compare routines...
NS_ASSERTION(0>temp8.Compare(temp9),kComparisonError);
NS_ASSERTION(0<temp9.Compare(temp8),kComparisonError);
NS_ASSERTION(0==temp8.Compare(temp8a,PR_TRUE),kComparisonError);

View File

@ -61,8 +61,10 @@ nsString::nsString() {
NS_ASSERTION(kCommonEmptyBuffer[0]==0,kFoolMsg);
mLength = mCapacity = 0;
mStr = kCommonEmptyBuffer;
if(!mSelfTested)
if(!mSelfTested) {
mSelfTested=PR_TRUE;
SelfTest();
}
}
@ -1869,7 +1871,7 @@ NS_BASE int fputs(const nsString& aString, FILE* out)
* @return
*/
void nsString::SelfTest(void) {
#if 1
#if 0
static const char* kConstructorError = kConstructorError;
static const char* kComparisonError = "Comparision error!";
@ -1884,6 +1886,10 @@ void nsString::SelfTest(void) {
//first, let's test the constructors...
nsString empty;
empty="";
empty="xxx";
empty="";
nsString a(temp);
nsString* a_=new nsString(a); //test copy constructor
nsString b("world!");
@ -1961,6 +1967,7 @@ void nsString::SelfTest(void) {
const char* bbbb="bbbb";
//First test the string compare routines...
NS_ASSERTION(0>temp8.Compare(temp9),kComparisonError);
NS_ASSERTION(0<temp9.Compare(temp8),kComparisonError);
NS_ASSERTION(0==temp8.Compare(temp8a,PR_TRUE),kComparisonError);

View File

@ -154,7 +154,7 @@ PRInt32 nsCRT::strlen(const PRUnichar* s)
* NOTE: If both are null, we return 0.
* @update gess7/30/98
* @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)
{
@ -177,7 +177,7 @@ PRInt32 nsCRT::strcmp(const PRUnichar* s1, const PRUnichar* s2)
* NOTE: If either is null, we return 0.
* @update gess7/30/98
* @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)
{
@ -204,7 +204,7 @@ PRInt32 nsCRT::strncmp(const PRUnichar* s1, const PRUnichar* s2, PRInt32 n)
* NOTE: If both are null, we return 0.
* @update gess7/30/98
* @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)
{
@ -232,7 +232,7 @@ PRInt32 nsCRT::strcasecmp(const PRUnichar* s1, const PRUnichar* s2)
* NOTE: If both are null, we return 0.
* @update gess7/30/98
* @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)
{
@ -263,7 +263,7 @@ PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const PRUnichar* s2, PRInt32 n)
* @update gess7/30/98
* @param s1 points to unichar string
* @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)
{
@ -288,7 +288,7 @@ PRInt32 nsCRT::strcmp(const PRUnichar* s1, const char* s2)
* @update gess7/30/98
* @param s1 points to unichar string
* @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)
{
@ -314,7 +314,7 @@ PRInt32 nsCRT::strncmp(const PRUnichar* s1, const char* s2, PRInt32 n)
* @update gess7/30/98
* @param s1 points to unichar string
* @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)
{
@ -342,7 +342,7 @@ PRInt32 nsCRT::strcasecmp(const PRUnichar* s1, const char* s2)
* @update gess7/30/98
* @param s1 points to unichar string
* @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)
{

View File

@ -61,8 +61,10 @@ nsString::nsString() {
NS_ASSERTION(kCommonEmptyBuffer[0]==0,kFoolMsg);
mLength = mCapacity = 0;
mStr = kCommonEmptyBuffer;
if(!mSelfTested)
if(!mSelfTested) {
mSelfTested=PR_TRUE;
SelfTest();
}
}
@ -1869,7 +1871,7 @@ NS_BASE int fputs(const nsString& aString, FILE* out)
* @return
*/
void nsString::SelfTest(void) {
#if 1
#if 0
static const char* kConstructorError = kConstructorError;
static const char* kComparisonError = "Comparision error!";
@ -1884,6 +1886,10 @@ void nsString::SelfTest(void) {
//first, let's test the constructors...
nsString empty;
empty="";
empty="xxx";
empty="";
nsString a(temp);
nsString* a_=new nsString(a); //test copy constructor
nsString b("world!");
@ -1961,6 +1967,7 @@ void nsString::SelfTest(void) {
const char* bbbb="bbbb";
//First test the string compare routines...
NS_ASSERTION(0>temp8.Compare(temp9),kComparisonError);
NS_ASSERTION(0<temp9.Compare(temp8),kComparisonError);
NS_ASSERTION(0==temp8.Compare(temp8a,PR_TRUE),kComparisonError);

View File

@ -61,8 +61,10 @@ nsString::nsString() {
NS_ASSERTION(kCommonEmptyBuffer[0]==0,kFoolMsg);
mLength = mCapacity = 0;
mStr = kCommonEmptyBuffer;
if(!mSelfTested)
if(!mSelfTested) {
mSelfTested=PR_TRUE;
SelfTest();
}
}
@ -1869,7 +1871,7 @@ NS_BASE int fputs(const nsString& aString, FILE* out)
* @return
*/
void nsString::SelfTest(void) {
#if 1
#if 0
static const char* kConstructorError = kConstructorError;
static const char* kComparisonError = "Comparision error!";
@ -1884,6 +1886,10 @@ void nsString::SelfTest(void) {
//first, let's test the constructors...
nsString empty;
empty="";
empty="xxx";
empty="";
nsString a(temp);
nsString* a_=new nsString(a); //test copy constructor
nsString b("world!");
@ -1961,6 +1967,7 @@ void nsString::SelfTest(void) {
const char* bbbb="bbbb";
//First test the string compare routines...
NS_ASSERTION(0>temp8.Compare(temp9),kComparisonError);
NS_ASSERTION(0<temp9.Compare(temp8),kComparisonError);
NS_ASSERTION(0==temp8.Compare(temp8a,PR_TRUE),kComparisonError);