Esempio n. 1
0
/*
 *
 * Ԥ�ڽ��: OK
 *
 * ���з�ʽ: clPushBackInputStream.ecx 6
 */
  int CTest::TestIsMarkSupported(int argc,char *argv[])
{
    IByteArrayInputStream* in;

    ArrayOf<Byte>* buffer = ArrayOf<Byte>::Alloc(3328);
    const char * str = (const char*) m_text;
    buffer->Copy((Byte*) str, 3328);

    ECode rt = CByteArrayInputStream::New(buffer, &in);
    if ( 0 == rt)
        rt = CPushbackInputStream::New((IInputStream*)in, &m_pis);

    Boolean supported;
    if (0 == rt) {
        rt = m_pis->IsMarkSupported(&supported);
    }

    if (0 == rt) {
        printf("test 6:OK\n");
    }
    else {
        printf("test 6 ERR: rt = %d\n", rt);
    }
    if(in) in->Release();
    if(m_pis) m_pis->Release();
    ArrayOf<Byte>::Free(buffer);

    return 0;
}
Esempio n. 2
0
/*
 *
 * ���: OK
 *
 * ���з�ʽ: clPushBackInputStream.ecx 3
 */
 int CTest::TestAvailable(int argc,char *argv[])
{
    IByteArrayInputStream* in;

    ArrayOf<Byte>* buffer = ArrayOf<Byte>::Alloc(3328);
    const char * str = (const char*) m_text;
    buffer->Copy((Byte*) str, 3328);

    ECode rt = CByteArrayInputStream::New(buffer, &in);
    if ( 0 == rt)
        rt = CPushbackInputStream::New((IInputStream*)in, &m_pis);

    Int32 number;
    if (0 == rt) {
        rt = m_pis->Available(&number);
    }

    if (0 == rt) {
        printf("test 3:OK\n");
    }
    else {
        printf("test3 ERR: rt = %d\n", rt);
    }
    if(in) in->Release();
    if(m_pis) m_pis->Release();
    ArrayOf<Byte>::Free(buffer);

    return 0;
}
Esempio n. 3
0
/*
 *
 * ���: OK
 *
 * ���з�ʽ: clLineNumberReader.ecx 3
 */
 int CTest::TestClose(int argc,char *argv[])
{
    ICharArrayReader * ir;

    ArrayOf<Char8>* buffer = ArrayOf<Char8>::Alloc(1024);
    if (buffer == NULL) return E_OUT_OF_MEMORY_ERROR;
    const char * str = (const char*) m_text;
    buffer->Copy((Char8*) str, 1024);

    ECode rt = CCharArrayReader::New(buffer, &ir);

    if (rt == 0) {
        rt = CLineNumberReader::New((IReader*)ir, &m_lnr);
        if (rt == 0) rt = m_lnr->Close();

    }

    if (0 == rt) {
        printf("test 3:OK\n");
    }
    else {
        printf("test 3 ERR: rt = %d\n", rt);
    }
    if(ir) ir->Release();
    if(m_lnr) m_lnr->Release();
    ArrayOf<Char8>::Free(buffer);

    return 0;
}
Esempio n. 4
0
 /*
 * Ԥ�ڽ��: OK
 *
 * ���з�ʽ: clLineNumberReader.ecx 8
 *
 */
  int CTest::TestReadBufferEx(int argc,char *argv[])
{
    ICharArrayReader * ir;

    ArrayOf<Char8>* buffer = ArrayOf<Char8>::Alloc(1024);
    if (buffer == NULL) return E_OUT_OF_MEMORY_ERROR;
    const char * str = (const char*) m_text;
    buffer->Copy((Char8*) str, 1024);

    ECode rt = CCharArrayReader::New(buffer, &ir);

    if (rt == 0) {
        rt = CLineNumberReader::New((IReader*)ir, &m_lnr);
    }
    Int32 value = 0;
    ArrayOf<Char8>* buf = (ArrayOf<Char8>*) malloc(sizeof(ArrayOf<Char8>*));
    if (rt == 0) {
        rt = m_lnr->ReadBufferEx(0, 0, buf, &value);
    }
    if (0 == rt) {
        printf("test 8:OK\n");
    }
    else {
        printf("test 8 ERR: rt = %d\n", rt);
    }
    if(ir) ir->Release();
    if(m_lnr) m_lnr->Release();
    ArrayOf<Char8>::Free(buffer);
    free(buf);

    return 0;
}
Esempio n. 5
0
/*
 *
 * ���: OK
 *
 * ���з�ʽ: clLineNumberInputStream.ecx 3
 */
 int CTest::TestClose(int argc,char *argv[])
{
    IByteArrayInputStream* in;

    ArrayOf<Byte>* buffer = ArrayOf<Byte>::Alloc(1024);
    const char * str = (const char*) m_text;
    buffer->Copy((Byte*) str, 1024);

    ECode rt = CByteArrayInputStream::New(buffer, &in);
    if ( 0 == rt)
        rt = CLineNumberInputStream::New((IInputStream*)in, &m_lnis);

    if (0 == rt) {
        rt = m_lnis->Close();
    }
    if (0 == rt) {
        printf("test 3:OK\n");
    }
    else {
        printf("test 3 ERR: rt = %d\n", rt);
    }
    if(in) in->Release();
    if(m_lnis) m_lnis->Release();
    ArrayOf<Byte>::Free(buffer);
    return 0;
}
Esempio n. 6
0
 /*
 * Ԥ�ڽ��: OK
 *
 * ���з�ʽ: clPushbackReader.ecx 14
 */
  int CTest::TestUnReadBufferEx(int argc,char *argv[])
{
    ICharArrayReader * ir;

    ArrayOf<Char8>* buffer = ArrayOf<Char8>::Alloc(1024);
    if (buffer == NULL) return E_OUT_OF_MEMORY_ERROR;
    const char * str = (const char*) m_text;
    buffer->Copy((Char8*) str, 1024);

    ECode rt = CCharArrayReader::New(buffer, &ir);

    if (rt == 0) {
        rt = CPushbackReader::New((IReader*)ir, &m_pr);
    }
    if (0 == rt) {
        rt = m_pr->UnReadBufferEx(0, 0, *buffer);
    }
    if (0 == rt) {
        printf("test 14:OK\n");
    }
    else {
        printf("test 14 ERR: rt = %d\n", rt);
    }
    if(ir) ir->Release();
    if(m_pr) m_pr->Release();
    ArrayOf<Char8>::Free(buffer);
    return 0;
}
Esempio n. 7
0
int main(int argc, char *argv[])
{
    ECode ec = NOERROR;
    ArrayOf<Byte> *buffer = ArrayOf<Byte>::Alloc(1024);
    Int32 len;

    IFileOutputStream *pfo = NULL;
    ec = CFileOutputStream::New(String("/data/data/com.elastos.runtime/elastos/tstbuffer.txt"), &pfo);
    if (FAILED(ec)) {
    	printf("Cann't Create CFileOutputStream, ec = %x\n", ec);
        return -1;
    }


    IBufferedOutputStream *pbos = NULL;
    ec = CBufferedOutputStream::New((IFileOutputStream *)pfo, &pbos);
    if (FAILED(ec)) {
    	printf("Cann't Create CZipOutputStream, ec = %x\n", ec);
        return -1;
    }

    Int32 i = 0;

    buffer->Copy((Byte *)"random", 6);
    while(i < 100) {
        ec = pbos->WriteBufferEx(0, 6, *buffer);
        if (FAILED(ec)) {
            printf("WriteBufferEx Failed! ec = %x\n", ec);
            return -1;
        }
        pbos->Flush();
        //buffer->Copy((Byte *)&i, 4);
        i++;
    }
    printf("==============================================\n");
    pbos->Close();
    return 0;

}