Arguments to tests

A test without arguments, are declared like this void test(void). A test can also be declared with arguments as shown in sample202.1below
  void test_deg2rad(double degrees, double radians, double *error) {
    double result = deg2rad(degrees);
    *error = result-radians;
    VALIDATE_FP(result , radians);  
    }

  void testmain(void) {
    double rounding_error;
    EXECUTE(test_deg2rad, 360, 2*PI, &rounding_error);
    COMMENT("Rounding error is %f\n", rounding_error );
    }
If the test are executed repeatedly, e.g. they have been setup with a PARAMETER macro, each call will use the same function arguments. By passing PARAMETER_VALUE as a one of these, this argument can be made to vary with each test run, e.g. in sample212.1
  void test_deg2rad(double degrees, double radians) {
    double result = deg2rad(degrees);
    VALIDATE_FP(result , radians);  
    }
 
  void testmain(void) {
    PARAMETER_RANGE_FP(2*PI, 10*PI, 2*PI);
    EXECUTE(test_deg2rad, 360, PARAMETER_VALUE_FP);
    }

TestApe will pass commandline arguments after the --args tag to testmain, so if the test executable are invoked like this

./sample22 --args 4
argc will be 1 and argv[0] will be "4" in the testmain function declared in sample222.1below
  void test_deg2rad(double degrees, double radians) {
    double result = deg2rad(degrees);
    *error = result-radians;
    VALIDATE_FP(result , radians);
    }

  int testmain(int argc, char *argv[]) {
    double rounding_error;
    int number = atoi(argv[0]);
    EXECUTE(test_deg2rad, 360, number*PI, &rounding_error);
    COMMENT("Rounding error for number equals %d is %f\n", number, rounding_error);
  }



testape

News

The latest headlines from Testape.com

TestApe Release 880 available, Dec 3rd 2011

New is this release are support for floating point validations and function mocking. Also, MinGW has been added to the list of supported platforms.

more

Forum change, Mar 27th 2011

TestApe forum is now hosted on Proboards. Support questions can be posted here or send directly on email. Due to ...

more

TestApe beta release available, Sep 27th 2011

TestApe can now be used with MinGW GCC on windows. Also supported in this beta are floating point types in validations or when mocking functions

more

IPad update for WebTTY, May 15th 2011

A small fix for webtty scripts, to allow the usage from Apple IPads. Tab on textarea to bring up IPad keyboard - you may have to scroll webpage beneath keyboard, in order to actually see what you're typing.

TestApe Release 791 available, Apr 2nd 2010

This release contains a new flexible mocking system with default mocks automatically generated for unresolved functions. Installation packages are available for GCC/Linux, GCC/CygWin as well Visual Studio 2009/Windows XP or Vista.

more

TestApe beta version available, Jan 26th 2010

New beta version is now available for download. This is the last beta before official release. The release supports an extensive mocking system.

more

Forum change, Mar 10th 2009

There is a change for the forum hosted on this site. The previous phpBB forum is closed for now. All forum threads will be migrated to a new simple blog. ...

more