Home > The Unit Test Framework > User's guide > Usage variants > Static library

The static library variant of the UTF

The UTF can be built into a static library. If you opt to link a test module with the standalone static library, this usage is called the static library variant of the UTF.
UTF 可以被編譯為靜態庫。 如果你選擇將測試模塊鏈接到獨立靜態庫, 這種用法被稱為 UTF 的靜態庫用法。

The test runner supplied with this variant requires you to implement the test module initialization function that matches one of the two specifications depending on the compilation flag BOOST_TEST_ALTERNATIVE_INIT_API. If flag isn't defined you are required to match the original specification. If you define the flag BOOST_TEST_ALTERNATIVE_INIT_API during a test module compilation you are required to use the alternative initialization function specification. The UTF provides an ability to automatically generate an empty test module initialization function with correct specification if no custom initialization is required by a test module.
這種用法提供的測試運行器需要你根據編譯標籤 BOOST_TEST_ALTERNATIVE_INIT_API 實現測試模塊匹配兩種定義之一的初始化函數。 如果在測試模塊編譯過程中定義了標籤 BOOST_TEST_ALTERNATIVE_INIT_API,你需要使用備選的初始化函數定義。 如果測試模塊不需要自定義的初始化,UTF 提供了自動生成正確的空測試模塊初始化函數的能力。

[Important] Important

If you opted to use an alternative initialization API, for a test module to be able to link with prebuilt library, the flag BOOST_TEST_ALTERNATIVE_INIT_API has to be defined both during library and a test module compilation.
如果你選擇使用備用初始化 API,如果想要測試模塊能夠鏈接到預編譯的庫, 需要同時在生成庫和編譯測試模塊的過程中定義標籤 BOOST_TEST_ALTERNATIVE_INIT_API