Chapter 4. Case Study - Glib Arrays

1. Prerequisites
2. Analysis of documentation
3. Markup of requirements (assertions)
3.1. g_array_new()
3.2. Using ReqTools in a web browser
3.3. g_array_sized_new()
3.4. g_array_append_vals(), g_array_prepend_vals(), etc.
3.5. g_array_sort() and g_array_sort_with_data()
3.6. g_array_set_size()
3.7. g_array_free()
3.8. Implicit requirements in the description of GArray data fields
4. Creating catalogue of requirements
5. Generating template of .t2c file
6. Populating the template: development of parameterized tests
6.1. T2C-style comments
6.2. Header
6.3. <GLOBAL> section
6.4. <STARTUP> and <CLEANUP> sections
6.5. Planning the test cases
6.6. Parameters of the tests
6.6.1. Choosing the parameters
6.6.2. Choosing the values of the parameters
6.7. Typical structure of a test scenario
6.7.1. Declarations and definitions used by the tests
6.7.2. Setup of the test situation
6.7.3. Call of the function under test
6.7.4. Analysis of the results
6.7.5. Cleanup
6.8. Test scenario #1 - check appending to an empty array
6.9. Test scenario #2 - check appending to a non-empty array
7. Using T2C to generate the sources of the tests and other files
8. Building, executing and debugging the tests, analysing the results
8.1. Building and installing the tests
8.2. Creating a test package
8.3. Executing and debugging the tests

In this case study, we consider test development for several functions from GLib Library dealing with arrays that grow automatically as elements are added.

For the sake of simplicity, the test execution framework provided with T2C will be used here along with the facilities to generate rather minimal source files (for debugging).

Note

If you would like to use TETWare Lite or GLib Testing Framework in this example instead of the simple testing framework provided with T2C, please use c_tet or c_gtest_nested targets, respectively, in place of c_standalone when T2C tools are called.

Sample top-level scripts and other files for the test package generated using these T2C targets can be found in the package with T2C: in other/c_tet/ and other/c_gtest_nested/ directories. These files are not installed with T2C but are provided with it in the package.

For c_tet target, these files should be placed to the same directory where the top-level directory of the suite is located, i.e. to tut-examples/example01/ in this case.

For c_gtest_nested target, the only top-level file that is not generated by T2C (other/c_gtest_nested/gen_files.sh) should be placed to tut-examples/example01/example01-t2c directory.

The sources of API libraries for these T2C targets can be found in the respective subdirectories of `t2c --print-data-dir`/api directory. gen_files.sh script will copy them to an appropriate subdirectory in the test suite.

There is no external T2C API library for c_minimal target. The .c file and the Makefile generated from the .t2c file using this target should be self-contained (all necessary API definitions are placed within the .c file).

The documentation, sources and other files for the example considered in this case study can be found in tut-examples/example01 directory. Unless otherwise stated, the paths mentioned below are relative to this directory.