Skip to main content

test_that/
lib.rs

1// Copyright 2022 Google LLC
2// Copyright 2026 Bradford Hovinen <bradford@hovinen.me>
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//      http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16#![no_std]
17#![doc = include_str!("../crate_docs.md")]
18#![cfg_attr(docsrs, feature(doc_cfg), doc(auto_cfg))]
19
20#[macro_use]
21extern crate alloc;
22#[cfg(feature = "std")]
23extern crate std;
24
25/// Re-export of `alloc` for use by this crate's macros.
26/// Do not use directly; it is not part of the public API.
27#[doc(hidden)]
28pub extern crate alloc as __alloc;
29
30#[cfg(feature = "test-that-macro")]
31extern crate test_that_macro;
32
33#[cfg(test)]
34extern crate quickcheck;
35
36#[macro_use]
37pub mod assertions;
38pub mod description;
39pub mod internal;
40pub mod matcher;
41pub mod matcher_support;
42pub mod matchers;
43pub mod result;
44
45#[cfg(feature = "googletest-compat")]
46pub mod compat;
47
48/// Re-exports of the symbols in this crate which are most likely to be used.
49///
50/// This includes:
51///  * All assertion macros,
52///  * Traits and type definitions normally used by tests, and
53///  * All built-in matchers.
54///
55/// Typically, one imports everything in the prelude in one's test module:
56///
57/// ```
58/// mod tests {
59///     use test_that::prelude::*;
60/// }
61/// ```
62pub mod prelude {
63    pub use super::OrFailExt;
64    pub use super::TestResult;
65    pub use super::TestResultExt;
66    #[cfg(feature = "googletest-compat")]
67    #[allow(deprecated)]
68    pub use super::compat::IntoTestResult;
69    pub use super::matcher::Matcher;
70    pub use super::matcher::MatcherExt;
71    pub use super::matchers::containers::*;
72    pub use super::matchers::*;
73    #[cfg(feature = "std")]
74    pub use super::verify_current_test_outcome;
75    pub use super::{assert_that, fail, verify_pred, verify_that};
76    #[cfg(feature = "non-fatal-assertions")]
77    pub use super::{expect_pred, expect_that};
78    #[cfg(feature = "googletest-compat")]
79    #[allow(deprecated)]
80    pub use crate::result::Result;
81}
82
83pub use result::{OrFailExt, TestResult, TestResultExt, verify_current_test_outcome};
84
85#[cfg(feature = "non-fatal-assertions")]
86pub use test_that_macro::test;