示例#1
0
int CTest::test_toArrayLjava_lang_Object(int argc, char* argv[])
{
    PEL("CTest::test_toArrayLjava_lang_Object")
    // Test for method java.lang.Object []
    // java.util.ArrayList.toArray(java.lang.Object [])
    AutoPtr<IInterface> outface;
    alist->Set(25, NULL, (IInterface**)&outface);
    alist->Set(75, NULL, (IInterface**)&outface);
    AutoPtr< ArrayOf<IInterface*> > argArray = ArrayOf<IInterface*>::Alloc(100);
    AutoPtr< ArrayOf<IInterface*> > retArray;
    alist->ToArrayEx(argArray, (ArrayOf<IInterface*>**)&retArray);
    assert(retArray == argArray);
    argArray = ArrayOf<IInterface*>::Alloc(1000);
    alist->ToArrayEx(argArray, (ArrayOf<IInterface*>**)&retArray);
    Int32 sizelen = 0;
    assert((*argArray)[(alist->GetSize(&sizelen), sizelen)] == NULL);
    for (int i = 0; i < 100; i++) {
        if ((i == 25) || (i == 75))
            assert((*retArray)[i] == NULL);
        else
            assert((*retArray)[i] == (*objArray)[i]);
    }

    AutoPtr< ArrayOf<IInterface*> > strArray = ArrayOf<IInterface*>::Alloc(100);
    // try {
    ECode ec = alist->ToArrayEx(strArray, (ArrayOf<IInterface*>**)&retArray);
    if (ec != NOERROR) {
        printf("ArrayStoreException expected\n");
    }

    // } catch (ArrayStoreException e) {
        //expected
    // }
    return 0;
}
示例#2
0
int CTest::test_trimToSize_02(int argc, char* argv[])
{
    PEL("CTest::test_trimToSize_02")
    // ArrayList list = new ArrayList(Arrays.asList(new String[] { "a", "b", "c",
    //         "d", "e", "f", "g" }));
    Boolean isflag = FALSE;
    AutoPtr<IArrayList> list;
    CArrayList::New((IArrayList**)&list);
    AutoPtr<ICharSequence> csa;
    CString::New(String("a"), (ICharSequence**)&csa);
    AutoPtr<ICharSequence> csb;
    CString::New(String("b"), (ICharSequence**)&csb);
    AutoPtr<ICharSequence> csc;
    CString::New(String("c"), (ICharSequence**)&csc);
    AutoPtr<ICharSequence> csd;
    CString::New(String("d"), (ICharSequence**)&csd);
    AutoPtr<ICharSequence> cse;
    CString::New(String("e"), (ICharSequence**)&cse);
    AutoPtr<ICharSequence> csf;
    CString::New(String("f"), (ICharSequence**)&csf);
    AutoPtr<ICharSequence> csg;
    CString::New(String("g"), (ICharSequence**)&csg);
    list->Add(csa, &isflag);
    list->Add(csb, &isflag);
    list->Add(csc, &isflag);
    list->Add(csd, &isflag);
    list->Add(cse, &isflag);
    list->Add(csf, &isflag);
    list->Add(csg, &isflag);

    list->Remove(csa, &isflag);
    list->Remove(csf, &isflag);
    list->TrimToSize();
    return 0;
}
示例#3
0
int CTest::test_clone(int argc, char* argv[])
{
    PEL("CTest::test_clone")
    // Test for method java.lang.Object java.util.ArrayList.clone()
    AutoPtr<IArrayList> x;
    AutoPtr<ICloneable> listclone = (ICloneable*) alist->Probe(EIID_ICloneable);
    listclone->Clone((IInterface**)&x);
    Boolean isflag = FALSE;
    assert((x->Equals(alist, &isflag), isflag));
    Int32 sizelen = 0;
    AutoPtr<IInterface> outface;
    AutoPtr<IInterface> outface2;
    for (int i = 0; i < (alist->GetSize(&sizelen), sizelen); i++) {
        alist->Get(i, (IInterface**)&outface);
        x->Get(i, (IInterface**)&outface2);
        assert(outface == outface2);
    }

    alist->Add(NULL, &isflag);
    alist->AddEx(25, NULL);
    listclone->Clone((IInterface**)&x);
    assert((x->Equals(alist, &isflag), isflag));
    for (int i = 0; i < (alist->GetSize(&sizelen), sizelen); i++) {
        alist->Get(i, (IInterface**)&outface);
        x->Get(i, (IInterface**)&outface2);
        assert(outface == outface2);
    }
    return 0;
}
示例#4
0
int CTest::test_ConstructorIF(int argc, char* argv[])
{
    PEL("CTest::test_ConstructorIF")
    // Test for method java.util.LinkedHashMap(int, float)
    AutoPtr<IMap> hm2;
    CLinkedHashMap::New(5, (Float)0.5, (IMap**)&hm2);
    Int32 sizelen = 0;
    assert(0 == (hm2->GetSize(&sizelen), sizelen));
    // try {
    ECode ec = CLinkedHashMap::New(0, 0, (IMap**)&hm2);
    if (ec != NOERROR) {
        printf("Failed to throw IllegalArgumentException for initial load factor <= 0");
    }

    // } catch (IllegalArgumentException e) {
    //     //expected
    // }

    AutoPtr<IMap> empty;
    CLinkedHashMap::New(0, 0.75f, (IMap**)&empty);
    AutoPtr<IInterface> outface;
    AutoPtr<ICharSequence> nothing;
    CStringWrapper::New(String("nothing"), (ICharSequence**)&nothing);
    AutoPtr<ICharSequence> something;
    CStringWrapper::New(String("something"), (ICharSequence**)&something);
    AutoPtr<ICharSequence> here;
    CStringWrapper::New(String("here"), (ICharSequence**)&here);
    assert((empty->Get(nothing, (IInterface**)&outface), outface) == NULL);
    empty->Put(something, here, (IInterface**)&outface);
    empty->Get(something, (IInterface**)&outface);
    String str = Object::ToString(outface);
    assert(str == String("here"));
    return 0;
}
示例#5
0
文件: jpeg.c 项目: archey/driftnet
/* jpeg_load_img:
 * Read a JPEG file into an image. */
