ソースを参照

less default file IO in test units

Alexander Freytag 11 年 前
コミット
ec19bcf42c
2 ファイル変更68 行追加58 行削除
  1. 23 19
      tests/TestGPHIKOnlineLearnable.cpp
  2. 45 39
      tests/TestGPHIKRegression.cpp

+ 23 - 19
tests/TestGPHIKOnlineLearnable.cpp

@@ -25,6 +25,7 @@ using namespace NICE;  // nice-core
 
 const bool verboseStartEnd = true;
 const bool verbose = false;
+const bool writeClassifiersForVerification = false;
 
 
 CPPUNIT_TEST_SUITE_REGISTRATION( TestGPHIKOnlineLearnable );
@@ -557,25 +558,28 @@ void TestGPHIKOnlineLearnable::testOnlineLearningMultiClass()
   
   
   // TEST that both classifiers produce equal store-files
-   std::string s_destination_save_IL ( "myClassifierIL.txt" );
-  
-  std::filebuf fbOut;
-  fbOut.open ( s_destination_save_IL.c_str(), ios::out );
-  std::ostream os (&fbOut);
-  //
-  classifier->store( os );
-  //   
-  fbOut.close(); 
-  
-  std::string s_destination_save_scratch ( "myClassifierScratch.txt" );
-  
-  std::filebuf fbOutScratch;
-  fbOutScratch.open ( s_destination_save_scratch.c_str(), ios::out );
-  std::ostream osScratch (&fbOutScratch);
-  //
-  classifierScratch->store( osScratch );
-  //   
-  fbOutScratch.close(); 
+  if ( writeClassifiersForVerification )
+  {
+    std::string s_destination_save_IL ( "myClassifierIL.txt" );
+    
+    std::filebuf fbOut;
+    fbOut.open ( s_destination_save_IL.c_str(), ios::out );
+    std::ostream os (&fbOut);
+    //
+    classifier->store( os );
+    //   
+    fbOut.close(); 
+    
+    std::string s_destination_save_scratch ( "myClassifierScratch.txt" );
+    
+    std::filebuf fbOutScratch;
+    fbOutScratch.open ( s_destination_save_scratch.c_str(), ios::out );
+    std::ostream osScratch (&fbOutScratch);
+    //
+    classifierScratch->store( osScratch );
+    //   
+    fbOutScratch.close(); 
+  }
   
   
   // TEST both classifiers to produce equal results

+ 45 - 39
tests/TestGPHIKRegression.cpp

@@ -25,7 +25,7 @@ using namespace NICE;  // nice-core
 
 const bool verboseStartEnd = true;
 const bool verbose = false;
-
+const bool writeRegressionObjectsForVerification = false;
 
 CPPUNIT_TEST_SUITE_REGISTRATION( TestGPHIKRegression );
 
@@ -290,25 +290,28 @@ void TestGPHIKRegression::testRegressionOnlineLearnableAdd1Example()
   
   
   // TEST that both regressionMethods produce equal store-files
-   std::string s_destination_save_IL ( "myRegressionMethodIL.txt" );
-  
-  std::filebuf fbOut;
-  fbOut.open ( s_destination_save_IL.c_str(), ios::out );
-  std::ostream os (&fbOut);
-  //
-  regressionMethod->store( os );
-  //   
-  fbOut.close(); 
-  
-  std::string s_destination_save_scratch ( "myRegressionMethodScratch.txt" );
-  
-  std::filebuf fbOutScratch;
-  fbOutScratch.open ( s_destination_save_scratch.c_str(), ios::out );
-  std::ostream osScratch (&fbOutScratch);
-  //
-  regressionMethodScratch->store( osScratch );
-  //   
-  fbOutScratch.close(); 
+  if ( writeRegressionObjectsForVerification )
+  {
+    std::string s_destination_save_IL ( "myRegressionMethodIL.txt" );
+    
+    std::filebuf fbOut;
+    fbOut.open ( s_destination_save_IL.c_str(), ios::out );
+    std::ostream os (&fbOut);
+    //
+    regressionMethod->store( os );
+    //   
+    fbOut.close(); 
+    
+    std::string s_destination_save_scratch ( "myRegressionMethodScratch.txt" );
+    
+    std::filebuf fbOutScratch;
+    fbOutScratch.open ( s_destination_save_scratch.c_str(), ios::out );
+    std::ostream osScratch (&fbOutScratch);
+    //
+    regressionMethodScratch->store( osScratch );
+    //   
+    fbOutScratch.close(); 
+  }
   
   
   // TEST both regressionMethods to produce equal results
@@ -450,25 +453,28 @@ void TestGPHIKRegression::testRegressionOnlineLearnableAddMultipleExamples()
   
   
   // TEST that both regressionMethods produce equal store-files
-   std::string s_destination_save_IL ( "myRegressionMethodIL.txt" );
-  
-  std::filebuf fbOut;
-  fbOut.open ( s_destination_save_IL.c_str(), ios::out );
-  std::ostream os (&fbOut);
-  //
-  regressionMethod->store( os );
-  //   
-  fbOut.close(); 
-  
-  std::string s_destination_save_scratch ( "myRegressionMethodScratch.txt" );
-  
-  std::filebuf fbOutScratch;
-  fbOutScratch.open ( s_destination_save_scratch.c_str(), ios::out );
-  std::ostream osScratch (&fbOutScratch);
-  //
-  regressionMethodScratch->store( osScratch );
-  //   
-  fbOutScratch.close(); 
+  if ( writeRegressionObjectsForVerification )
+  {
+    std::string s_destination_save_IL ( "myRegressionMethodIL.txt" );
+    
+    std::filebuf fbOut;
+    fbOut.open ( s_destination_save_IL.c_str(), ios::out );
+    std::ostream os (&fbOut);
+    //
+    regressionMethod->store( os );
+    //   
+    fbOut.close(); 
+    
+    std::string s_destination_save_scratch ( "myRegressionMethodScratch.txt" );
+    
+    std::filebuf fbOutScratch;
+    fbOutScratch.open ( s_destination_save_scratch.c_str(), ios::out );
+    std::ostream osScratch (&fbOutScratch);
+    //
+    regressionMethodScratch->store( osScratch );
+    //   
+    fbOutScratch.close(); 
+  }
   
   
   // TEST both regressionMethods to produce equal results