Gimp/libgimp/tests
Jehan 2a00a9e60a Issue #434: remove broken plural support for GimpUnit.
Rather than trying to implement full i18n plural support, we just remove
this failed attempt from the past. The fact is that to get proper
support, we'd basically need to reimplement a Gettext-like plural
definition syntax within our API, then ask people to write down this
plural definition for their language, then to write every plural form…
all this for custom units which only them will ever see!

Moreover code investigation shows that the singular form was simply
never used, and the plural form was always used (whatever the actual
unit value displayed).

As for the "identifier", this was a text which was never shown anywhere
(except in the unit editor) and for all built-in units, as well as
default unitrc units, it was equivalent to the English plural value.

So we now just have a unique name which is the "long label" to be used
everywhere in the GUI, and abbreviation will be basically the "short
label". That's it. No useless (or worse, not actually usable because it
was not generic internationalization) values anymore!
2024-08-06 11:39:57 +02:00
..
pygimp
c-test-header.c
libgimp-run-c-test.sh libgimp: allow to run gimp_procedure_run_config() with no config object. 2024-02-29 16:33:32 +01:00
libgimp-run-python-test.sh
meson.build libgimp: new unit tests around GimpImage and item API. 2024-08-02 14:12:10 +02:00
README.md
test-color-parser.c libgimp, libgimpcolor: make real unit test of old (compiled but unused) … 2024-04-20 12:39:52 +02:00
test-color-parser.py libgimp, libgimpcolor: make real unit test of old (compiled but unused) … 2024-04-20 12:39:52 +02:00
test-image.c libgimp: new unit tests around GimpImage and item API. 2024-08-02 14:12:10 +02:00
test-image.py libgimp: new unit tests around GimpImage and item API. 2024-08-02 14:12:10 +02:00
test-palette.c libgimp: also update unit testing for GimpColorArray. 2024-04-18 16:00:42 +02:00
test-palette.py libgimp: also update unit testing for GimpColorArray. 2024-04-18 16:00:42 +02:00
test-selection-float.c app, libgimp, pdb, plug-ins: new GimpGroupLayer class in libgimp. 2024-07-07 10:27:04 +02:00
test-selection-float.py plug-ins, tests: Update Python plug-ins after b1736a67 2024-07-07 12:37:33 +00:00
test-unit.c Issue #434: remove broken plural support for GimpUnit. 2024-08-06 11:39:57 +02:00
test-unit.py libgimp: new unit tests for GimpUnit. 2024-08-02 12:14:54 +02:00

Unit testing for libgimp

We should test every function in our released libraries and ensure they return the correct data. This test infrastructure does this for the C library and the Python 3 binding.

Every new test unit should be added both in C and Python 3.

Procedure to add the C unit

C functions are tested in a real plug-in which is run by the unit test infrastructure. Most of the boiler-plate code is contained in c-test-header.c therefore you don't have to care about it.

All you must do is create a gimp_c_test_run() function with the following template:

static GimpValueArray *
gimp_c_test_run (GimpProcedure        *procedure,
                 GimpRunMode           run_mode,
                 GimpImage            *image,
                 gint                  n_drawables,
                 GimpDrawable        **drawables,
                 GimpProcedureConfig  *config,
                 gpointer              run_data)
{
  /* Each test must be surrounded by GIMP_TEST_START() and GIMP_TEST_END()
   * macros this way:
   */
  GIMP_TEST_START("Test name for easy debugging")
  /* Run some code and finish by an assert-like test. */
  GIMP_TEST_END(testme > 0)

  /* Do more tests as needed. */

  /* Mandatorily end the function by this macro: */
  GIMP_TEST_RETURN
}

This code must be in a file named only with alphanumeric letters and hyphens, and prepended with test-, such as: test-palette.c.

The part between test- and .c must be added to the tests list in libgimp/tests/meson.build.

Procedure to add the Python 3 unit

Unlike C, the Python 3 API is not run as a standalone plug-in, but as Python code directly interpreted through the python-fu-eval batch plug-in.

Simply add your code in a file named the same as the C file, but with .py extension instead of .c.

The file must mandatorily start with a shebang: #!/usr/bin/env python3

For testing, use gimp_assert() as follows:

#!/usr/bin/env python3

# Add your test code here.
# Then test that it succeeded with the assert-like test:
gimp_assert('Test name for easy debugging', testme > 0)

# Repeat with more tests as needed.