#include #include #include "equal.h" typedef int (*cdevTest)(cdevData & data); int tagTest ( cdevData & data ); int scalarTest ( cdevData & data ); int byteArrayTest ( cdevData & data ); int shortArrayTest ( cdevData & data ); int ushortArrayTest ( cdevData & data ); int intArrayTest ( cdevData & data ); int uintArrayTest ( cdevData & data ); int longArrayTest ( cdevData & data ); int ulongArrayTest ( cdevData & data ); int floatArrayTest ( cdevData & data ); int doubleArrayTest ( cdevData & data ); int stringArrayTest ( cdevData & data ); int asciiDumpTest ( cdevData & data ); int copyTest ( cdevData & data ); int assignmentTest ( cdevData & data ); int removeTest ( cdevData & data ); int findTest ( cdevData & data ); int xdrTest ( cdevData & data ); enum testTags { TAGTEST = 0, SCALARTEST, BYTEARRAYTEST, SHORTARRAYTEST, USHORTARRAYTEST, INTARRAYTEST, UINTARRAYTEST, LONGARRAYTEST, ULONGARRAYTEST, FLOATARRAYTEST, DOUBLEARRAYTEST, STRINGARRAYTEST, COPYTEST, ASSIGNTEST, FINDTEST, XDRTEST, ASCIIDUMPTEST, REMOVETEST, MAXTESTS }; cdevTest testFunctions[MAXTESTS] = { tagTest, scalarTest, byteArrayTest, shortArrayTest, ushortArrayTest, intArrayTest, uintArrayTest, longArrayTest, ulongArrayTest, floatArrayTest, doubleArrayTest, stringArrayTest, copyTest, assignmentTest, findTest, xdrTest, asciiDumpTest, removeTest, }; char * testNames[MAXTESTS] = { "Tag Insertion/Extraction Test", "Scalar Insertion/Extraction Test", "Byte Array Insertion/Extraction Test", "Short Array Insertion/Extraction Test", "Unsigned Short Array Insert/Extract Test", "Int Array Insert/Extract Test", "Unsigned Int Array Insert/Extract Test", "Long Array Insert/Extract Test", "Unsigned Long Array Insert/Extract Test", "Float Array Insert/Extract Test", "Double Array Insert/Extract Test", "String Insert/Extract Test", "Copy Constructor Test", "Assignment Operator Copy Test", "Tagged Item Find Test", "XDR Import/Export Facility Test", "ASCII Dump Test", "Tagged Item Deletion Test", }; int testResults[MAXTESTS]; int main() { int i; cdevData data; for(i=0; i0.0001 || D[9]!=(double)atof(STR[9])) { fprintf(stdout, "* ERROR IN STRING INSERTION/EXTRACTION\n"); result = -1; } return result; } int byteArrayTest ( cdevData & data ) { int LOCALTAG = 10; int result = 0, bresult = 0; int x; BYTE input[1000]; cdevBounds bounds[3]; cdevBounds obounds[3]; BYTE C[1000]; short S[1000]; unsigned short US[1000]; int I[1000]; unsigned int UI[1000]; long L[1000]; unsigned long UL[1000]; float F[1000]; double D[1000]; char * STR[1000]; bounds[0].offset = 0; bounds[0].length = 10; bounds[1].offset = 0; bounds[1].length = 10; bounds[2].offset = 0; bounds[2].length = 10; for(x=0; x<1000; x++) input[x] = (BYTE)x; data.insert(globalTags[LOCALTAG], input, 1000, 3); data.setBounds(globalTags[LOCALTAG], bounds, 3); data.getBounds(globalTags[LOCALTAG], obounds, 3); for(x=0; x<3; x++) { if(bounds[x].offset!=obounds[x].offset) bresult = -1; } if(bresult!=0) fprintf(stdout, "* MISMATCH BETWEEN BOUNDS SPECIFIED AND BOUNDS READ\n"); data.get(globalTags[LOCALTAG], C); data.get(globalTags[LOCALTAG], S); data.get(globalTags[LOCALTAG], US); data.get(globalTags[LOCALTAG], I); data.get(globalTags[LOCALTAG], UI); data.get(globalTags[LOCALTAG], L); data.get(globalTags[LOCALTAG], UL); data.get(globalTags[LOCALTAG], F); data.get(globalTags[LOCALTAG], D); data.get(globalTags[LOCALTAG], STR); for(x=0; x<1000; x++) { if(input[x]!=(BYTE)C[x] || input[x]!=(BYTE)S[x] || input[x]!=(BYTE)US[x] || input[x]!=(BYTE)I[x] || input[x]!=(BYTE)UI[x] || input[x]!=(BYTE)L[x] || input[x]!=(BYTE)UL[x] || input[x]!=(BYTE)F[x] || input[x]!=(BYTE)D[x] || input[x]!=(BYTE)atof(STR[x])) { result = -1; } delete STR[x]; } if(result) fprintf(stdout, "* MISMATCH BETWEEN SPECIFIED DATA AND RETRIEVED DATA\n"); if(result || bresult) return -1; return 0; } int shortArrayTest ( cdevData & data ) { int LOCALTAG = 11; int result = 0, bresult = 0; int x; short input[1000]; cdevBounds bounds[3]; cdevBounds obounds[3]; BYTE C[1000]; short S[1000]; unsigned short US[1000]; int I[1000]; unsigned int UI[1000]; long L[1000]; unsigned long UL[1000]; float F[1000]; double D[1000]; char * STR[1000]; bounds[0].offset = 0; bounds[0].length = 5; bounds[1].offset = 0; bounds[1].length = 2; bounds[2].offset = 0; bounds[2].length = 100; for(x=0; x<1000; x++) input[x] = (short)x*2; data.insert(globalTags[LOCALTAG], input, 1000, 3); data.setBounds(globalTags[LOCALTAG], bounds, 3); data.getBounds(globalTags[LOCALTAG], obounds, 3); for(x=0; x<3; x++) { if(bounds[x].offset!=obounds[x].offset) bresult = -1; } if(bresult!=0) fprintf(stdout, "* MISMATCH BETWEEN BOUNDS SPECIFIED AND BOUNDS READ\n"); data.get(globalTags[LOCALTAG], C); data.get(globalTags[LOCALTAG], S); data.get(globalTags[LOCALTAG], US); data.get(globalTags[LOCALTAG], I); data.get(globalTags[LOCALTAG], UI); data.get(globalTags[LOCALTAG], L); data.get(globalTags[LOCALTAG], UL); data.get(globalTags[LOCALTAG], F); data.get(globalTags[LOCALTAG], D); data.get(globalTags[LOCALTAG], STR); for(x=0; x<1000; x++) { if((BYTE)input[x]!=C[x] || input[x]!=(short)S[x] || input[x]!=(short)US[x] || input[x]!=(short)I[x] || input[x]!=(short)UI[x] || input[x]!=(short)L[x] || input[x]!=(short)UL[x] || input[x]!=(short)F[x] || input[x]!=(short)D[x] || input[x]!=(short)atof(STR[x])) { result = -1; } delete STR[x]; } if(result) fprintf(stdout, "* MISMATCH BETWEEN SPECIFIED DATA AND RETRIEVED DATA\n"); if(result || bresult) return -1; return 0; } int ushortArrayTest ( cdevData & data ) { int LOCALTAG = 12; int result = 0, bresult = 0; int x; unsigned short input[1000]; cdevBounds bounds[3]; cdevBounds obounds[3]; BYTE C[1000]; short S[1000]; unsigned short US[1000]; int I[1000]; unsigned int UI[1000]; long L[1000]; unsigned long UL[1000]; float F[1000]; double D[1000]; char * STR[1000]; bounds[0].offset = 0; bounds[0].length = 5; bounds[1].offset = 0; bounds[1].length = 2; bounds[2].offset = 0; bounds[2].length = 100; for(x=0; x<1000; x++) input[x] = (unsigned short)x*3; data.insert(globalTags[LOCALTAG], input, 1000, 3); data.setBounds(globalTags[LOCALTAG], bounds, 3); data.getBounds(globalTags[LOCALTAG], obounds, 3); for(x=0; x<3; x++) { if(bounds[x].offset!=obounds[x].offset) bresult = -1; } if(bresult!=0) fprintf(stdout, "* MISMATCH BETWEEN BOUNDS SPECIFIED AND BOUNDS READ\n"); data.get(globalTags[LOCALTAG], C); data.get(globalTags[LOCALTAG], S); data.get(globalTags[LOCALTAG], US); data.get(globalTags[LOCALTAG], I); data.get(globalTags[LOCALTAG], UI); data.get(globalTags[LOCALTAG], L); data.get(globalTags[LOCALTAG], UL); data.get(globalTags[LOCALTAG], F); data.get(globalTags[LOCALTAG], D); data.get(globalTags[LOCALTAG], STR); for(x=0; x<1000; x++) { if((BYTE)input[x]!=C[x] || (short)input[x]!=S[x] || input[x]!=(unsigned short)US[x] || input[x]!=(unsigned short)I[x] || input[x]!=(unsigned short)UI[x] || input[x]!=(unsigned short)L[x] || input[x]!=(unsigned short)UL[x] || input[x]!=(unsigned short)F[x] || input[x]!=(unsigned short)D[x] || input[x]!=(unsigned short)atof(STR[x])) { result = -1; } delete STR[x]; } if(result) fprintf(stdout, "* MISMATCH BETWEEN SPECIFIED DATA AND RETRIEVED DATA\n"); if(result || bresult) return -1; return 0; } int intArrayTest ( cdevData & data ) { int LOCALTAG = 13; int result = 0, bresult = 0; int x; int input[1000]; cdevBounds bounds[3]; cdevBounds obounds[3]; BYTE C[1000]; short S[1000]; unsigned short US[1000]; int I[1000]; unsigned int UI[1000]; long L[1000]; unsigned long UL[1000]; float F[1000]; double D[1000]; char * STR[1000]; bounds[0].offset = 0; bounds[0].length = 5; bounds[1].offset = 0; bounds[1].length = 2; bounds[2].offset = 0; bounds[2].length = 100; for(x=0; x<1000; x++) input[x] = (int)x*4; data.insert(globalTags[LOCALTAG], input, 1000, 3); data.setBounds(globalTags[LOCALTAG], bounds, 3); data.getBounds(globalTags[LOCALTAG], obounds, 3); for(x=0; x<3; x++) { if(bounds[x].offset!=obounds[x].offset) bresult = -1; } if(bresult!=0) fprintf(stdout, "* MISMATCH BETWEEN BOUNDS SPECIFIED AND BOUNDS READ\n"); data.get(globalTags[LOCALTAG], C); data.get(globalTags[LOCALTAG], S); data.get(globalTags[LOCALTAG], US); data.get(globalTags[LOCALTAG], I); data.get(globalTags[LOCALTAG], UI); data.get(globalTags[LOCALTAG], L); data.get(globalTags[LOCALTAG], UL); data.get(globalTags[LOCALTAG], F); data.get(globalTags[LOCALTAG], D); data.get(globalTags[LOCALTAG], STR); for(x=0; x<1000; x++) { if((BYTE)input[x]!=C[x] || (short)input[x]!=S[x] || (unsigned short)input[x]!=US[x] || input[x]!=(int)I[x] || input[x]!=(int)UI[x] || input[x]!=(int)L[x] || input[x]!=(int)UL[x] || input[x]!=(int)F[x] || input[x]!=(int)D[x] || input[x]!=(int)atof(STR[x])) { result = -1; } delete STR[x]; } if(result) fprintf(stdout, "* MISMATCH BETWEEN SPECIFIED DATA AND RETRIEVED DATA\n"); if(result || bresult) return -1; return 0; } int uintArrayTest ( cdevData & data ) { int LOCALTAG = 14; int result = 0, bresult = 0; int x; unsigned int input[1000]; cdevBounds bounds[3]; cdevBounds obounds[3]; BYTE C[1000]; short S[1000]; unsigned short US[1000]; int I[1000]; unsigned int UI[1000]; long L[1000]; unsigned long UL[1000]; float F[1000]; double D[1000]; char * STR[1000]; bounds[0].offset = 0; bounds[0].length = 5; bounds[1].offset = 0; bounds[1].length = 2; bounds[2].offset = 0; bounds[2].length = 100; for(x=0; x<1000; x++) input[x] = (unsigned int)x*5; data.insert(globalTags[LOCALTAG], input, 1000, 3); data.setBounds(globalTags[LOCALTAG], bounds, 3); data.getBounds(globalTags[LOCALTAG], obounds, 3); for(x=0; x<3; x++) { if(bounds[x].offset!=obounds[x].offset) bresult = -1; } if(bresult!=0) fprintf(stdout, "* MISMATCH BETWEEN BOUNDS SPECIFIED AND BOUNDS READ\n"); data.get(globalTags[LOCALTAG], C); data.get(globalTags[LOCALTAG], S); data.get(globalTags[LOCALTAG], US); data.get(globalTags[LOCALTAG], I); data.get(globalTags[LOCALTAG], UI); data.get(globalTags[LOCALTAG], L); data.get(globalTags[LOCALTAG], UL); data.get(globalTags[LOCALTAG], F); data.get(globalTags[LOCALTAG], D); data.get(globalTags[LOCALTAG], STR); for(x=0; x<1000; x++) { if((BYTE)input[x]!=C[x] || (short)input[x]!=S[x] || (unsigned short)input[x]!=US[x] || (int)input[x]!=I[x] || input[x]!=(unsigned int)UI[x] || input[x]!=(unsigned int)L[x] || input[x]!=(unsigned int)UL[x] || input[x]!=(unsigned int)F[x] || input[x]!=(unsigned int)D[x] || input[x]!=(unsigned int)atof(STR[x])) { result = -1; } delete STR[x]; } if(result) fprintf(stdout, "* MISMATCH BETWEEN SPECIFIED DATA AND RETRIEVED DATA\n"); if(result || bresult) return -1; return 0; } int longArrayTest ( cdevData & data ) { int LOCALTAG = 15; int result = 0, bresult = 0; int x; long input[1000]; cdevBounds bounds[3]; cdevBounds obounds[3]; BYTE C[1000]; short S[1000]; unsigned short US[1000]; int I[1000]; unsigned int UI[1000]; long L[1000]; unsigned long UL[1000]; float F[1000]; double D[1000]; char * STR[1000]; bounds[0].offset = 0; bounds[0].length = 5; bounds[1].offset = 0; bounds[1].length = 2; bounds[2].offset = 0; bounds[2].length = 100; for(x=0; x<1000; x++) input[x] = (long)x*6; data.insert(globalTags[LOCALTAG], input, 1000, 3); data.setBounds(globalTags[LOCALTAG], bounds, 3); data.getBounds(globalTags[LOCALTAG], obounds, 3); for(x=0; x<3; x++) { if(bounds[x].offset!=obounds[x].offset) bresult = -1; } if(bresult!=0) fprintf(stdout, "* MISMATCH BETWEEN BOUNDS SPECIFIED AND BOUNDS READ\n"); data.get(globalTags[LOCALTAG], C); data.get(globalTags[LOCALTAG], S); data.get(globalTags[LOCALTAG], US); data.get(globalTags[LOCALTAG], I); data.get(globalTags[LOCALTAG], UI); data.get(globalTags[LOCALTAG], L); data.get(globalTags[LOCALTAG], UL); data.get(globalTags[LOCALTAG], F); data.get(globalTags[LOCALTAG], D); data.get(globalTags[LOCALTAG], STR); for(x=0; x<1000; x++) { if((BYTE)input[x]!=C[x] || (short)input[x]!=S[x] || (unsigned short)input[x]!=US[x] || (int)input[x]!=I[x] || (unsigned int)input[x]!=UI[x] || input[x]!=(long)L[x] || input[x]!=(long)UL[x] || input[x]!=(long)F[x] || input[x]!=(long)D[x] || input[x]!=(long)atof(STR[x])) { result = -1; } delete STR[x]; } if(result) fprintf(stdout, "* MISMATCH BETWEEN SPECIFIED DATA AND RETRIEVED DATA\n"); if(result || bresult) return -1; return 0; } int ulongArrayTest ( cdevData & data ) { int LOCALTAG = 16; int result = 0, bresult = 0; int x; unsigned long input[1000]; cdevBounds bounds[3]; cdevBounds obounds[3]; BYTE C[1000]; short S[1000]; unsigned short US[1000]; int I[1000]; unsigned int UI[1000]; long L[1000]; unsigned long UL[1000]; float F[1000]; double D[1000]; char * STR[1000]; bounds[0].offset = 0; bounds[0].length = 5; bounds[1].offset = 0; bounds[1].length = 2; bounds[2].offset = 0; bounds[2].length = 100; for(x=0; x<1000; x++) input[x] = (unsigned long)x*7; data.insert(globalTags[LOCALTAG], input, 1000, 3); data.setBounds(globalTags[LOCALTAG], bounds, 3); data.getBounds(globalTags[LOCALTAG], obounds, 3); for(x=0; x<3; x++) { if(bounds[x].offset!=obounds[x].offset) bresult = -1; } if(bresult!=0) fprintf(stdout, "* MISMATCH BETWEEN BOUNDS SPECIFIED AND BOUNDS READ\n"); data.get(globalTags[LOCALTAG], C); data.get(globalTags[LOCALTAG], S); data.get(globalTags[LOCALTAG], US); data.get(globalTags[LOCALTAG], I); data.get(globalTags[LOCALTAG], UI); data.get(globalTags[LOCALTAG], L); data.get(globalTags[LOCALTAG], UL); data.get(globalTags[LOCALTAG], F); data.get(globalTags[LOCALTAG], D); data.get(globalTags[LOCALTAG], STR); for(x=0; x<1000; x++) { if((BYTE)input[x]!=C[x] || (short)input[x]!=S[x] || (unsigned short)input[x]!=US[x] || (int)input[x]!=I[x] || (unsigned int)input[x]!=UI[x] || (long)input[x]!=L[x] || input[x]!=(unsigned long)UL[x] || input[x]!=(unsigned long)F[x] || input[x]!=(unsigned long)D[x] || input[x]!=(unsigned long)atof(STR[x])) { result = -1; } delete STR[x]; } if(result) fprintf(stdout, "* MISMATCH BETWEEN SPECIFIED DATA AND RETRIEVED DATA\n"); if(result || bresult) return -1; return 0; } int floatArrayTest ( cdevData & data ) { int LOCALTAG = 17; int result = 0, bresult = 0; int x; float input[1000]; cdevBounds bounds[3]; cdevBounds obounds[3]; BYTE C[1000]; short S[1000]; unsigned short US[1000]; int I[1000]; unsigned int UI[1000]; long L[1000]; unsigned long UL[1000]; float F[1000]; double D[1000]; char * STR[1000]; bounds[0].offset = 0; bounds[0].length = 5; bounds[1].offset = 0; bounds[1].length = 2; bounds[2].offset = 0; bounds[2].length = 100; for(x=0; x<1000; x++) input[x] = (float)2.1 * x; data.insert(globalTags[LOCALTAG], input, 1000, 3); data.setBounds(globalTags[LOCALTAG], bounds, 3); data.getBounds(globalTags[LOCALTAG], obounds, 3); for(x=0; x<3; x++) { if(bounds[x].offset!=obounds[x].offset) bresult = -1; } if(bresult!=0) fprintf(stdout, "* MISMATCH BETWEEN BOUNDS SPECIFIED AND BOUNDS READ\n"); data.get(globalTags[LOCALTAG], C); data.get(globalTags[LOCALTAG], S); data.get(globalTags[LOCALTAG], US); data.get(globalTags[LOCALTAG], I); data.get(globalTags[LOCALTAG], UI); data.get(globalTags[LOCALTAG], L); data.get(globalTags[LOCALTAG], UL); data.get(globalTags[LOCALTAG], F); data.get(globalTags[LOCALTAG], D); data.get(globalTags[LOCALTAG], STR); for(x=0; x<1000; x++) { if((BYTE)input[x]!=C[x] || (short)input[x]!=S[x] || (unsigned short)input[x]!=US[x] || (int)input[x]!=I[x] || (unsigned int)input[x]!=UI[x] || (long)input[x]!=L[x] || (unsigned long)input[x]!=UL[x] || input[x]!=(float)F[x] || input[x]!=(float)D[x] || !equal(input[x], (float)atof(STR[x]))) { result = -1; } delete STR[x]; } if(result) fprintf(stdout, "* MISMATCH BETWEEN SPECIFIED DATA AND RETRIEVED DATA\n"); if(result || bresult) return -1; return 0; } int doubleArrayTest ( cdevData & data ) { int LOCALTAG = 18; int result = 0, bresult = 0; int x; double input[1000]; cdevBounds bounds[3]; cdevBounds obounds[3]; BYTE C[1000]; short S[1000]; unsigned short US[1000]; int I[1000]; unsigned int UI[1000]; long L[1000]; unsigned long UL[1000]; float F[1000]; double D[1000]; char * STR[1000]; bounds[0].offset = 0; bounds[0].length = 5; bounds[1].offset = 0; bounds[1].length = 2; bounds[2].offset = 0; bounds[2].length = 100; for(x=0; x<1000; x++) input[x] = (double)5.1111112*x; data.insert(globalTags[LOCALTAG], input, 1000, 3); data.setBounds(globalTags[LOCALTAG], bounds, 3); data.getBounds(globalTags[LOCALTAG], obounds, 3); for(x=0; x<3; x++) { if(bounds[x].offset!=obounds[x].offset) bresult = -1; } if(bresult!=0) fprintf(stdout, "* MISMATCH BETWEEN BOUNDS SPECIFIED AND BOUNDS READ\n"); data.get(globalTags[LOCALTAG], C); data.get(globalTags[LOCALTAG], S); data.get(globalTags[LOCALTAG], US); data.get(globalTags[LOCALTAG], I); data.get(globalTags[LOCALTAG], UI); data.get(globalTags[LOCALTAG], L); data.get(globalTags[LOCALTAG], UL); data.get(globalTags[LOCALTAG], F); data.get(globalTags[LOCALTAG], D); data.get(globalTags[LOCALTAG], STR); for(x=0; x<1000 && !result; x++) { if((BYTE)input[x]!=C[x] || (short)input[x]!=S[x] || (unsigned short)input[x]!=US[x] || (int)input[x]!=I[x] || (unsigned int)input[x]!=UI[x] || (long)input[x]!=L[x] || (unsigned long)input[x]!=UL[x] || !equal((float)input[x],F[x]) || !equal(input[x],(double)D[x]) || !equal(input[x],(double)atof(STR[x]))) { if((BYTE)input[x]!=C[x]) fprintf(stdout, "* Byte %c != %c\n", (BYTE)input[x], C[x]); if((short)input[x]!=S[x]) fprintf(stdout, "* Short %i != %i\n", (short)input[x], S[x]); if((unsigned short)input[x]!=US[x]) fprintf(stdout, "* Unsigned short %i != %i\n", (unsigned short)input[x], US[x]); if((int)input[x]!=I[x]) fprintf(stdout, "* Int %i != %i\n", (int)input[x], I[x]); if((unsigned int)input[x]!=UI[x]) fprintf(stdout, "* Unsigned int %i != %i\n", (unsigned int)input[x], UI[x]); if((long)input[x]!=L[x]) fprintf(stdout, "* Long %i != %i\n", (long)input[x], L[x]); if((unsigned long)input[x]!=UL[x]) fprintf(stdout, "* Unsigned long %i != %i\n", (unsigned long)input[x], UL[x]); if(!equal((float)input[x],(double)F[x])) fprintf(stdout, "* Float %f != %f\n", (float)input[x], F[x]); if(!equal(input[x],D[x])) fprintf(stdout, "* Double %f != %f\n", input[x], D[x]); if(!equal(input[x],atof(STR[x]))) fprintf(stdout, "* String %f != %f\n", input[x], atof(STR[x])); result = -1; } delete STR[x]; } if(result) fprintf(stdout, "* MISMATCH BETWEEN SPECIFIED DATA AND RETRIEVED DATA\n"); if(result || bresult) return -1; return 0; } int stringArrayTest ( cdevData & data ) { int LOCALTAG = 19; int result = 0, bresult = 0; int x; char * input[1000]; cdevBounds bounds[3]; cdevBounds obounds[3]; BYTE C[1000]; short S[1000]; unsigned short US[1000]; int I[1000]; unsigned int UI[1000]; long L[1000]; unsigned long UL[1000]; float F[1000]; double D[1000]; char * STR[1000]; bounds[0].offset = 0; bounds[0].length = 5; bounds[1].offset = 0; bounds[1].length = 2; bounds[2].offset = 0; bounds[2].length = 100; for(x=0; x<1000; x++) { input[x] = new char[32]; sprintf(input[x], "%i.%i", x, x); } data.insert(globalTags[LOCALTAG], input, 1000, 3); data.setBounds(globalTags[LOCALTAG], bounds, 3); data.getBounds(globalTags[LOCALTAG], obounds, 3); for(x=0; x<3; x++) { if(bounds[x].offset!=obounds[x].offset) bresult = -1; } if(bresult!=0) fprintf(stdout, "* MISMATCH BETWEEN BOUNDS SPECIFIED AND BOUNDS READ\n"); data.get(globalTags[LOCALTAG], C); data.get(globalTags[LOCALTAG], S); data.get(globalTags[LOCALTAG], US); data.get(globalTags[LOCALTAG], I); data.get(globalTags[LOCALTAG], UI); data.get(globalTags[LOCALTAG], L); data.get(globalTags[LOCALTAG], UL); data.get(globalTags[LOCALTAG], F); data.get(globalTags[LOCALTAG], D); data.get(globalTags[LOCALTAG], STR); for(x=0; x<1000; x++) { if((BYTE)atof(input[x])!=C[x] || (short)atof(input[x])!=S[x] || (unsigned short)atof(input[x])!=US[x] || (int)atof(input[x])!=I[x] || (unsigned int)atof(input[x])!=UI[x] || (long)atof(input[x])!=L[x] || (unsigned long)atof(input[x])!=UL[x] || !equal(atof(input[x]),(double)F[x]) || !equal(atof(input[x]),D[x]) || strcmp(input[x],STR[x])) { result = -1; } delete STR[x]; delete input[x]; } if(result) fprintf(stdout, "* MISMATCH BETWEEN SPECIFIED DATA AND RETRIEVED DATA\n"); if(result || bresult) return -1; return 0; } int asciiDumpTest ( cdevData & data ) { data.asciiDump(stdout); return 0; } int copyTest ( cdevData & data ) { int result = 0; cdevData data2(data); char Val1[64], Val2[64]; char * val1[1000], * val2[1000]; int i, x; size_t dim1, dim2; for(i=0; i<10; i++) { data.getDim(globalTags[i], &dim1); data2.getDim(globalTags[i], &dim2); if(dim1!=dim2) { fprintf(stdout, "* MISMATCH BETWEEN DIMENSION SIZES ON %s\n", globalTagNames[i]); result = -1; } else if(data.getType(globalTags[i]) != data2.getType(globalTags[i])) { fprintf(stdout, "* MISMATCH BETWEEN DATA TYPES SIZES ON %s\n", globalTagNames[i]); result = -1; } data.get(globalTags[i], Val1, 64); data2.get(globalTags[i], Val2, 64); if(strcmp(Val1, Val2)) { result = -1; } } for(i=10; i<20; i++) { memset(val1, 0, 1000*sizeof(char *)); memset(val2, 0, 1000*sizeof(char *)); if(!data.get(globalTags[i], val1) && !data2.get(globalTags[i], val2)) { data.getDim(globalTags[i], &dim1); data2.getDim(globalTags[i], &dim2); if(dim1!=dim2) { fprintf(stdout, "* MISMATCH BETWEEN DIMENSION SIZES ON %s\n", globalTagNames[i]); result = -1; } else if(data.getType(globalTags[i]) != data2.getType(globalTags[i])) { fprintf(stdout, "* MISMATCH BETWEEN DATA TYPES SIZES ON %s\n", globalTagNames[i]); result = -1; } else if(dim1) { cdevBounds * bounds1 = new cdevBounds[dim1]; cdevBounds * bounds2 = new cdevBounds[dim2]; data.getBounds(globalTags[i], bounds1, dim1); data2.getBounds(globalTags[i], bounds2, dim2); for(x=0; x<(int)dim1; x++) { if(bounds1[x].offset != bounds2[x].offset || bounds1[x].length != bounds2[x].length) { result = -1; fprintf(stdout, "* MISMATCH BETWEEN BOUNDS SIZES ON %s\n", globalTagNames[i]); } } delete bounds1; delete bounds2; } for(x=0; x<1000; x++) { if(strcmp(val1[x], val2[x])) { fprintf(stdout, "* VALUE MISMATCH ON %s\n", globalTagNames[i]); result = -1; } delete val1[x]; delete val2[x]; } } else { fprintf(stdout, "* FAILURE TO READ DATA ON %s\n", globalTagNames[i]); for(x=0; x<1000; x++) { if(val1[x]!=NULL) delete val1[x]; if(val2[x]!=NULL) delete val2[x]; } result = -1; } } return result; } int removeTest (cdevData & data ) { int result = 0; int removedCnt = 0; int goneCnt = 0; int i; for(i=0; i<20; i+=3) { data.remove(globalTags[i]); removedCnt++; } for(i=0; i<20; i++) { if(data.getType(globalTags[i])==CDEV_INVALID) goneCnt++; } if(goneCnt!=removedCnt) return -1; for(i=0; i<20; i+=3) { if(data.getType(globalTags[i])!=CDEV_INVALID) return -1; } return 0; } int findTest ( cdevData & data ) { int result = 0; int x; // Test finding scalar value first BYTE c1, * c2; data.get (globalTags[0], &c1); data.find(globalTags[0], (void * &)c2); if(c1 != *c2) result = -1; // Test finding an array of values next int i1[1000], *i2; data.get(globalTags[13], i1); data.find(globalTags[13], (void * &)i2); for(x=0; x<1000; x++) { if(i1[x]!=i2[x]) result = -1; } // Test finding a single character string next char s1[100], *s2; data.get(globalTags[9], s1, 100); data.find(globalTags[9], (void * &)s2); if(strcmp(s1, s2)) result = -1; // Test finding an array of character strings char *S1[1000], ** S2; data.get(globalTags[19], S1); data.find(globalTags[19], (void * &)S2); for(x=0; x<1000; x++) { if(strcmp(S1[x], S2[x])) result = -1; delete S1[x]; } return result; } int xdrTest ( cdevData & data ) { int result = 0; char * buf; size_t bufLen; cdevData data2; data.xdrExport(&buf, &bufLen); data2.xdrImport(buf, bufLen); char Val1[64], Val2[64]; char * val1[1000], * val2[1000]; int i, x; size_t dim1, dim2; for(i=0; i<10; i++) { data.getDim(globalTags[i], &dim1); data2.getDim(globalTags[i], &dim2); if(dim1!=dim2) { fprintf(stdout, "* MISMATCH BETWEEN DIMENSION SIZES ON %s\n", globalTagNames[i]); result = -1; } else if(data.getType(globalTags[i]) != data2.getType(globalTags[i])) { fprintf(stdout, "* MISMATCH BETWEEN DATA TYPES SIZES ON %s\n", globalTagNames[i]); result = -1; } data.get(globalTags[i], Val1, 64); data2.get(globalTags[i], Val2, 64); if(strcmp(Val1, Val2)) { result = -1; } } for(i=10; i<20; i++) { memset(val1, 0, 1000*sizeof(char *)); memset(val2, 0, 1000*sizeof(char *)); if(!data.get(globalTags[i], val1) && !data2.get(globalTags[i], val2)) { data.getDim(globalTags[i], &dim1); data2.getDim(globalTags[i], &dim2); if(dim1!=dim2) { fprintf(stdout, "* MISMATCH BETWEEN DIMENSION SIZES ON %s\n", globalTagNames[i]); result = -1; } else if(data.getType(globalTags[i]) != data2.getType(globalTags[i])) { fprintf(stdout, "* MISMATCH BETWEEN DATA TYPES SIZES ON %s\n", globalTagNames[i]); result = -1; } else if(dim1) { cdevBounds * bounds1 = new cdevBounds[dim1]; cdevBounds * bounds2 = new cdevBounds[dim2]; data.getBounds(globalTags[i], bounds1, dim1); data2.getBounds(globalTags[i], bounds2, dim2); for(x=0; x<(int)dim1; x++) { if(bounds1[x].offset != bounds2[x].offset || bounds1[x].length != bounds2[x].length) { result = -1; fprintf(stdout, "* MISMATCH BETWEEN BOUNDS SIZES ON %s\n", globalTagNames[i]); } } delete bounds1; delete bounds2; } for(x=0; x<1000; x++) { if(strcmp(val1[x], val2[x])) { fprintf(stdout, "* VALUE MISMATCH ON %s\n", globalTagNames[i]); result = -1; } delete val1[x]; delete val2[x]; } } else { fprintf(stdout, "* FAILURE TO READ DATA ON %s\n", globalTagNames[i]); for(x=0; x<1000; x++) { if(val1[x]!=NULL) delete val1[x]; if(val2[x]!=NULL) delete val2[x]; } result = -1; } } return result; } int assignmentTest ( cdevData & data ) { int result = 0; cdevData data2; char Val1[64], Val2[64]; char * val1[1000], * val2[1000]; int i, x; size_t dim1, dim2; data2 = data; for(i=0; i<10; i++) { data.getDim(globalTags[i], &dim1); data2.getDim(globalTags[i], &dim2); if(dim1!=dim2) { fprintf(stdout, "* MISMATCH BETWEEN DIMENSION SIZES ON %s\n", globalTagNames[i]); result = -1; } else if(data.getType(globalTags[i]) != data2.getType(globalTags[i])) { fprintf(stdout, "* MISMATCH BETWEEN DATA TYPES SIZES ON %s\n", globalTagNames[i]); result = -1; } data.get(globalTags[i], Val1, 64); data2.get(globalTags[i], Val2, 64); if(strcmp(Val1, Val2)) { result = -1; } } for(i=10; i<20; i++) { memset(val1, 0, 1000*sizeof(char *)); memset(val2, 0, 1000*sizeof(char *)); if(!data.get(globalTags[i], val1) && !data2.get(globalTags[i], val2)) { data.getDim(globalTags[i], &dim1); data2.getDim(globalTags[i], &dim2); if(dim1!=dim2) { fprintf(stdout, "* MISMATCH BETWEEN DIMENSION SIZES ON %s\n", globalTagNames[i]); result = -1; } else if(data.getType(globalTags[i]) != data2.getType(globalTags[i])) { fprintf(stdout, "* MISMATCH BETWEEN DATA TYPES SIZES ON %s\n", globalTagNames[i]); result = -1; } else if(dim1) { cdevBounds * bounds1 = new cdevBounds[dim1]; cdevBounds * bounds2 = new cdevBounds[dim2]; data.getBounds(globalTags[i], bounds1, dim1); data2.getBounds(globalTags[i], bounds2, dim2); for(x=0; x<(int)dim1; x++) { if(bounds1[x].offset != bounds2[x].offset || bounds1[x].length != bounds2[x].length) { result = -1; fprintf(stdout, "* MISMATCH BETWEEN BOUNDS SIZES ON %s\n", globalTagNames[i]); } } delete bounds1; delete bounds2; } for(x=0; x<1000; x++) { if(strcmp(val1[x], val2[x])) { fprintf(stdout, "* VALUE MISMATCH ON %s\n", globalTagNames[i]); result = -1; } delete val1[x]; delete val2[x]; } } else { fprintf(stdout, "* FAILURE TO READ DATA ON %s\n", globalTagNames[i]); for(x=0; x<1000; x++) { if(val1[x]!=NULL) delete val1[x]; if(val2[x]!=NULL) delete val2[x]; } result = -1; } } return result; }