> I get a test file with a lot of code that looks like this:
>
>   printf(
>     "%s %d: Some useful description and maybe a number %d\n",
>     (expected_value == test_value) ? "ok" : "not ok", ++tests,
>     some_useful_debugging_info
>   );
>
> I find it manageable, but I'm wondering about the next guy.

I've coded up a library of c++ functions for my infrastructure:

void increment_error_count(){
   err_cnt++;
   if(err_cnt>10){
      exit 1;
   }
}

void error(string desc){
   increment_error_count();
   cout << "ERROR: " << desc << endl;
}

void pass(string desc){
   increment_pass_count();
   cout << "pass : " << desc << endl;
}

void expected_actual(
   int expected;
   int actual;
   string desc
){
  cout << "expected "<<expected<<", actual="<<actual<<endl;
  if(expected==actual){
     pass(desc);
  }else{
     error(desc);
  }
}

Then in the test, your code:

>   printf(
>     "%s %d: Some useful description and maybe a number %d\n",
>     (expected_value == test_value) ? "ok" : "not ok", ++tests,
>     some_useful_debugging_info
>   );


would look something like this:

 expected_actual(expected_value ,test_value, "some useful description");

We have a number of actual_expected functions to handle diferent types and
range checking and what not. They all print out the actual and expected
values, so you don't have to do that formatting in the test call.
cause usually if there is a failure, the very next thing we need to  know
is the actual value we got versus the expected value we wanted.

The error logging will stop after some number of errors occurs, so you're
not wasting sim time.

Each test ends by doing an end-of-test-report which prints out pass count
and error count and prints out and overall-result string. the perl script
scrapes this value and puts it in a report.

We have hundreds and hundreds of tests. so the goal is to keep the
tests as absolutely short as possible.





_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to