and has ergonomics challenges. We instead suggest recommending a more popular framework, such as GTest, supplemented with CMake functions adding negative compilation testing capabilities.
## I ntroduction
rigorous testing suite
#include <gtest gtest.h="">
TEST(TestMyApi, Halving) {
EXPECT_FLOAT_EQ(21.0F, get_half_of(42.0F));
EXPECT_DOUBLE_EQ(21.0, get_half_of(42.0));
}gtest>
## Even leave a helpful comment comment
#include <gtest gtest.h="">
TEST(TestMyApi, Halving) {
EXPECT_FLOAT_EQ(21.0F, get_half_of(42.0F));
EXPECT_DOUBLE_EQ(21.0, get_half_of(42.0));
// This should NOT compile:
// get_half_of(23); get_half_of(23);
}gtest>
## Now throw it into the rest of the code base

template<
class T,
class = std::enable_if_t
## • Add a new main for the testing framework
#include <gtest gtest.h="">
// This class is setup and torn down once for the
// entire test suite
class TestEnvironment TestEnvironment);
return RUN_ALL_TESTS();
}gtest>
## Our First Test
## • Add a test file with a failing test
PRJ/TESTS/FirstTest.cpp
#include <gtest gtest.h="">
TEST(FirstTest, DoesThisCompile) {
$> out/unit-tests/development/test.exegtest>
## Our First Test
## • Add a test file with a failing test
1 test from FirstTest
#include <gtest gtest.h="">
TEST(FirstTest, DoesThisCompile) {
Visual Studio Code 251
42.4 Вправа правил побудови 252
43 Tectuyan 254
43.1 Бібліотека rust_gtest_interop 255
43.2 Правила GN для тестів Rust 255
43.3 Макрос chromium::import! 256
43.4 Тестова Нативні тести Rust (тобо #[test]). Не рекомендується використовувати поза //third_party/rust.
• Тести gtest, написані на C++, які виконують Rust за допомогою викликів FFI. Достатньо, коли код Rust є лише тонким тонким прошарком FFI, а наявні модульні тести забезпечують достатнє покриття для функції.
• Тести gtest, написані на Rust, що використовують крейт який тестується через його публічний API (з використанням
VirtualBuildEnv reference
• Cross-build using a tool requires
• How to require test frameworks like gtest: using test_requires
• Using Conan to build for iOS
#### 4.1.6 Introduction to versioning
So far options.with_fmt:
self.requires("fmt/8.1.1")
self.test_requires("gtest/1.11.0")
def generate(self):
tc = CMakeToolchain(self)
if self.options.with_fmt: "test_hello"))
• We added the gtest/1.11.0 requirement to the recipe as a test_requires(). It’s a type of requirement intended for testing libraries like Catch2 or gtest.
• We use the tools.build:skip_test
VirtualBuildEnv reference
• Cross-build using a tool requires
• How to require test frameworks like gtest: using test_requires
• Using Conan to build for iOS
#### 4.1.6 Introduction to versioning
So far options.with_fmt:
self.requires("fmt/8.1.1")
self.test_requires("gtest/1.11.0")
def generate(self):
tc = CMakeToolchain(self)
if self.options.with_fmt: "test_hello"))
• We added the gtest/1.11.0 requirement to the recipe as a test_requires(). It’s a type of requirement intended for testing libraries like Catch2 or gtest.
• We use the tools.build:skip_test
VirtualBuildEnv reference
• Cross-build using a tool requires
• How to require test frameworks like gtest: using test_requires
• Using Conan to build for iOS
#### 4.1.6 Introduction to versioning
So far options.with_fmt:
self.requires("fmt/8.1.1")
self.test_requires("gtest/1.11.0")
def generate(self):
tc = CMakeToolchain(self)
if self.options.with_fmt: "test_hello"))
• We added the gtest/1.11.0 requirement to the recipe as a test_requires(). It’s a type of requirement intended for testing libraries like Catch2 or gtest.
• We use the tools.build:skip_test
VirtualBuildEnv reference
• Cross-build using a tool requires
• How to require test frameworks like gtest: using test_requires
• Using Conan to build for iOS
#### 4.1.6 Introduction to versioning
So far options.with_fmt:
self.requires("fmt/8.1.1")
self.test_requires("gtest/1.11.0")
def generate(self):
tc = CMakeToolchain(self)
if self.options.with_fmt: "test_hello"))
• We added the gtest/1.11.0 requirement to the recipe as a test_requires(). It’s a type of requirement intended for testing libraries like Catch2 or gtest.
• We use the tools.build:skip_test