Expand description
§Module :: test_tools
Tools for writing and running tests.
§Basic use-case
use test_tools::*;
#[ cfg( feature = "enabled" ) ]
#[ cfg( not( feature = "no_std" ) ) ]
tests_impls!
{
fn pass1()
{
assert_eq!( true, true );
}
//
fn pass2()
{
assert_eq!( 1, 1 );
}
}
//
#[ cfg( feature = "enabled" ) ]
#[ cfg( not( feature = "no_std" ) ) ]
tests_index!
{
pass1,
pass2,
}§To add to your project
cargo add test_tools --dev§Try out from the repository
git clone https://github.com/Wandalen/wTools
cd wTools
cd examples/test_trivial
cargo run§Sample
println!("-- doc test: printing Cargo feature environment variables --");
for (key, val) in std::env::vars() {
if key.starts_with("CARGO_FEATURE_") {
println!("{}={}", key, val);
}
}Re-exports§
pub use super::super::asset;pub use super::super::compiletime;pub use super::super::helper;pub use super::super::smoke_test;pub use super::super::version;pub use super::super::process as process_tools;pub use ::error_tools;pub use ::collection_tools;pub use ::impls_index;pub use ::mem_tools;pub use ::typing_tools;pub use ::diagnostics_tools;
Modules§
- binary_
heap std::collections::BinaryHeapmacros- btree_
map std::collections::BTreeMapmacros- btree_
set std::collections::BTreeSetmacros- collection
- Module containing all collection macros
- dependency
- Namespace with dependencies.
- error
- Alias for
std::error::BasicError. - exposed
- Exposed namespace of the module.
- hash_
map std::collections::HashMapmacros- hash_
set std::collections::HashSetmacros- implsindex
- Collection of general purpose meta tools.
- linked_
list std::collections::LinkedListmacros- mem
- Collection of general purpose meta tools.
- orphan
- Shared with parent namespace of the module
- own
- Own namespace of the module.
- prelude
- Prelude to use essentials:
use my_module::prelude::*. - test
- Tools for testing.
- thiserror
- github crates-io docs-rs
- vec_
deque std::collections::VecDequemacros- vector
- Vec macros
Macros§
- _impls_
callback - Internal impls1 macro. Don’t use.
- a_
dbg_ false - Asserts that a boolean expression is false at runtime.
- a_
dbg_ id - Asserts that two expressions are identical.
- a_
dbg_ not_ id - Asserts that two expressions are not identical with each other.
- a_
dbg_ true - Asserts that a boolean expression is true at runtime.
- a_false
- Asserts that a boolean expression is false at runtime.
- a_id
- Asserts that two expressions are identical to each other (using
PartialEq). Prints nice diff. - a_
not_ id - Asserts that two expressions are not identical to each other (using
PartialEq). Prints nice diff. - a_true
- Asserts that a boolean expression is true at runtime.
- bmap
- Creates a
BTreeMapfrom a list of key-value pairs. - bset
- Creates a
BTreeSetfrom a list of elements. - cta_
mem_ same_ size - Compile-time assertion that two values have the same size.
- cta_
ptr_ same_ size - Compile-time assertion that memory behind two references have the same size.
- cta_
true - Macro to compare meta condition is true at compile-time.
- cta_
type_ same_ align - Compile-time assertion of having the same align.
- cta_
type_ same_ size - Compile-time assertion that two types have the same size.
- debug_
assert_ id - Macro asserts that two expressions are identical to each other. Unlike
std::assert_eqit is removed from a release build. - debug_
assert_ identical - Macro asserts that two expressions are identical to each other. Unlike
std::assert_eqit is removed from a release build. Alias ofdebug_assert_id. - debug_
assert_ ni - Macro asserts that two expressions are not identical to each other. Unlike
std::assert_eqit is removed from a release build. - debug_
assert_ not_ identical - Macro asserts that two expressions are not identical to each other. Unlike
std::assert_eqit is removed from a release build. - deque
- Creates a
VecDequefrom a list of elements. - dlist
- Creates a
Vecfrom a list of elements. - doc_
file_ test - Test a file with documentation.
- fn_name
- Get name of a function.
- fn_
rename - Macro to rename function.
- fns
- Split functions.
- fns2
- Split functions.
- hmap
- Creates a
HashMapfrom a list of key-value pairs. - hset
- Creates a
HashSetfrom a list of elements. - implements
- Macro
implementsto answer the question: does it implement a trait? - impls
- Macros to put each function under a named macro to index every function in a class.
- impls1
- Define implementation putting each function under a macro.
- impls2
- Define implementation putting each function under a macro.
- impls3
- Macros to put each function under a named macro to index every function in a class.
- impls_
optional - Define implementation putting each function under a macro.
Use index! to generate code for each element.
Unlike elements of
impls_optional!, elements of [impls] are mandatory to be used inindex!. - index
- Index of items.
- inspect_
to_ str_ type_ of - Macro to inspect type of a variable and its size exporting it as a string.
- inspect_
type_ of - Macro to inspect type of a variable and its size printing into stdout and exporting it as a string.
- instance_
of - Macro
instance_ofto answer the question: does it implement a trait? Alias of the macroimplements. - into_
bmap - Creates a
BTreeMapfrom a list of key-value pairs. - into_
bset - Creates a
BTreeSetfrom a list of elements. - into_
dlist - Creates a
Vecfrom a list of elements. - into_
hmap - Creates a
HashMapfrom a list of key-value pairs. - into_
hset - Creates a
HashSetfrom a list of elements. - into_
llist - Creates a
LinkedListfrom a llist of elements. - into_
vec - Creates a
Vecfrom a list of elements. - into_
vecd - Creates a
VecDequefrom a list of elements. - is_
slice - Macro to answer the question: is it a slice?
- llist
- Creates a
LinkedListfrom a llist of elements. - num
- Required to convert integets to floats.
- tests_
impls - Define implementation putting each function under a macro and adding attribute
#[ test ]. Use index! to generate code for each element. Unlike elements of [test_impls_optional!], elements of [test_impls] are mandatory to be used inindex!. - tests_
impls_ optional - Define implementation putting each function under a macro and adding attribute
#[ test ]. Use index! to generate code for each element. Unlike elements of [test_impls!], elements of [test_impls_optional] are optional to be used inindex!. - tests_
index - Index of items.
Structs§
- BTree
Map - An ordered map based on a B-Tree.
- BTree
Set - An ordered set based on a B-Tree.
- Binary
Heap - A priority queue implemented with a binary heap.
- Bmap
- An ordered map based on a B-Tree.
- Bset
- An ordered set based on a B-Tree.
- Deque
- A double-ended queue implemented with a growable ring buffer.
- Dlist
- A contiguous growable array type, written as
Vec<T>, short for ‘vector’. - HashMap
- A hash map implemented with quadratic probing and SIMD lookup.
- HashSet
- A hash set implemented as a
HashMapwhere the value is(). - Hmap
- A hash map implemented with quadratic probing and SIMD lookup.
- Hset
- A hash set implemented as a
HashMapwhere the value is(). - Linked
List - A doubly-linked list with owned nodes.
- Llist
- A doubly-linked list with owned nodes.
- Map
- A hash map implemented with quadratic probing and SIMD lookup.
- Set
- A hash set implemented as a
HashMapwhere the value is(). - Smoke
Module Test - Context for smoke testing of a module.
- Vec
- A contiguous growable array type, written as
Vec<T>, short for ‘vector’. - VecDeque
- A double-ended queue implemented with a growable ring buffer.
Traits§
- ErrWith
- This trait allows adding extra context or information to an error, creating a tuple of the additional context and the original error. This is particularly useful for error handling when you want to include more details in the error without losing the original error value.
Functions§
- smoke_
test_ for_ local_ run - Run smoke test for local version of the module.
- smoke_
test_ for_ published_ run - Run smoke test for published version of the module.
- smoke_
test_ run - Run smoke test for the module. Run smoke test for the module.
- smoke_
tests_ run - Run smoke test for both published and local version of the module.
Type Aliases§
- Result
With Report - A type alias for a
Resultthat contains an error which is a tuple of a report and an original error.