77 "usage: tsofttest file [-t1] [-t2] [-t3] [-t4] [-t5] [-v] [-D]" "\n" 78 " or: tsofttest --help|-h" "\n" 85 "file TSOFT file" "\n" 88 "-t1 test individual components" "\n" 89 "-t2 test trimws" "\n" 90 "-t3 test class tsoftfile" "\n" 91 "-t4 test translation table" "\n" 92 "-t5 test itsoftstream" "\n" 96 using namespace tfxx::cmdline;
97 static Declare options[]=
121 cerr << usage_text << endl;
126 Commandline cmdline(iargc, argv, options);
129 if (cmdline.optset(0))
131 cerr << usage_text << endl;
132 cerr << help_text << endl;
138 opt.
test1=cmdline.optset(2);
139 opt.
test2=cmdline.optset(3);
140 opt.
test3=cmdline.optset(4);
141 opt.
debug=cmdline.optset(5);
142 opt.
ttest=cmdline.optset(6);
143 opt.
stest=cmdline.optset(7);
169 TFXX_assert(cmdline.extra(),
"missing file name");
170 std::string filename=cmdline.next();
172 { cout <<
"test TSOFT reading on file " << filename << endl; }
180 { cout <<
"test 1: test individual components" << endl; }
181 std::ifstream is(filename.c_str());
184 bool inchannels=
false;
193 cout <<
"<" << theline.theline() <<
">" << endl;
194 if (theline.hastag())
200 cout <<
"tag: " << theline.thetag() <<
"; ";
201 if (theline.hascontent())
203 cout <<
"content: " << theline.thecontent() << endl;
207 cout <<
"no content" << endl;
216 cout << line << endl;
218 cout << theline.time().timestring() << endl;
220 for (
int i=0;i<theline.nsamples();++i)
222 cout << theline.sample(i) <<
"; ";
244 { cout <<
"test 2: test trimws" << endl; }
245 cout <<
"++++" <<
passtrimws(
" hdj wed ") <<
"++++" << endl;
246 cout <<
"++++" <<
passtrimws(
" hdj wed") <<
"++++" << endl;
247 cout <<
"++++" <<
passtrimws(
"hdj wed ") <<
"++++" << endl;
248 cout <<
"++++" <<
passtrimws(
" ") <<
"++++" << endl;
249 cout <<
"++++" <<
passtrimws(
"") <<
"++++" << endl;
258 { cout <<
"test 3: test class tsoftfile" << endl; }
259 std::ifstream is(filename.c_str());
264 filefree.append(thefile.free());
269 for (
int ich=0; ich<dc.
nchannels(); ++ich)
271 cout <<
"channel #" << ich <<
":" << endl;
272 cout <<
"===========" << endl;
275 sff::FREE channelfree;
278 cout <<
"number of available sequences: " << cd.
ntraces() << endl;
279 for (
int iseq=0; iseq<cd.
ntraces(); ++iseq)
282 cout <<
" sequence #" << iseq <<
":" << endl;
283 cout <<
" =============" << endl;
284 cout <<
" start: " << ds.
date().timestring() << endl;
285 cout <<
" dt: " << ds.
interval().timestring() << endl;
287 cout <<
" number of samples: " << s.size() << endl;
288 int nsmp=s.size() < 10 ? s.size() : 10;
290 for (
int isa=0; isa<nsmp; ++isa)
292 cout <<
" " << s(f+isa) << endl;
304 { cout <<
"ttest: translation table" << endl; }
308 cout <<
"The translation table is unique" << endl;
312 cout <<
"ATTENTION: The translation table is ambiguous" << endl;
322 { cout <<
"stest: itsoftstream" << endl; }
323 std::ifstream is(filename.c_str());
327 "stream is not good although no trace has been read");
331 sff::WID2 wid2=its.wid2();
332 sff::FREE free=its.free();
334 cout <<
"WID2 line of next trace:" << endl;
336 cout <<
"FREE block of next trace:" << endl;
338 cout <<
"some samples of of next trace:" << endl;
339 int nsa=series.size() < 10 ? series.size() : 10;
340 for (
int isa=0; isa<nsa; ++isa)
342 cout << series(isa+series.f()) << endl;
#define DATRW_assert(C, M)
Check an assertion and report by throwing an exception.
int ntraces() const
number of data traces
const char * tagdata
TSOFT data tag.
trace of contiguous data.
contains takes one line and splits it into tag and information.
void reporttranslation(std::ostream &os)
report translation table
const std::string & thedatatype() const
return datatype
std::string passtrimws(std::string line)
void series(const Tdseries &s)
set series
aff::Series< double > Tdseries
int nchannels() const
return number of channels
const Datatrace & trace(const unsigned int &i) const
return data trace
bool translationisunique(const bool &verbose)
check uniqueness of translation table
const std::string & theinstrument() const
return instrument
#define TSOFTTEST_VERSION
void chinfo(const Channelinfo &ci)
set channel info
Tlos channelinfofree(const Channelinfo &ci)
prepare free comment block from channel info
void setchannelinfo(const std::string &line)
set channel info
const std::string & thelocation() const
return location
void date(const libtime::TAbsoluteTime d)
set time of first sample
const char * tagchannels
TSOFT channels tag.
Channeldata & channel(const unsigned int &i, const bool &debug=false)
return data for specific channel
void interval(const libtime::TRelativeTime i)
set sampling interval
std::string getDOSline(std::istream &is)
helper function getDOSline