32.5. Определение покрытия кода тестами
Исходный код PostgreSQL может быть скомпилирован с инструментарием определения покрытия, чтобы узнать, какие части кода покрываются регрессионными тестами или другими комплектами тестов, выполняемыми в дереве кода. В настоящее время эта возможность поддерживается в случае использования компилятора GCC и требует наличия gcov
и lcov
программ.
Типичный рабочий процесс выглядит так:
./configure --enable-coverage ... OTHER OPTIONS ... make make check # или другой комплект тестов make coverage-html
Затем откройте в своём HTML-браузере страницу coverage/index.html
. Команды make
работают и в подкаталогах.
Чтобы обнулить подсчёт выполнений между тестами, запустите:
make coverage-clean
9.10. Enum Support Functions
For enum types (described in Section 8.7), there are several functions that allow cleaner programming without hard-coding particular values of an enum type. These are listed in Table 9.32. The examples assume an enum type created as:
CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple');
Table 9.32. Enum Support Functions
Notice that except for the two-argument form of enum_range
, these functions disregard the specific value passed to them; they care only about its declared data type. Either null or a specific value of the type can be passed, with the same result. It is more common to apply these functions to a table column or function argument than to a hardwired type name as suggested by the examples.