Changeset 548
- Timestamp:
- 08/18/09 11:06:04 (15 years ago)
- Location:
- library
- Files:
-
- 1 added
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/base/loggers.h
r529 r548 35 35 string itfilename; 36 36 public: 37 //!Default constructor38 37 memlog ( int maxlen0, string itf = "" ) : maxlen ( maxlen0 ), ind ( 0 ), vectors ( 0 ), itfilename ( itf ) {} 39 38 40 memlog() : ind ( 0 ), vectors ( 0 ) {} 39 //!Default constructor 40 memlog() : maxlen ( 0 ), ind ( 0 ), vectors ( 0 ) {} 41 41 42 42 //! Initialize storage -
library/tests/loggers_test.cpp
r493 r548 4 4 #include "UnitTest++.h" 5 5 #include <string> 6 #include <stdexcept> 6 7 #include <sys/stat.h> 7 8 #include <sys/types.h> 9 #include <unistd.h> 8 10 9 11 using namespace bdm; 12 13 int get_file_size ( const char *fname ) { 14 struct stat st; 15 if ( stat ( fname, &st ) ) { 16 std::string msg = "can't stat "; 17 msg += fname; 18 throw std::runtime_error ( msg ); 19 } 20 21 int sz = static_cast<int>(st.st_size); 22 if ( sz != st.st_size ) { 23 std::string msg = fname; 24 msg += " too big"; 25 throw std::runtime_error ( msg ); 26 } 27 28 return sz; 29 } 30 31 TEST ( test_memlog ) { 32 RV th = RV ( "{alog blog }" ); 33 RV r = RV ( "{r }", "2" ); 34 35 string ls ( "test_log.bin" ); 36 remove_all ( ls.c_str() ); 37 38 memlog logger ( 100, ls ); 39 40 int rid = logger.add ( r, "" ); 41 int thid = logger.add ( th, "th" ); 42 43 logger.init(); 44 45 for ( int i = 0; i < 10; i++ ) { 46 logger.logit ( rid, vec_2 ( ( double ) i, ( double ) ( i + 1 ) ) ); 47 logger.logit ( thid, vec_2 ( ( double ) ( 100 - i ), ( double ) ( i - 50 ) ) ); 48 logger.step(); 49 } 50 51 logger.finalize(); 52 53 CHECK_EQUAL ( get_file_size ( "test_log.matrix" ), get_file_size ( ls.c_str() ) ); 54 } 10 55 11 56 TEST ( test_dirfilelog ) { … … 20 65 dirfilelog L ( "exp/dirfile", 10 ); 21 66 22 int rid; 23 int thid; 24 25 rid = L.add ( r, "" ); 26 thid = L.add ( th, "th" ); 67 int rid = L.add ( r, "" ); 68 int thid = L.add ( th, "th" ); 27 69 28 70 L.init();