MCPcopy Create free account
hub / github.com/amule-project/amule / run

Method run

unittests/tests/TextFileTest.cpp:174–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172 }
173
174 virtual void run()
175 {
176 const char* lines[] = {
177 " # comment",
178 "abc",
179 "# foo bar",
180 " ",
181 "def ghi ",
182 "",
183 "# xyz",
184 " xyz",
185 " ",
186 ""
187 };
188
189 {
190 CONTEXT("Writing lines manually");
191
192 CTextFile file;
193 ASSERT_TRUE(file.Open("testfile.txt", CTextFile::write));
194
195 for (size_t i = 0; i < ArraySize(lines); ++i) {
196 CONTEXT(wxString::Format("Writing the %i'th line.", static_cast<int>(i)));
197
198 ASSERT_TRUE(file.WriteLine(lines[i]));
199 }
200 }
201
202 {
203 CONTEXT("Reading manually written lines");
204
205 CTextFile file;
206 ASSERT_TRUE(file.Open("testfile.txt", CTextFile::read));
207 ASSERT_FALSE(file.Eof());
208
209 for (size_t i = 0; i < ArraySize(lines); ++i) {
210 CONTEXT(wxString::Format("Reading the %i'th line.", static_cast<int>(i)));
211
212 ASSERT_EQUALS(lines[i], file.GetNextLine());
213 }
214 ASSERT_TRUE(file.Eof());
215 }
216
217 {
218 CONTEXT("Writing lines automatically");
219
220 CTextFile file;
221 ASSERT_FALSE(file.IsOpened());
222 ASSERT_TRUE(file.Open("testfile.txt", CTextFile::write));
223 ASSERT_TRUE(file.WriteLines(wxArrayString(ArraySize(lines), lines)));
224 ASSERT_TRUE(file.IsOpened());
225 }
226
227 {
228 CONTEXT("Reading automatically written lines");
229
230 CTextFile file;
231 ASSERT_FALSE(file.IsOpened());

Callers

nothing calls this directly

Calls 8

ArraySizeFunction · 0.85
wxArrayStringClass · 0.85
WriteLineMethod · 0.80
GetNextLineMethod · 0.80
WriteLinesMethod · 0.80
OpenMethod · 0.45
EofMethod · 0.45
IsOpenedMethod · 0.45

Tested by

no test coverage detected