// tutorial20.ot
group "tutorial_20";
table test_file(char *, float, int) read "tutorial20_table.txt";
test("Traversing a space separated file")
{
iterate( str1, num1, num2 ) from test_file
{
verify(op_strncmp(str1, "H", 1) == 0);
verify(num1 > 10);
verify(num2 > 20);
}
}
test("Failing traversing a space separated file")
{
iterate( str1, num1, num2 ) from test_file
{
verify(op_strncmp(str1, "H", 1) == 0);
verify(num1 < 20);
verify(num2 > 20);
}
}
A very useful thing is that you can read a table from a space separated file with data. The data will be in columns and inserted in a table. tutorial20_table.txt is the file where we find the table data. Types of data is declared as char*, float and int. In iterate, there is no difference between a normal table, and a table read from a file.
========================================================================= Opera Testsuite ========================================================================= ========================================================================= E:/src/operaclean/opera-windows7/modules/selftest/documentation/tutorial/tutorial20.ot(2): tutorial_20 ========================================================================= Traversing a space separated file ............................. Passed Failing traversing a space separated file ..................... FAILED E:/src/operaclean/opera-windows7/modules/selftest/documentation/tutorial/tutorial20.ot(21): 'ST_table_0[iterator].v1' should be smaller than 20. The value is 20 ========================================================================= 2 tests run, 1 test failed, 0 tests skipped, 1 test OK Place a breakpoint in testsuite_break_here() to debug the failed test =========================================================================