RE: [boost] Little bug in unit_test_result.cpp

2003-06-09 Thread Rozental, Gennadiy
Both applied. Thanks. Though CLA support is about to be reworked anyway.

Gennadiy.
___
Unsubscribe  other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


[boost] Little bug in unit_test_result.cpp

2003-04-24 Thread Guillaume Melquiond
Hi,

I'm not really interested in this file, but since gcc complained about an
unitialized variable, I did fix it. And it is the first patch. So please
apply it (and change the name of the enum item before, if necessary).

However, by looking at the code, I found a good example of data
duplication; and the purpose of the second patch is to clean it a bit.

Regards,

Guillaume
Index: boost/test/detail/unit_test_parameters.hpp
===
RCS file: /cvsroot/boost/boost/boost/test/detail/unit_test_parameters.hpp,v
retrieving revision 1.7
diff -u -r1.7 unit_test_parameters.hpp
--- boost/test/detail/unit_test_parameters.hpp  13 Feb 2003 08:07:20 -  1.7
+++ boost/test/detail/unit_test_parameters.hpp  24 Apr 2003 14:44:14 -
@@ -37,7 +37,7 @@
 c_string_literal const LOG_FORMAT= BOOST_TEST_LOG_FORMAT; // 
--log_format
 c_string_literal const OUTPUT_FORMAT = BOOST_TEST_OUTPUT_FORMAT;  // 
--output_format
 
-enum report_level { CONFIRMATION_REPORT, SHORT_REPORT, 
DETAILED_REPORT, NO_REPORT };
+enum report_level { CONFIRMATION_REPORT, SHORT_REPORT, 
DETAILED_REPORT, NO_REPORT, BAD_REPORT };
 c_string_literal const report_level_names[] = { confirm  , short , 
detailed , no  };
 
 enum output_format { HRF /* human readable format */, XML /* XML */ };
Index: libs/test/src/unit_test_result.cpp
===
RCS file: /cvsroot/boost/boost/libs/test/src/unit_test_result.cpp,v
retrieving revision 1.15
diff -u -r1.15 unit_test_result.cpp
--- libs/test/src/unit_test_result.cpp  15 Feb 2003 21:55:32 -  1.15
+++ libs/test/src/unit_test_result.cpp  24 Apr 2003 14:44:14 -
@@ -490,7 +490,7 @@
 
 static int const map_size = sizeof(name_value_map)/sizeof(my_pair);
 
-report_level rl;
+report_level rl = BAD_REPORT;
 if( reportlevel.empty() )
 rl = CONFIRMATION_REPORT;
 else {
--- libs/test/src/unit_test_result.cpp.old  2003-04-24 16:45:52.0 +0200
+++ libs/test/src/unit_test_result.cpp  2003-04-24 16:50:33.0 +0200
@@ -476,27 +476,15 @@
 void
 unit_test_result::report( std::string const reportlevel, std::ostream where_to_ )
 {
-struct my_pair {
-c_string_literallevel_name;
-report_levellevel_value;
-};
-
-static const my_pair name_value_map[] = {
-{ confirm , CONFIRMATION_REPORT },
-{ short   , SHORT_REPORT },
-{ detailed, DETAILED_REPORT },
-{ no  , NO_REPORT },
-};
-
-static int const map_size = sizeof(name_value_map)/sizeof(my_pair);
+static int const map_size = sizeof(report_level_names)/sizeof(c_string_literal);
 
 report_level rl = BAD_REPORT;
 if( reportlevel.empty() )
 rl = CONFIRMATION_REPORT;
 else {
-for( int i =0; i  map_size; i++ ) {
-if( reportlevel == name_value_map[i].level_name ) {
-rl = name_value_map[i].level_value;
+for( int i = 0; i  map_size; i++ ) {
+if( reportlevel == report_level_names[i] ) {
+rl = (report_level)i;
 break;
 }
 }
___
Unsubscribe  other changes: http://lists.boost.org/mailman/listinfo.cgi/boost