Tutorial 3 - Basic OpString test

// tutorial3.ot
group "tutorial_3";

include "modules/util/opstring.h";

test("Append a string")
{
  OpString str;
  str.Append(UNI_L("Hello"));
  verify(uni_strcmp(str, UNI_L("Hello")) == 0);
}

A new keyword is introduced here, include. You should use the include keyword instead of the normal #include thing in the preprocessor. The Selftest engine will move all includes to the top, and then avoid all duplicates in the includes, so you will get a file that compiles quickly.

As with the earlier tests, we use the group first, then a test with the name "Append a string". We append the string "Hello" to the empty string str, and then we control that the content in str is "Hello". See the expected output below.

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

=========================================================================
E:/src/operaclean/opera-windows7/modules/selftest/documentation/tutorial/tutorial3.ot(2):  tutorial_3 
=========================================================================
  Append a string ............................................... Passed
=========================================================================
1 test run, 0 tests failed, 0 tests skipped, 1 test OK
=========================================================================