assertables
Assertables: a Rust crate of assert macros for testing
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (6.2%) to scientific vocabulary
Repository
Assertables: a Rust crate of assert macros for testing
Basic Info
Statistics
- Stars: 88
- Watchers: 2
- Forks: 3
- Open Issues: 3
- Releases: 0
Metadata Files
README.md
Assertables: assert macros for better testing
Assertables is a Rust crate of assert macros to improve your compile-time tests and run-time reliability.
documentation • source • llms.txt • crate • email
Introduction
The Assertables Rust crate provides many assert macros that can help you develop, test, and debug.
This documentation is also available as llms.txt.
- Test values with assert_lt, assert_gt, assert_in, …
- Test groups with assert_all, assert_any, assert_iter, …
- Test wrappers with assert_ok, assert_some, assert_ready, …
- Test matching with assert_matches, assertismatch, …
- Test nearness with assert_approx, assertabsdiff, …
- Test programs with assert_command, assert_status, …
- Many more below.
To use this crate, add it to your file Cargo.toml:
toml
assertables = "9.8.2"
Benefits:
- You can write better tests to improve reliability and maintainability.
- You can handle more corner cases without needing to write custom code.
- You can troubleshoot faster because error messages show more detail.
Learning: FAQ, docs, examples, changes, upgrades, developing.
Comparisons: more_asserts, cool_asserts, assert2, claims, etc.
Examples
Examples with numbers:
rust
let i = 1;
assert_lt!(i, 2);
assert_in_range!(&i, 0..2);
Examples with strings:
rust
let s = "hello";
assert_starts_with!(s, "h");
assert_is_match!(Regex::new(r"e.*o").unwrap(), s);
Examples with arrays:
rust
let a = [1, 2, 3];
assert_contains!(a, &2);
assert_all!(a.into_iter(), |i: i32| i < 4);
Highlights
Values:
assert_eq!(a, b)assert_ne!(a, b)assert_ge!(a, b)assert_gt!(a, b)assert_le!(a, b)assert_lt!(a, b)
Floats:
Nearness:
assert_approx_eq!(a, b)assert_in_delta!(a, b, delta)assert_in_epsilon!(a, b, epsilon)assert_in_range!(a, range)assert_diff_eq_x!(a, b, x)assert_abs_diff_eq_x!(a, b, x)
Groups:
assert_all!(group, predicate)assert_any!(group, predicate)assert_is_empty!(group)assert_len_eq!(a, b)assert_count_eq!(a, b)
Matching:
assert_starts_with!(sequence, x)assert_ends_with!(sequence, x)assert_contains!(container, x)assert_is_match!(matcher, x)assert_matches!(expr, pattern)assert_email_address!(string)
Results:
Options:
Polls:
Readers:
Iterators:
assert_iter_eq!(a, b)assert_iter_ne!(a, b)assert_iter_ge!(a, b)assert_iter_gt!(a, b)assert_iter_le!(a, b)assert_iter_lt!(a, b)
Sets:
Bags:
Commands:
Status:
assert_status_success!(a)assert_status_code_value_eq_x!(a, x)assert_status_code_value_ne_x!(a, x)assert_status_failure!(a)
Infix values:
assert_infix!(a == b)assert_infix!(a != b)assert_infix!(a < b)assert_infix!(a <= b)assert_infix!(a > b)assert_infix!(a >= b)
Infix logic:
assert_infix!(a & b)assert_infix!(a | b)assert_infix!(a ^ b)assert_infix!(a && b)assert_infix!(a || b)
For a complete list of modules and macros, see the docs.
Forms
All the macros have forms for an optional message:
assert_gt!(a, b)// default messageassert_gt!(a, b, "your text")// custom message
All the macros have forms for different outcomes:
assert_gt!(1, 2)// panicassert_gt_as_result!(1, 2)return Resultdebug_assert_gt!(a, b)// panic in debug mode
Many of the macros have a form "compare left item to right item" that compares items of the same kind, and a form "compare left item to right expression" that compares one item to any arbitrary expression:
assert_len_eq!(a, b)// a.len() = b.len()assert_len_eq_x!(a, x)// a.len() = x
Many of the macros has a "success return", which means the macro returns data that you can optionally use for more testing.
let inner = assert_ok!(result)let string = assert_fs_read_to_string_ne!("alfa.txt", "")let stdout = assert_command_stdout_gt!("ls", vec![b' '])
Tracking
- Package: assertables-rust-crate
- Version: 9.8.2
- Created: 2021-03-30T15:47:49Z
- Updated: 2025-08-03T10:17:46Z
- License: MIT or Apache-2.0 or GPL-2.0 or GPL-3.0 or contact us for more
- Contact: Joel Parker Henderson joel@joelparkerhenderson.com
Owner
- Name: SixArm
- Login: SixArm
- Kind: organization
- Email: sixarm@sixarm.com
- Location: San Francisco
- Website: http://sixarm.com
- Twitter: sixarm
- Repositories: 580
- Profile: https://github.com/SixArm
SixArm Software
Citation (CITATION.cff)
cff-version: 1.2.0
title: Assertables: Rust crate of assert macros for testing
message: >-
If you use this work and you want to cite it,
then you can use the metadata from this file.
type: software
authors:
- given-names: Joel Parker
family-names: Henderson
email: joel@joelparkerhenderson.com
affiliation: joelparkerhenderson.com
orcid: 'https://orcid.org/0009-0000-4681-282X'
identifiers:
- type: url
value: 'https://github.com/SixArm/assertables-rust-crate/'
description: Assertables: Rust crate of assert macros for testing
repository-code: 'https://github.com/SixArm/assertables-rust-crate/'
abstract: >-
Assertables: Rust crate of assert macros for testing
license: See license file
GitHub Events
Total
- Issues event: 7
- Watch event: 21
- Issue comment event: 43
- Push event: 107
- Pull request event: 1
- Fork event: 2
- Create event: 15
Last Year
- Issues event: 7
- Watch event: 21
- Issue comment event: 43
- Push event: 107
- Pull request event: 1
- Fork event: 2
- Create event: 15
Committers
Last synced: 11 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Joel Parker Henderson | j****l@j****m | 384 |
| Scott Stevenson | s****t@s****o | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 9
- Total pull requests: 1
- Average time to close issues: 2 months
- Average time to close pull requests: about 13 hours
- Total issue authors: 8
- Total pull request authors: 1
- Average comments per issue: 4.89
- Average comments per pull request: 0.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 6
- Pull requests: 0
- Average time to close issues: 11 days
- Average time to close pull requests: N/A
- Issue authors: 5
- Pull request authors: 0
- Average comments per issue: 5.33
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- ypoluektovich (2)
- anchpop (1)
- shepmaster (1)
- DavidAntliff (1)
- rluvaton (1)
- udalrich (1)
- bjones1 (1)
- drmorr0 (1)
- osmano807 (1)
- xstefanox (1)
Pull Request Authors
- srstevenson (1)
- kmorkos (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cargo 513,348 total
- Total dependent packages: 13
- Total dependent repositories: 3
- Total versions: 69
- Total maintainers: 1
crates.io: assertables
Assertables: assert macros for better testing, debugging, quality assurance, and runtime reliability.
- Documentation: https://docs.rs/assertables/
- License: MIT OR Apache-2.0 OR GPL-2.0 OR GPL-3.0 OR BSD-3-Clause
-
Latest release: 9.8.2
published 8 months ago
Rankings
Maintainers (1)
Dependencies
- actions/checkout v3 composite
- taiki-e/create-gh-release-action v1 composite
- cargo-dist 0.0.2 development
- regex 1.7.1 development