Changeset 315


Ignore:
Timestamp:
Mar 10, 2006 8:28:52 AM (18 years ago)
Author:
cxsong
Message:

modified test_grid for multiple objects

Location:
trunk/src/mesh
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/mesh/grid1d.cc

    r300 r315  
    2929RpGrid1d::RpGrid1d(const char * buf)
    3030{
     31#ifdef DEBUG
     32printf("RpGrid1d(char*)\n");
     33#endif
    3134        deserialize(buf);
    3235}
     
    251254RpGrid1d::objectName(const char* str)
    252255{
    253         m_name = str;
     256        m_name.assign(str);
    254257}
    255258
     
    282285                + m_data.size() * sizeof(DataValType);
    283286
    284 #ifdef DEBUG
    285         printf("RpGrid1d::numBytes returns %d\n", nbytes);
    286 #endif
    287287        return nbytes;
    288288}
  • trunk/src/mesh/test_grid.cc

    r309 r315  
    4545{
    4646        int i, j, err, nbytes;
     47        const char* name1 = "output.grid(g1d)";
     48        const char* name2 = "output.grid(g2d)";
    4749
    4850        printf("Testing RpGrid1d\n");
    4951
    50         RpGrid1d* grid1 = new RpGrid1d("output.grid(g1d)", 20);
     52        RpGrid1d* grid1 = new RpGrid1d(name1, 20);
    5153        grid1->addAllPoints(&(points[0]), 20);
    5254
    53         char* buf = grid1->serialize(nbytes);
    54         writeToFile(buf, nbytes, "out.grid1");
    55 
    56         delete [] buf;
    57         buf = NULL;
    58 
    59         printf("grid1 objectname: %s\n", grid1->objectName());
     55        RpGrid1d* grid2 = new RpGrid1d(name2, 20);
     56        grid2->addAllPoints(&(points[0]), 20);
    6057
    6158        printf("Testing serializer\n");
     
    6360        RpSerializer myvis;
    6461        myvis.addObject(grid1);
    65         RpGrid1d* ptr = (RpGrid1d*) myvis.getObject(grid1->objectName());
    66         if (ptr == NULL)
    67                 printf("%s not found\n", grid1->objectName());
     62        myvis.addObject(grid2);
    6863
    69         buf = myvis.serialize();
     64        char* buf = myvis.serialize();
    7065
    7166        // write the byte stream to a file for verification
    7267        nbytes = myvis.numBytes();
    73         writeToFile(buf, nbytes, "out.g1");
     68        writeToFile(buf, nbytes, "out.g2");
    7469
    7570        //myvis.print();
     
    8176        newvis.print();
    8277
     78        printf("Testing serializer::getObject\n");
     79
     80        RpGrid1d* ptr1 = (RpGrid1d*) newvis.getObject(name1);
     81        if (ptr1 != NULL)
     82                ptr1->print();
     83        else
     84                printf("%s not found\n", name1);
     85
     86        RpGrid1d* ptr2 = (RpGrid1d*) newvis.getObject(name2);
     87        if (ptr2 != NULL)
     88                ptr2->print();
     89        else
     90                printf("%s not found\n", name2);
     91
     92        delete [] buf;
     93
    8394        return 0;
    8495}
Note: See TracChangeset for help on using the changeset viewer.