Back to index

lightning-sunbird  0.9+nobinonly
Functions
TestPermanentAtoms.cpp File Reference
#include "nsIAtom.h"
#include "nsAtomTable.h"
#include "nsCOMPtr.h"
#include <stdio.h>
#include "nsString.h"
#include "nsReadableUtils.h"

Go to the source code of this file.

Functions

static void Assert (PRBool aCondition, const char *aStatement)
static void AssertString (nsIAtom *aAtom, const nsACString &aString)
static void AssertPermanence (nsIAtom *aAtom, PRBool aPermanence)
int main ()
 main()

Function Documentation

static void Assert ( PRBool  aCondition,
const char *  aStatement 
) [static]

Definition at line 47 of file TestPermanentAtoms.cpp.

{
    printf("%s: %s\n", aCondition?"PASS":"FAIL", aStatement);
}

Here is the caller graph for this function:

static void AssertPermanence ( nsIAtom aAtom,
PRBool  aPermanence 
) [static]

Definition at line 59 of file TestPermanentAtoms.cpp.

{
    Assert(NS_STATIC_CAST(AtomImpl*,aAtom)->IsPermanent() == aPermanence,
           aPermanence ? "atom is permanent" : "atom is not permanent");
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void AssertString ( nsIAtom aAtom,
const nsACString &  aString 
) [static]

Definition at line 52 of file TestPermanentAtoms.cpp.

{
    const char *str;
    NS_STATIC_CAST(AtomImpl*,aAtom)->GetUTF8String(&str);
    Assert(nsDependentCString(str) == aString, "string is correct");
}

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( void  )

main()

Definition at line 65 of file TestPermanentAtoms.cpp.

{
    nsCOMPtr<nsIAtom> foo = do_GetAtom("foo");
    AssertString(foo, NS_LITERAL_CSTRING("foo"));
    AssertPermanence(foo, PR_FALSE);

    nsCOMPtr<nsIAtom> foop = do_GetPermanentAtom("foo");
    AssertString(foop, NS_LITERAL_CSTRING("foo"));
    AssertPermanence(foop, PR_TRUE);
    
    Assert(foo == foop, "atoms are equal");
    
    nsCOMPtr<nsIAtom> barp = do_GetPermanentAtom("bar");
    AssertString(barp, NS_LITERAL_CSTRING("bar"));
    AssertPermanence(barp, PR_TRUE);
    
    nsCOMPtr<nsIAtom> bar = do_GetAtom("bar");
    AssertString(bar, NS_LITERAL_CSTRING("bar"));
    AssertPermanence(bar, PR_TRUE);

    Assert(bar == barp, "atoms are equal");
    
    return 0;
}

Here is the call graph for this function: