- Timestamp:
- Mar 16, 2008, 7:45:37 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/nni_test.cc
r1210 r1242 24 24 */ 25 25 26 #include "Suite.h" 27 26 28 #include "yat/utility/FileUtil.h" 27 29 #include "yat/utility/Matrix.h" … … 44 46 } 45 47 46 int main( const int argc,constchar* argv[])48 int main(int argc, char* argv[]) 47 49 { 48 bool print = (argc>1 && argv[1]==std::string("-p"));49 bool ok = true; 50 test::Suite suite(argc, argv); 51 50 52 uint neighbours=3; 51 53 std::string knni_data("data/knni_matrix.data"); … … 76 78 for (unsigned int j=0; j<control.columns(); j++) 77 79 if (std::abs(control(i,j))>error_bound) { 78 if (print) 79 std::cerr << "kNNI FAILED, error on row " << i << " and " 80 suite.err() << "kNNI FAILED, error on row " << i << " and " 80 81 << "column " << j << " is " << std::abs(control(i,j)) 81 82 << ". Expected less than " << error_bound << std::endl; 82 ok=false; // calculation result out of accepted error bounds83 suite.add(false); // calculation result out of accepted error bounds 83 84 } 84 85 else 85 86 if (!((control(i,j)==control(i,j)))) { 86 if (print) 87 std::cerr << "kNNI FAILED, nan (not a number) " 87 suite.err() << "kNNI FAILED, nan (not a number) " 88 88 << "encountered in test on row " << i 89 89 << " and column " << j << std::endl; 90 ok =false; // calucaltion error detected90 suite.add(false); // calucaltion error detected 91 91 } 92 92 control_stream.close(); … … 107 107 for (unsigned int j=0; j<control.columns(); j++) 108 108 if (std::abs(control(i,j))>error_bound) { 109 if (print) 110 std::cerr << "WeNNI FAILED, error on row " << i << " and " 109 suite.err() << "WeNNI FAILED, error on row " << i << " and " 111 110 << "column " << j << " is " << std::abs(control(i,j)) 112 111 << ". Expected less than " << error_bound << std::endl; 113 ok=false; // calculation result out of accepted error bounds112 suite.add(false); // calculation result out of accepted error bounds 114 113 } 115 114 else 116 115 if (!((control(i,j)==control(i,j)))) { 117 if (print) 118 std::cerr << "WeNNI FAILED, nan (not a number) " 116 suite.err() << "WeNNI FAILED, nan (not a number) " 119 117 << "encountered in test on row " << i 120 118 << " and column " << j << std::endl; 121 ok=false; // calucaltion error detected119 suite.add(false); // calucaltion error detected 122 120 } 123 121 control_stream.close(); … … 138 136 for (unsigned int j=0; j<control.columns(); j++) 139 137 if (std::abs(control(i,j))>error_bound) { 140 if (print) 141 std::cerr << "WeNNI binary weight test FAILED.\nError on row " << i 138 suite.err() << "WeNNI binary weight test FAILED.\nError on row " << i 142 139 << " and column " << j << " is " << std::abs(control(i,j)) 143 140 << ". Expected less than " << error_bound << std::endl; 144 ok=false; // calculation result out of accepted error bounds141 suite.add(false); // calculation result out of accepted error bounds 145 142 } 146 143 else 147 144 if (!((control(i,j)==control(i,j)))) { 148 if (print) 149 std::cerr << "WeNNI binary wieght test FAILED.\n" 145 suite.err() << "WeNNI binary wieght test FAILED.\n" 150 146 << "nan (not a number) encountered in test on row " << i 151 147 << " and column " << j << std::endl; 152 ok=false; // calucaltion error detected148 suite.add(false); // calucaltion error detected 153 149 } 154 150 control_stream.close(); … … 156 152 weight_stream.close(); 157 153 158 return (ok ? 0 : -1);154 return suite.return_value(); 159 155 }
Note: See TracChangeset
for help on using the changeset viewer.