Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

/home/vlg/develop/gwavmerger/tests/name_utils_test.cpp File Reference

#include <iostream>

Include dependency graph for name_utils_test.cpp:

Include dependency graph

Go to the source code of this file.

Functions

int main ()

Variables

const char * list []
const char * list_non_uniform_format []
const char * list_with_gaps []
const char * list_bad_format []


Function Documentation

int main  
 

Definition at line 40 of file name_utils_test.cpp.

References format_seqnum, list, list_bad_format, list_non_uniform_format, list_with_gaps, make_name_with_offset, make_prev_name, parse_format, and parse_seq_number.

00041 {
00042     int i;
00043     string format;
00044     vector<string> v;
00045 
00046     cout << '\n' << "Testing parse_format() ...";
00047 
00048     i = 0;
00049     while (list [i]) { v.push_back (list [i++]); }
00050 
00051     format = parse_format ("ru_", v);
00052     if (format != "%03d") {
00053         cout << "failed valid list\n";
00054         cout << "(expected \"%03\", returned \"" << format << "\"\n\n";
00055         return 1;
00056     }
00057     
00058     v.clear ();
00059     i = 0;
00060     while (list_with_gaps [i]) { v.push_back (list_with_gaps [i++]); }
00061 
00062     format = parse_format ("ru_", v);
00063     if (format != "%03d") {
00064         cout << "failed list with gaps\n";
00065         return 1;
00066     }
00067 
00068     v.clear ();
00069     i = 0;
00070     while (list_non_uniform_format [i]) { 
00071         v.push_back (list_non_uniform_format [i++]); 
00072     }
00073 
00074     format = parse_format ("ru_", v);
00075     if (format != "%d") {
00076         cout << "failed list with non-uniform format\n";
00077         cout << "(expected \"\", returned \"" << format << "\"\n\n";
00078         return 1;
00079     }
00080     v.clear ();
00081 
00082     i = 0;
00083     while (list_bad_format [i]) { 
00084         v.push_back (list_bad_format [i++]); 
00085     }
00086 
00087     format = parse_format ("ru_", v);
00088     if (format != "") {
00089         cout << "failed list with bad format\n";
00090         cout << "(expected \"\", returned \"" << format << "\"\n\n";
00091         return 1;
00092     }
00093     cout << "ok\n";
00094 
00095     cout << "\nTesting parse_seq_num() ";
00096     string res;
00097     string name;
00098     name = "ru_00034.wav";
00099     res = parse_seq_number (name, "ru_");
00100     if (res != "00034") {
00101         cout << "failed (expected \"00034\", returned \"" << res << "\"\n\n";
00102         return 1;
00103     }
00104     res = parse_seq_number (name, "en_");
00105     if (res != "") {
00106         cout << "failed (expected \"\", returned \"" << res << "\"\n\n";
00107         return 1;
00108     }
00109     name = "ru_0999";
00110     res = parse_seq_number (name, "ru_");
00111     if (res != "") {
00112         cout << "failed (expected \"\", returned \"" << res << "\"\n\n";
00113         return 1;
00114     }
00115     name = "ru_0999.wav";
00116     res = parse_seq_number (name, "ru_");
00117     if (res != "0999") {
00118         cout << "failed (expected \"0999\", returned \"" << res << "\"\n\n";
00119         return 1;
00120     }
00121     cout << "ok\n";
00122 
00123     cout << "\nTesting format_seqnum () ";
00124     res = format_seqnum (54, "%03d");
00125     if (res != "054") {
00126         cout << "failed (expected \"054\", returned \"" << res << "\"\n\n";
00127         return 1;
00128     }
00129 
00130     res = format_seqnum (54, "%d");
00131     if (res != "54") {
00132         cout << "failed (expected \"54\", returned \"" << res << "\"\n\n";
00133         return 1;
00134     }
00135     cout << "ok\n";
00136 
00137     cout << "\nTesting make_name_with_offset () ";
00138     string dirpath ("/English/Test/");
00139     format = "%04d";
00140     name = "ru_0999.wav";
00141     res = make_name_with_offset (name, format, "ru_", dirpath, 0);
00142 
00143     if (res != dirpath + "ru_0999.wav") {
00144         cout << "failed\n\t(expected \"/English/Test/ru_0999.wav\""
00145              << ", returned \"" << res << "\")\n\n";
00146         return 1;
00147     }
00148     cout << "ok\n";
00149 
00150     cout << "\nTesting make_prev_name () ";
00151     res = make_prev_name (name, format, "ru_", dirpath);
00152     if (res != dirpath + "ru_0998.wav") {
00153         cout << "failed\n\t(expected \"/English/Test/ru_0998.wav\""
00154              << ", returned \"" << res << "\")\n\n";
00155         return 1;
00156     }
00157     res.erase (0, dirpath.length ());
00158     name = res;
00159     res = make_prev_name (name, format, "ru_", dirpath);
00160     if (res != dirpath + "ru_0997.wav") {
00161         cout << "failed\n\t(expected \"/English/Test/ru_0997.wav\""
00162              << ", returned \"" << res << "\")\n\n";
00163         return 1;
00164     }
00165     cout << "ok\n";
00166 
00167     cout << "\n";
00168 }


Variable Documentation

const char* list[] [static]
 

Initial value:

{ 
    "ru_001.wav", "ru_002.wav", "ru_003.wav", 
    "ru_004.wav", "ru_005.wav", NULL 
}

Definition at line 17 of file name_utils_test.cpp.

Referenced by main.

const char* list_bad_format[] [static]
 

Initial value:

{ 
    "ru_001.wav", "en_002.wav", "ru_003.wav", 
    "ru_004.wav", "", "ru_006.wav", NULL 
}

Definition at line 32 of file name_utils_test.cpp.

Referenced by main.

const char* list_non_uniform_format[] [static]
 

Initial value:

{ 
    "ru_001.wav", "ru_2.wav", "ru_003.wav", 
    "ru_004.wav", "ru_005.wav", NULL 
}

Definition at line 22 of file name_utils_test.cpp.

Referenced by main.

const char* list_with_gaps[] [static]
 

Initial value:

{ 
    "ru_001.wav", "gap", "ru_003.wav", 
    "ru_004.wav", "gap", "ru_006.wav", NULL 
}

Definition at line 27 of file name_utils_test.cpp.

Referenced by main.


Generated on Tue Feb 11 23:05:31 2003 for gwavmerger by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002