Home > The Unit Test Framework > Compilation >

The UTF compilation variants and procedures

Table of Contents

Standalone library compilation
Auto-linking support
Direct include

The UTF is comparatively complicated component and is implemented in close to hundred header and source files, so for long term usage the preferable solution is to build the UTF as a reusable standalone library. Depending on your platform this may save you a significant time during test module compilation and doesn't really require that much effort. Boost Getting started tells you how to get pre-built libraries for some platforms. If available, this is the easiest option and you can ignore standalone library compilation instructions below.
UTF 是相對比較複雜的組件,實現在將近上百個頭文件和源文件中, 所以對於長期使用的話,最好的解決方案是將 UTF 編譯成獨立的可重用的庫。 依賴於你的平台,在編譯測試模塊時這會節省你相當的時間並且實際上不需要那麼費力。 Boost Getting started 會告訴你如何得到某些平台上的預編譯的庫。 如果能夠找到,這將是最簡單的方法,你可以忽略下面的獨立庫編譯的指令。

Following files constitute the UTF implementation:
下面的文件組成了 UTF 的實現:

Compilation procedures

In comparison with many other boost libraries, which are completely implemented in header files, compilation and linking with the UTF may require additional steps. The UTF presents you with options to either built and link with a standalone library or include the implementation directly into a test module. If you opt to use the library the UTF headers implement the auto-linking support. The compilation of the UTF library and a test module can be configured using the following compilation flags.
同 boost 中其它很多完全實現在頭文件中的庫相比,UTF 的編譯和鏈接需要額外的步驟。 UTF 提供你如下選項: 編譯並鏈接為獨立的庫 (built and link with a standalone library)在測試模塊中直接包含實現 (include the implementation directly)。 如果你使用庫,UTF 頭文件實現了支持自動鏈接 (auto-linking support)。 編譯 UTF 庫和測試模塊可以使用如下的編譯標籤配置。

Table 3. The UTF compilation flags

Flag Usage
BOOST_TEST_DYN_LINK Define this flag to build/use dynamic library. 定義這個標籤使用動態庫
BOOST_TEST_NO_LIB Define this flag to prevent auto-linking. 定義這個標籤阻止自動鏈接
BOOST_TEST_NO_MAIN Define this flag to prevent function main() implementation generation.
定義這個標籤阻止實現生成 main() 函數
BOOST_TEST_MAIN Define this flag to generate an empty test module initialization function and in case of dynamic library variant default function main() implementation as well.
定義這個標籤生成空的測試模塊初始化函數,並在動態庫版本 (dynamic library variant) 情況下同樣實現 main() 函數
BOOST_TEST_MODULE Define this flag to generate the test module initialization function, which uses the defined value to name the master test suite. In case of dynamic library variant default function main() implementation is generated as well
定義這個標籤生成空的測試模塊初始化函數,使用定義的值作為主測試套件的名稱。 在動態庫版本 (dynamic library variant) 情況下同樣生成默認的 main() 函數實現
BOOST_TEST_ALTERNATIVE_INIT_API Define this flag to generate the switch to the alternative test module initialization API.
定義這個標籤生成備選的測試模塊初始化 API

Further in documentation you are going to see in details when and how these flags should be used.