- Timestamp:
- May 9, 2008, 2:37:57 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/stats_test.cc
r633 r634 37 37 #include <iostream> 38 38 #include <numeric> 39 #include <sstream>40 39 #include <string> 41 40 #include <vector> … … 49 48 bool test_add(void); 50 49 bool test_blame(void); 51 bool test_cache(const Stats&);52 50 bool test_classic(void); 53 51 bool test_base_class(const Stats&); … … 69 67 } 70 68 71 //ok &= test_add();72 //ok &= test_blame();69 ok &= test_add(); 70 ok &= test_blame(); 73 71 ok &= test_classic(); 74 72 … … 112 110 113 111 114 bool test_cache(const Stats& stats)115 {116 std::cerr << "test cache " << std::endl;117 std::stringstream ss;118 stats.print(ss);119 ClassicStats new_stats(path());120 if (!new_stats.load_cache(ss)) {121 std::cerr << "Failed reloading cache" << std::endl;122 return false;123 }124 std::cerr << "Hello" << std::endl;125 ss.clear(std::ios::goodbit);126 if (stats.authors() != new_stats.authors()) {127 std::cerr << "Error: cache: authors not the same\n";128 return false;129 }130 std::cerr << "Hello2" << std::endl;131 if (stats.revision()!=new_stats.revision()) {132 std::cerr << "Error: cache: revision not the same\n";133 return false;134 }135 try {136 for (int lt=0; lt<1; ++lt) {137 for (std::set<std::string>::const_iterator a=stats.authors().begin();138 a!=stats.authors().end(); ++a) {139 for (svn_revnum_t rev=0; rev<=stats.revision(); ++rev) {140 std::cerr << "lt: " << lt << std::endl;141 std::cerr << "author: " << *a << std::endl;142 std::cerr << "rev: " << rev << std::endl;143 if (stats(lt, *a, rev)!=new_stats(lt, *a, rev)) {144 std::cerr << "Error cache:\n";145 std::cerr << "lt: " << lt << std::endl;146 std::cerr << "author: " << *a << std::endl;147 std::cerr << "rev: " << rev << std::endl;148 std::cerr << stats(lt, *a, rev) << " not equal "149 << new_stats(lt, *a, rev) << std::endl;150 return false;151 }152 }153 }154 }155 }156 catch (std::runtime_error& e) {157 std::cerr << "Caught an exception. what(): " << e.what() << "\n";158 return false;159 }160 161 std::stringstream ss2;162 new_stats.print(ss2);163 if (ss.str()!=ss2.str()) {164 std::cerr << "ERROR: reprinted cache not equal first printed cache\n";165 166 std::string line;167 std::string line2;168 std::size_t line_no=1;169 ss.seekg(0);170 ss2.seekg(0);171 assert(ss.good());172 assert(ss2.good());173 while (getline(ss, line) && getline(ss2, line2) ) {174 if (line==line2) {175 std::cerr << line_no << " " << line << "\n";176 }177 else {178 std::cerr << line_no << "< " << line << "\n";179 std::cerr << line_no << "> " << line2 << "\n";180 return false;181 }182 ++line_no;183 }184 return false;185 }186 return true;187 }188 189 190 112 bool test_classic(void) 191 113 { … … 193 115 ClassicStats cs(path()); 194 116 cs.parse(path()); 195 //ok &= test_base_class(cs); 196 197 // Peter, should be included in test_base_test() 198 ok &= test_cache(cs); 117 ok &= test_base_class(cs); 199 118 200 119 // testing copyright lines for peter
Note: See TracChangeset
for help on using the changeset viewer.