Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions | Variables
TestStreamUtils.cpp File Reference
#include <stdlib.h>
#include <stdio.h>
#include "nsIPipe.h"
#include "nsStreamUtils.h"
#include "nsString.h"
#include "nsCOMPtr.h"

Go to the source code of this file.

Classes

struct  Test

Defines

#define DECL_TEST(name)   { #name, name }

Typedefs

typedef PRBool(* TestFunc )()

Functions

static PRBool test_consume_stream ()
int main (int argc, char **argv)
 The Xalan testcases app.

Variables

static struct Test tests []

Define Documentation

#define DECL_TEST (   name)    { #name, name }

Definition at line 80 of file TestStreamUtils.cpp.


Typedef Documentation

typedef PRBool(* TestFunc)()

Definition at line 79 of file TestStreamUtils.cpp.


Function Documentation

int main ( int  argc,
char **  argv 
)

The Xalan testcases app.

Definition at line 90 of file TestStreamUtils.cpp.

                                {
  int count = 1;
  if (argc > 1)
    count = atoi(argv[1]);

  if (NS_FAILED(NS_InitXPCOM2(nsnull, nsnull, nsnull)))
    return -1;

  while (count--) {
    for (const Test* t = tests; t->name != nsnull; ++t) {
      printf("%25s : %s\n", t->name, t->func() ? "SUCCESS" : "FAILURE");
    }
  }
  
  NS_ShutdownXPCOM(nsnull);
  return 0;
}

Here is the call graph for this function:

static PRBool test_consume_stream ( ) [static]

Definition at line 48 of file TestStreamUtils.cpp.

                                    {
  const char kData[] =
      "Get your facts first, and then you can distort them as much as you "
      "please.";

  nsCOMPtr<nsIInputStream> input;
  nsCOMPtr<nsIOutputStream> output;
  NS_NewPipe(getter_AddRefs(input),
             getter_AddRefs(output),
             10, PR_UINT32_MAX);
  if (!input || !output)
    return PR_FALSE;

  PRUint32 n = 0;
  output->Write(kData, sizeof(kData) - 1, &n);
  if (n != (sizeof(kData) - 1))
    return PR_FALSE;
  output = nsnull;  // close output

  nsCString buf;
  if (NS_FAILED(NS_ConsumeStream(input, PR_UINT32_MAX, buf)))
    return PR_FALSE;

  if (!buf.Equals(kData))
    return PR_FALSE;

  return PR_TRUE; 
}

Here is the call graph for this function:


Variable Documentation

struct Test tests[] [static]