diff options
author | Mathias Gumz <akira at fluxbox dot org> | 2011-03-18 14:51:17 (GMT) |
---|---|---|
committer | Mathias Gumz <akira at fluxbox dot org> | 2011-03-18 14:51:17 (GMT) |
commit | 253f13d46ed96dd9a4ed8619820d14098d547fc8 (patch) | |
tree | b0d485fab64182be446d764d8adc211e8804eb55 /src/tests/main.cc | |
parent | 81b240e9762acde7e3682a6cec02932564d122f6 (diff) | |
download | fluxbox_paul-253f13d46ed96dd9a4ed8619820d14098d547fc8.zip fluxbox_paul-253f13d46ed96dd9a4ed8619820d14098d547fc8.tar.bz2 |
some love to src/tests, use automake to use the same build environment as the rest of fluxbox
Diffstat (limited to 'src/tests/main.cc')
-rw-r--r-- | src/tests/main.cc | 142 |
1 files changed, 0 insertions, 142 deletions
diff --git a/src/tests/main.cc b/src/tests/main.cc deleted file mode 100644 index 04e1363..0000000 --- a/src/tests/main.cc +++ /dev/null | |||
@@ -1,142 +0,0 @@ | |||
1 | // main.cc for testing menu in fluxbox | ||
2 | // Copyright (c) 2001 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) | ||
3 | // | ||
4 | // Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | // copy of this software and associated documentation files (the "Software"), | ||
6 | // to deal in the Software without restriction, including without limitation | ||
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | // and/or sell copies of the Software, and to permit persons to whom the | ||
9 | // Software is furnished to do so, subject to the following conditions: | ||
10 | // | ||
11 | // The above copyright notice and this permission notice shall be included in | ||
12 | // all copies or substantial portions of the Software. | ||
13 | // | ||
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | // DEALINGS IN THE SOFTWARE. | ||
21 | |||
22 | #include "../StringUtil.hh" | ||
23 | |||
24 | #include <iostream> | ||
25 | #include <fstream> | ||
26 | #include <string> | ||
27 | #include <vector> | ||
28 | |||
29 | using namespace std; | ||
30 | |||
31 | bool loadMenu(string filename); | ||
32 | bool loadMenu2(string filename); | ||
33 | |||
34 | void showError(int line, int pos, string& instr) { | ||
35 | |||
36 | cerr<<"Error on line: "<<line<<endl; | ||
37 | cerr<<instr<<endl; | ||
38 | for (int c=0; c<pos; c++) { | ||
39 | if (instr[c]=='\t') | ||
40 | cerr<<'\t'; | ||
41 | else | ||
42 | cerr<<" "; | ||
43 | } | ||
44 | cerr<<"^ here"<<endl; | ||
45 | |||
46 | } | ||
47 | |||
48 | int main(int argc, char **argv) { | ||
49 | string filename = "menu"; | ||
50 | if (argc>1) | ||
51 | filename = argv[1]; | ||
52 | if (loadMenu2(filename)) | ||
53 | cout<<"Load successfull"<<endl; | ||
54 | else | ||
55 | cout<<"Load failed"<<endl; | ||
56 | |||
57 | /* | ||
58 | string out; | ||
59 | vector<string> stringlist; | ||
60 | stringlist.push_back(" \t\t\t \t[(in \\)\t haha )] \t\t "); | ||
61 | stringlist.push_back("(in\\)) {_ _ my_ _}"); | ||
62 | stringlist.push_back("(in) {_ _ my_ _}"); | ||
63 | stringlist.push_back("(in){_ _ my_ _}"); | ||
64 | stringlist.push_back("\t \t \t ( in ) {haha}"); | ||
65 | stringlist.push_back("\t \t \t (( in \\) ) {haha}"); | ||
66 | stringlist.push_back("\t \t \t (( in \\) ){hihi}"); | ||
67 | stringlist.push_back("\t \t \t (( in \\) )|{hihi}"); | ||
68 | for (unsigned int i=0; i<stringlist.size(); i++) { | ||
69 | int pos = StringUtil::getStringBetween(out, stringlist[i].c_str(), '(', ')'); | ||
70 | int total_pos = 0; | ||
71 | if (pos<0) { | ||
72 | showError(i+1, -pos, stringlist[i]); | ||
73 | continue; | ||
74 | } | ||
75 | cerr<<"string="<<stringlist[i]<<endl; | ||
76 | cerr<<"pos="<<pos<<" ::"<<out; | ||
77 | total_pos += pos; | ||
78 | pos = StringUtil::getStringBetween(out, stringlist[i].c_str()+total_pos, '{', '}'); | ||
79 | if (pos<=0) { | ||
80 | pos=-pos; | ||
81 | showError(i+1, total_pos+pos, stringlist[i]); | ||
82 | continue; | ||
83 | } | ||
84 | cerr<<"::"<<out<<"::"<<endl; | ||
85 | total_pos += pos; | ||
86 | } | ||
87 | */ | ||
88 | return 0; | ||
89 | } | ||
90 | |||
91 | |||
92 | |||
93 | bool loadMenu2(string filename) { | ||
94 | |||
95 | if (!filename.size()) | ||
96 | return false; | ||
97 | |||
98 | ifstream menufile(filename.c_str()); | ||
99 | |||
100 | |||
101 | if (menufile) { | ||
102 | string instr; | ||
103 | vector<string> args; | ||
104 | int line=0; | ||
105 | while (!menufile.eof()) { | ||
106 | //read a line | ||
107 | getline(menufile, instr); | ||
108 | line++; | ||
109 | string arg; | ||
110 | int pos = StringUtil::getStringBetween(arg, instr.c_str(), '[', ']'); | ||
111 | if (pos<=0) { | ||
112 | showError(line, -pos, instr); | ||
113 | continue; | ||
114 | } | ||
115 | |||
116 | cerr<<"("<<line<<"):"<<arg<<"::"; | ||
117 | int total_pos = pos; | ||
118 | pos = StringUtil::getStringBetween(arg, instr.c_str()+pos, '(', ')'); | ||
119 | if (pos<=0) { | ||
120 | showError(line, total_pos+(-pos), instr); | ||
121 | continue; | ||
122 | } | ||
123 | cerr<<arg<<"::"; | ||
124 | |||
125 | total_pos +=pos; | ||
126 | pos = StringUtil::getStringBetween(arg, instr.c_str()+total_pos, '{', '}'); | ||
127 | if (pos<=0) { | ||
128 | total_pos = total_pos+(-pos); | ||
129 | showError(line, total_pos, instr); | ||
130 | continue; | ||
131 | } | ||
132 | cerr<<arg<<":"<<endl; | ||
133 | |||
134 | } | ||
135 | |||
136 | |||
137 | } else | ||
138 | return false; | ||
139 | |||
140 | return true; | ||
141 | } | ||
142 | |||