00001
00002
00004
00005 #include <simgear/compiler.h>
00006
00007 #include <iostream>
00008 #include "tabbed_values.hxx"
00009
00010 using std::cout;
00011 using std::cerr;
00012 using std::endl;
00013
00014
00015 int main (int ac, char ** av)
00016 {
00017 const char* string1 = "Hello\tWorld\t34\tZ\t\tThere Is No Spoon";
00018
00019 SGTabbedValues tv(string1);
00020
00021 if (tv[0] != "Hello") {
00022 cerr << "failed to read string at index 0" << endl;
00023 return 1;
00024 }
00025
00026 if (tv[1] != "World") {
00027 cerr << "failed to read string at index 1" << endl;
00028 return 1;
00029 }
00030
00031 if (tv[2] != "34") {
00032 cerr << "failed to read string at index 2" << endl;
00033 return 1;
00034 }
00035
00036 double dval = tv.getDoubleAt(2);
00037 if (dval != 34.0) {
00038 cerr << "failed to read double at index 2" << endl;
00039 return 2;
00040 }
00041
00042 char cval = tv.getCharAt(3);
00043 if (cval != 'Z') {
00044 cerr << "failed to read char at index 3" << endl;
00045 return 1;
00046 }
00047
00048 cval = tv.getCharAt(0);
00049 if (cval != 'H') {
00050 cerr << "failed to read char at index 0" << endl;
00051 return 1;
00052 }
00053
00054 if (tv.isValueAt(4)) {
00055 cerr << "didn't identify skipped value correctly" << endl;
00056 return 3;
00057 }
00058
00059 if (!tv.isValueAt(3)) {
00060 cerr << "didn't identify present value correctly" << endl;
00061 return 3;
00062 }
00063
00064 if (tv[5] != "There Is No Spoon") {
00065 cerr << "failed to read string at index 5 (got [" << tv[5] << "]" << endl;
00066 return 1;
00067 }
00068
00069 cout << "all tests passed successfully!" << endl;
00070 return 0;
00071 }