Changeset 250 for trunk/src


Ignore:
Timestamp:
Mar 1, 2006 1:35:45 PM (18 years ago)
Author:
cxsong
Message:

added tests for serialize/deserialize

Location:
trunk/src/mesh
Files:
2 edited

Legend:

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

    r249 r250  
    402402void RpMesh3d::print()
    403403{
     404        printf("Mesh nodes=%d elements=%d\n", m_numNodes, m_numElements);
    404405        string str;
    405406        xmlString(str);
  • trunk/src/mesh/test_mesh.cc

    r248 r250  
     1#include <stdio.h>
    12#include <string>
    23#include "mesh.h"
     
    5859        if (mptr == NULL)
    5960                return 1;
     61
     62        printf("nodes=%d ", mptr->numNodes());
     63        printf("elem=%d ", mptr->numElements());
     64        printf("nnie=%d\n", mptr->elementSize());
    6065
    6166        printf("Testing addAllNodes\n");
     
    127132        meshptr->print();
    128133
     134        printf("Testing serialize\n");
     135
     136        int nbytes=0;
     137        char* buf = meshptr->serialize(nbytes);
     138
     139        FILE* fp = fopen("out.tmp", "w");
     140        fwrite(buf, 1, nbytes, fp);
     141        fclose(fp);
     142
     143        printf("Testing deserialize\n");
     144
     145        RpMesh3d *newmesh = new RpMesh3d("mymesh", Num_nodes, Num_elements, 4);
     146        newmesh->deserialize(buf);
     147        newmesh->print();
     148
    129149        return 0;
    130150}
Note: See TracChangeset for help on using the changeset viewer.