Tutorial 12 - Optional tests

// tutorial12.ot
group "tutorial_12";

test("Run test if big endian") require BIG_ENDIAN;
{
}

test("Run test if little endian") require undefined BIG_ENDIAN;
{
}

We can check for defines to decide if we should run a test or not. Use require instead of #ifdef:s. When using require BIG_ENDIAN we tell Selftest that this test should only run if BIG_ENDIAN is defined. If we write require undefined BIG_ENDIAN, the test will only run if BIG_ENDIAN is undefined.

=========================================================================
Opera Testsuite
=========================================================================

=========================================================================
E:/src/operaclean/opera-windows7/modules/selftest/documentation/tutorial/tutorial12.ot(2):  tutorial_12 
=========================================================================
  Run test if big endian ........................................ Skipped (dep: defined: BIG_ENDIAN)
  Run test if little endian ..................................... Passed
=========================================================================
1 test run, 0 tests failed, 1 test skipped, 1 test OK
=========================================================================