int jpeg_load_img(img I) {
    struct jpeg_decompress_struct *cinfo = I->us;
    struct my_error_mgr *jerr;
    JSAMPARRAY buffer;
    img_alloc(I);
    jerr = (struct my_error_mgr*)cinfo->err;
    if (setjmp(jerr->jb)) {
        /* Oops, something went wrong. */
        I->err = IE_IMGFORMAT;
        jpeg_destroy_decompress(cinfo);
        return 0;
    }

    cinfo->out_color_space = JCS_RGB;
    cinfo->out_color_components = cinfo->output_components = 3;

    /* Start decompression. */
    buffer = cinfo->mem->alloc_sarray((j_common_ptr)cinfo, JPOOL_IMAGE, cinfo->output_width * cinfo->output_components, 1);

    while (cinfo->output_scanline < cinfo->output_height) {
        pel *p, *end;
        unsigned char *q;
        jpeg_read_scanlines(cinfo, buffer, 1);

        /* Now we have a buffer in RGB format. */
        for (p = I->data[cinfo->output_scanline - 1], end = p + I->width, q = (unsigned char*)buffer[0]; p < end; ++p, q += 3)
            *p = PEL(*q, *(q + 1), *(q + 2));
    }

    jpeg_finish_decompress(cinfo);
    jpeg_destroy_decompress(cinfo);

    return 1;
}
示例#6
0
int CTest::test_entrySetRemove(int argc, char* argv[])
{
    PEL("CTest::test_entrySetRemove")
    entrySetRemoveHelper(String("military"), String("intelligence"));
    entrySetRemoveHelper(String(NULL), String("hypothesis"));
    return 0;
}
示例#7
0
int CTest::test_values(int argc, char* argv[])
{
    PEL("CTest::test_values")
    // Test for method java.util.Collection java.util.LinkedHashMap.values()
    AutoPtr<ICollection> c;
    hm->Values((ICollection**)&c);
    Int32 len = 0;
    Int32 len1 = 0;
    c->GetSize(&len);
    hm->GetSize(&len1);
    assert(len1 == len);
    Boolean isflag = FALSE;
    for (int i = 0; i < objArray->GetLength(); i++) {
        assert((c->Contains((*objArray)[i], &isflag), isflag));
    }

    AutoPtr<IMap> myLinkedHashMap;
    CLinkedHashMap::New((IMap**)&myLinkedHashMap);
    AutoPtr<IInterface> outface;
    for (int i = 0; i < 100; i++) {
        myLinkedHashMap->Put((*objArray2)[i], (*objArray)[i], (IInterface**)&outface);
    }
    AutoPtr<ICollection> values;
    myLinkedHashMap->Values((ICollection**)&values);
    // new Support_UnmodifiableCollectionTest(
    //         "Test Returned Collection From LinkedHashMap.values()", values)
    //         .runTest();
    AutoPtr<IInteger32> int0;
    CInteger32::New(0, (IInteger32**)&int0);
    values->Remove(int0, &isflag);
    assert(!(myLinkedHashMap->ContainsValue(int0, &isflag), isflag));
    return 0;
}
示例#8
0
int CTest::test_entrySet(int argc, char* argv[])
{
    PEL("CTest::test_entrySet")
    // Test for method java.util.Set java.util.LinkedHashMap.entrySet()
    AutoPtr<ISet> s;
    hm->EntrySet((ISet**)&s);
    AutoPtr<IIterator> i;
    s->GetIterator((IIterator**)&i);
    Int32 len = 0;
    Int32 len1 = 0;
    hm->GetSize(&len);
    s->GetSize(&len1);
    assert(len == len1);
    Boolean isflag = FALSE;
    while (i->HasNext(&isflag), isflag) {
        AutoPtr<IMapEntry> m;
        AutoPtr<IInterface> outface;
        i->Next((IInterface**)&outface);
        m = IMapEntry::Probe(outface);
        AutoPtr<IInterface> keyface;
        m->GetKey((IInterface**)&keyface);
        AutoPtr<IInterface> valueface;
        m->GetValue((IInterface**)&valueface);
        Boolean isflag2 = FALSE;
        hm->ContainsKey(keyface, &isflag);
        hm->ContainsValue(valueface, &isflag2);
        assert(isflag && isflag2);
    }
    return 0;
}
示例#9
0
int CTest::test_putPresent(int argc, char* argv[])
{
    PEL("CTest::test_putPresent")
    AutoPtr<IMap> m;
    CLinkedHashMap::New(8, 0.75f, true, (IMap**)&m);
    AutoPtr<ICharSequence> KEY;
    CStringWrapper::New(String("KEY"), (ICharSequence**)&KEY);
    AutoPtr<ICharSequence> VALUE;
    CStringWrapper::New(String("VALUE"), (ICharSequence**)&VALUE);
    AutoPtr<ICharSequence> WOMBAT;
    CStringWrapper::New(String("WOMBAT"), (ICharSequence**)&WOMBAT);
    AutoPtr<ICharSequence> COMBAT;
    CStringWrapper::New(String("COMBAT"), (ICharSequence**)&COMBAT);
    AutoPtr<IInterface> outface;
    m->Put(KEY, VALUE, (IInterface**)&outface);
    m->Put(WOMBAT, COMBAT, (IInterface**)&outface);
    m->Put(KEY, VALUE, (IInterface**)&outface);
    AutoPtr< ArrayOf<IInterface*> > outarr;
    AutoPtr<ISet> outset;
    m->EntrySet((ISet**)&outset);
    outset->ToArray((ArrayOf<IInterface*>**)&outarr);
    AutoPtr<IMapEntry> newest;
    for (int i = 0; i < outarr->GetLength(); i++) {
        newest = IMapEntry::Probe((*outarr)[i]);
    }
    newest->GetKey((IInterface**)&outface);
    String str = Object::ToString(outface);
    assert(String("KEY") == str);
    newest->GetValue((IInterface**)&outface);
    str = Object::ToString(outface);
    assert(String("VALUE") == str);
    return 0;
}
示例#10
0
int CTest::test_getLjava_lang_Object(int argc, char* argv[])
{
    PEL("CTest::test_getLjava_lang_Object")
    // Test for method java.lang.Object
    // java.util.LinkedHashMap.get(java.lang.Object)
    AutoPtr<IInterface> outface;
    AutoPtr<ICharSequence> sqT;
    CStringWrapper::New(String("T"), (ICharSequence**)&sqT);
    hm->Get(sqT, (IInterface**)&outface);
    assert(outface == NULL);
    AutoPtr<ICharSequence> HELLO;
    CStringWrapper::New(String("HELLO"), (ICharSequence**)&HELLO);
    hm->Put(sqT, HELLO, (IInterface**)&outface);
    hm->Get(sqT, (IInterface**)&outface);
    String str = Object::ToString(outface);
    assert(String("HELLO") == str);

    AutoPtr<IMap> m;
    CLinkedHashMap::New((IMap**)&m);
    AutoPtr<ICharSequence> test;
    CStringWrapper::New(String("test"), (ICharSequence**)&test);
    m->Put(NULL, test, (IInterface**)&outface);
    m->Get(NULL, (IInterface**)&outface);
    str = Object::ToString(outface);
    assert(String("test") == str);
    AutoPtr<IInteger32> int0;
    CInteger32::New(0, (IInteger32**)&int0);
    assert((m->Get(int0, (IInterface**)&outface), outface) == NULL);
    return 0;
}
示例#11
0
int CTest::test_Constructor(int argc, char* argv[])
{
    PEL("CTest::test_Constructor")
    // Test for method java.util.HashSet()
    AutoPtr<ISet> hs2;
    CHashSet::New((ISet**)&hs2);
    Int32 sizlen = 0;
    assert(0 == (hs2->GetSize(&sizlen), sizlen));
    return 0;
}
示例#12
0
int CTest::test_GetCookieStore(int argc, char* argv[])
{
    PEL("CTest::test_GetCookieStore")
    AutoPtr<ICookieManager> cookieManager;
    CCookieManager::New((ICookieManager**)&cookieManager);
    AutoPtr<ICookieStore> store;
    cookieManager->GetCookieStore((ICookieStore**)&store);
    assert(store != NULL);
    return 0;
}
示例#13
0
int CTest::test_size(int argc, char* argv[])
{
    PEL("CTest::test_size")
    // Test for method int java.util.ArrayList.size()
    Int32 sizelen = 0;
    assert(100 == (alist->GetSize(&sizelen), sizelen));
    AutoPtr<IArrayList> al;
    CArrayList::New((IArrayList**)&al);
    assert(0 == (al->GetSize(&sizelen), sizelen));
    return 0;
}
示例#14
0
int CTest::test_CookieManager(int argc, char* argv[])
{
    PEL("CTest::test_CookieManager")
    AutoPtr<ICookieManager> cookieManager;
    CCookieManager::New((ICookieManager**)&cookieManager);
    assert(cookieManager != NULL);
    AutoPtr<ICookieStore> outcookie;
    cookieManager->GetCookieStore((ICookieStore**)&outcookie);
    assert(outcookie != NULL);
    return 0;
}
示例#15
0
int CTest::test_isEmpty(int argc, char* argv[])
{
    PEL("CTest::test_isEmpty")
    // Test for method boolean java.util.ArrayList.isEmpty()
    AutoPtr<IArrayList> al;
    CArrayList::New((IArrayList**)&al);
    Boolean isflag = FALSE;
    assert((al->IsEmpty(&isflag), isflag));
    assert(!(alist->IsEmpty(&isflag), isflag));
    return 0;
}
示例#16
0
int CTest::test_Constructor(int argc, char* argv[])
{
    PEL("CTest::test_Constructor")
    // Test for method java.util.LinkedHashMap()
    // new Support_MapTest2(new LinkedHashMap()).runTest();

    AutoPtr<IMap> hm2;
    CLinkedHashMap::New((IMap**)&hm2);
    Int32 sizelen = 0;
    assert(0 == (hm2->GetSize(&sizelen), sizelen));
    return 0;
}
示例#17
0
int CTest::test_indexOfLjava_lang_Object(int argc, char* argv[])
{
    PEL("CTest::test_indexOfLjava_lang_Object")
    // Test for method int java.util.ArrayList.indexOf(java.lang.Object)
    Int32 location = 0;
    AutoPtr<IInterface> outface;
    assert(87 == (alist->IndexOf((*objArray)[87], &location), location));
    assert(-1 == (alist->IndexOf(outface, &location), location));
    alist->AddEx(25, NULL);
    alist->AddEx(50, NULL);
    assert((alist->IndexOf(NULL, &location), location) == 25);
    return 0;
}
示例#18
0
int CTest::test_addLjava_lang_Object(int argc, char* argv[])
{
    PEL("CTest::test_addLjava_lang_Object")
    // Test for method boolean java.util.ArrayList.add(java.lang.Object)
    AutoPtr<IInterface> o; // = new Object();
    Boolean isflag = FALSE;
    alist->Add(o, &isflag);
    Int32 sizelen = 0;
    AutoPtr<IInterface> outface;
    assert((alist->Get((alist->GetSize(&sizelen), sizelen) - 1, (IInterface**)&outface), outface) == o);
    alist->Add(NULL, &isflag);
    assert((alist->Get((alist->GetSize(&sizelen), sizelen) - 1, (IInterface**)&outface), outface) == NULL);
    return 0;
}
示例#19
0
void CTest::checkValidParams4Put(IURI* uri, IMap* map)
{
    PEL("CTest::checkValidParams4Put")
    AutoPtr<ICookieManager> manager;
    CCookieManager::New((ICookieManager**)&manager);
    // try {
    ECode ec = manager->Put(uri, map);
    if (ec != NOERROR) {
        printf("Should throw IllegalArgumentException~~~~\n");
    }
    // } catch (IllegalArgumentException e) {
    //     // expected
    // }
}
示例#20
0
int CTest::test_removeLjava_lang_Object(int argc, char* argv[])
{
    PEL("CTest::test_removeLjava_lang_Object")
    // List list = new ArrayList(Arrays.asList(new String[] { "a", "b", "c",
    //         "d", "e", "f", "g" }));
    Boolean isflag = FALSE;
    AutoPtr<IArrayList> list;
    CArrayList::New((IArrayList**)&list);
    AutoPtr<ICharSequence> csa;
    CString::New(String("a"), (ICharSequence**)&csa);
    AutoPtr<ICharSequence> csb;
    CString::New(String("b"), (ICharSequence**)&csb);
    AutoPtr<ICharSequence> csc;
    CString::New(String("c"), (ICharSequence**)&csc);
    AutoPtr<ICharSequence> csd;
    CString::New(String("d"), (ICharSequence**)&csd);
    AutoPtr<ICharSequence> cse;
    CString::New(String("e"), (ICharSequence**)&cse);
    AutoPtr<ICharSequence> csf;
    CString::New(String("f"), (ICharSequence**)&csf);
    AutoPtr<ICharSequence> csg;
    CString::New(String("g"), (ICharSequence**)&csg);
    list->Add(csa, &isflag);
    list->Add(csb, &isflag);
    list->Add(csc, &isflag);
    list->Add(csd, &isflag);
    list->Add(cse, &isflag);
    list->Add(csf, &isflag);
    list->Add(csg, &isflag);

    assert((list->Remove(csa, &isflag), isflag));
    assert((list->Remove(csf, &isflag), isflag));
    // String[] result = new String[5];
    AutoPtr< ArrayOf<IInterface*> > result = ArrayOf<IInterface*>::Alloc(5);
    AutoPtr< ArrayOf<IInterface*> > outarr;
    list->ToArrayEx(result, (ArrayOf<IInterface*>**)&outarr);
    String str[5] = {String("b"), String("c"), String("d"), String("e"), String("g") };
    for (int i = 0; i < 5; ++i) {
        AutoPtr<ICharSequence> res = (ICharSequence*) (*outarr)[i]->Probe(EIID_ICharSequence);
        if (res == NULL) {
            assert(0);
        }
        String outstr;
        res->ToString(&outstr);
        assert( outstr == str[i]);
    }
    // assertTrue("Removed wrong element 3", Arrays.equals(result, new String[] { "b", "c", "d", "e", "g" }));
    return 0;
}
示例#21
0
AutoPtr<ICookieManager> CTest::store(String** cookies, int length, IMap* responseHeaders, ICookiePolicy* policy)
{
    PEL("CTest::store")
    AutoPtr<ICookieManager> manager;
    CCookieManager::New(NULL, policy, (ICookieManager**)&manager);
    // Put all cookies into manager
    for (int i = 0; i < length; i++) {
        for (int j = 2; j < 5; j += 2) {
            AutoPtr<IURI> uri;
            CURI::New(cookies[i][j], (IURI**)&uri);
            manager->Put(uri, responseHeaders);
        }
    }
    return manager;
}
示例#22
0
int CTest::test_getI(int argc, char* argv[])
{
    PEL("CTest::test_getI")
    // Test for method java.lang.Object java.util.ArrayList.get(int)
    AutoPtr<IInterface> outface;
    assert((alist->Get(22, (IInterface**)&outface), outface) == (*objArray)[22]);
    // try {
    ECode ec = alist->Get(8765, (IInterface**)&outface);
    if (ec != NOERROR) {
        printf("Failed to throw expected exception for index > size\n");
    }
    // } catch (IndexOutOfBoundsException e) {
    // }
    return 0;
}
示例#23
0
int CTest::testCookieManager_LCookieStore_LCookiePolicy(int argc, char* argv[])
{
    PEL("CTest::testCookieManager_LCookieStore_LCookiePolicy")
    AutoPtr<ICookieStore> store = new DummyStore();
    AutoPtr<ICookieManager> cookieManager;
    AutoPtr<ICookiePolicyHelper> cphelp;
    CCookiePolicyHelper::AcquireSingleton((ICookiePolicyHelper**)&cphelp);
    AutoPtr<ICookiePolicy> acceptcp;
    cphelp->GetCookiePolicy(CookiePolicyKind_ACCEPT_ALL, (ICookiePolicy**)&acceptcp);
    CCookieManager::New(store, acceptcp, (ICookieManager**)&cookieManager);
    AutoPtr<ICookieStore> out2;
    cookieManager->GetCookieStore((ICookieStore**)&out2);
    String outstr;
    ((DummyStore*)out2.Get())->GetName(&outstr);
    assert(Object::Equals(store, out2));
    return 0;
}
示例#24
0
int CTest::test_Constructor(int argc, char* argv[])
{
    PEL("CTest::test_Constructor")
    // Test for method java.util.ArrayList()
    // new Support_ListTest("", alist).runTest();

    AutoPtr<IArrayList> subList;
    CArrayList::New((IArrayList**)&subList);
    for (int i = -50; i < 150; i++) {
        AutoPtr<IInteger32> intface;
        CInteger32::New(i, (IInteger32**)&intface);
        Boolean isflag =  FALSE;
        subList->Add(intface, &isflag);
    }
    // new Support_ListTest("", subList.subList(50, 150)).runTest();
    return 0;
}
示例#25
0
int CTest::test_containsLjava_lang_Object(int argc, char* argv[])
{
    PEL("CTest::test_containsLjava_lang_Object")
    // Test for method boolean
    // java.util.ArrayList.contains(java.lang.Object)
    Boolean isflag = FALSE;
    assert((alist->Contains((*objArray)[99], &isflag), isflag));
    AutoPtr<IInteger32> intface;
    CInteger32::New(8, (IInteger32**)&intface);
    assert((alist->Contains(intface, &isflag), isflag));
    AutoPtr<IInterface> outface;
    assert((alist->Contains(outface, &isflag), !isflag));
    assert((alist->Contains(NULL, &isflag), !isflag));
    alist->Add(NULL, &isflag);
    assert((alist->Contains(NULL, &isflag), isflag));
    return 0;
}
示例#26
0
int CTest::test_lastIndexOfLjava_lang_Object(int argc, char* argv[])
{
    PEL("CTest::test_lastIndexOfLjava_lang_Object")
    // Test for method int java.util.ArrayList.lastIndexOf(java.lang.Object)
    AutoPtr<IInteger32> intface;
    CInteger32::New(99, (IInteger32**)&intface);
    Boolean isflag = FALSE;
    alist->Add(intface, &isflag);
    Int32 location = 0;
    assert(100 == (alist->LastIndexOf((*objArray)[99], &location), location));
    AutoPtr<IInterface> outface;
    assert(-1 == (alist->LastIndexOf(outface, &location), location));
    alist->AddEx(25, NULL);
    alist->AddEx(50, NULL);
    assert((alist->LastIndexOf(NULL, &location), location) == 50);
    return 0;
}
示例#27
0
int CTest::test_ConstructorIF(int argc, char* argv[])
{
    PEL("CTest::test_ConstructorIF")
    // Test for method java.util.HashSet(int, float)
    AutoPtr<ISet> hs2;
    CHashSet::New(5, (Float) 0.5, (ISet**)&hs2);
    Int32 sizlen = 0;
    assert(0 == (hs2->GetSize(&sizlen), sizlen));
    // try {
    ECode ec = CHashSet::New(0, 0, (ISet**)&hs2);
    // } catch (IllegalArgumentException e) {
        // return;
    // }
    if (ec != NOERROR) {
        printf("Failed to throw IllegalArgumentException for initial load factor <= 0\n");
    }
    return 0;
}
示例#28
0
int CTest::test_addILjava_lang_Object(int argc, char* argv[])
{
    PEL("CTest::test_addILjava_lang_Object")
    // Test for method void java.util.ArrayList.add(int, java.lang.Object)
    AutoPtr<IInterface> o;
    Boolean isflag = FALSE;
    ECode ec = alist->AddEx(50, o);

    for (int i = 0; i < objArray->GetLength(); i++) {
        AutoPtr<IInterface> outface;
        alist->Get(i, (IInterface**)&outface);
    }

    AutoPtr<IInterface> outface;
    assert((alist->Get(50, (IInterface**)&outface), outface) == o);
    assert((alist->Get(51, (IInterface**)&outface), outface) == (*objArray)[50]
          && ((alist->Get(52, (IInterface**)&outface), outface) == (*objArray)[51]));
    AutoPtr<IInterface> oldItem;
    alist->Get(25, (IInterface**)&oldItem);
    alist->AddEx(25, NULL);
    assert((alist->Get(25, (IInterface**)&outface), outface) == NULL);
    assert((alist->Get(26, (IInterface**)&outface), outface) == oldItem);

    // try {
    ec = alist->AddEx(-1, NULL);
    if (ec != NOERROR) {
        printf("IndexOutOfBoundsException expected\n");
    }
    // } catch (IndexOutOfBoundsException e) {
        //expected
    // }

    // try {
    Int32 sizelen = 0;
    ec = alist->AddEx((alist->GetSize(&sizelen), sizelen) + 1, NULL);
    if (ec != NOERROR) {
        printf("IndexOutOfBoundsException expected\n");
    }
    // } catch (IndexOutOfBoundsException e) {
        //expected
    // }
    return 0;
}
示例#29
0
int CTest::test_putAll_Ljava_util_Map_Null(int argc, char* argv[])
{
    PEL("CTest::test_putAll_Ljava_util_Map_Null")
    AutoPtr<IMap> linkedHashMap;
    CLinkedHashMap::New((IMap**)&linkedHashMap);
    // try {
    //     linkedHashMap.putAll(new MockMapNull());
    //     fail("Should throw NullPointerException");
    // } catch (NullPointerException e) {
    //     // expected.
    // }

    // try {
    //     linkedHashMap = new LinkedHashMap(new MockMapNull());
    //     fail("Should throw NullPointerException");
    // } catch (NullPointerException e) {
    //     // expected.
    // }
    return 0;
}
示例#30
0
AutoPtr<IMap> CTest::addCookie(String** cookies, int length)
{
    PEL("CTest::addCookie")
    AutoPtr<IMap> responseHeaders;
    CTreeMap::New((INavigableMap**)&responseHeaders);
    for (int i = 0; i < length; i++) {
        AutoPtr<IList> fields;
        CArrayList::New((IArrayList**)&fields);
        for (int j = 1; j < 5; j += 2) {
            AutoPtr<ICharSequence> sq;
            CStringWrapper::New(cookies[i][j], (ICharSequence**)&sq);
            Boolean isflag = FALSE;
            fields->Add(sq, &isflag);
        }
        AutoPtr<IInterface> outface;
        AutoPtr<ICharSequence> sq;
        CStringWrapper::New(cookies[i][0], (ICharSequence**)&sq);
        responseHeaders->Put(sq, fields, (IInterface**)&outface);
    }
    return responseHeaders;
}