Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
TestCRT.cpp File Reference
#include "nsCRT.h"
#include "nsString.h"
#include "plstr.h"
#include <stdlib.h>

Go to the source code of this file.

Classes

struct  Test

Defines

#define NUM_TESTS   int((sizeof(tests) / sizeof(tests[0])))

Functions

PRIntn sign (PRIntn val)
static void Check (const char *s1, const char *s2, PRIntn n)
int main ()
 main()

Variables

static Test tests []

Define Documentation

#define NUM_TESTS   int((sizeof(tests) / sizeof(tests[0])))

Definition at line 102 of file TestCRT.cpp.


Function Documentation

static void Check ( const char *  s1,
const char *  s2,
PRIntn  n 
) [static]

Definition at line 60 of file TestCRT.cpp.

{
  PRIntn clib = PL_strcmp(s1, s2);
  PRIntn clib_n = PL_strncmp(s1, s2, n);
  PRIntn clib_case = PL_strcasecmp(s1, s2);
  PRIntn clib_case_n = PL_strncasecmp(s1, s2, n);

  nsAutoString t1,t2; 
  t1.AssignWithConversion(s1);
  t2.AssignWithConversion(s2);
  const PRUnichar* us1 = t1.get();
  const PRUnichar* us2 = t2.get();

  PRIntn u2 = nsCRT::strcmp(us1, us2);
  PRIntn u2_n = nsCRT::strncmp(us1, us2, n);

  NS_ASSERTION(sign(clib) == sign(u2), "strcmp");
  NS_ASSERTION(sign(clib_n) == sign(u2_n), "strncmp");
}

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( void  )

main()

Definition at line 104 of file TestCRT.cpp.

{
  Test* tp = tests;
  for (int i = 0; i < NUM_TESTS; i++, tp++) {
    Check(tp->s1, tp->s2, tp->n);
  }

  return 0;
}

Here is the call graph for this function:

PRIntn sign ( PRIntn  val)

Definition at line 45 of file TestCRT.cpp.

                        {
    if (val == 0)
       return 0;
    else {
       if (val > 0)
           return 1;
       else
           return -1;
    }
}

Variable Documentation

Test tests[] [static]
Initial value:
 {
  { "foo", "foo", 3 },
  { "foo", "fo", 3 },

  { "foo", "bar", 3 },
  { "foo", "ba", 3 },

  { "foo", "zap", 3 },
  { "foo", "za", 3 },

  { "bar", "foo", 3 },
  { "bar", "fo", 3 },

  { "bar", "foo", 3 },
  { "bar", "fo", 3 },
}

Definition at line 86 of file TestCRT.cpp.