pub struct TestCtx { /* private fields */ }Implementations§
Source§impl TestCtx
impl TestCtx
Sourcepub fn thread_index(&self) -> usize
pub fn thread_index(&self) -> usize
The index of your thread, in the range between 0 and the specified TestCfg::threads value.
Examples found in repository?
examples/stack.rs (line 73)
66fn main() {
67 cobb::run_test(cobb::TestCfg::<BuggyStack<usize>> {
68 threads: if cfg!(miri) { 8 } else { 16 },
69 iterations: if cfg!(miri) { 100 } else { 1000 },
70 sub_iterations: if cfg!(miri) { 10 } else { 20 },
71 setup: || BuggyStack::new(),
72 test: |stk, tctx| {
73 stk.push(tctx.thread_index());
74 let _ = stk.pop();
75 },
76 ..Default::default()
77 });
78}More examples
examples/mutex.rs (line 51)
45fn main() {
46 cobb::run_test(cobb::TestCfg::<BuggyMutex<usize>> {
47 threads: 16,
48 iterations: 1000,
49 setup: || BuggyMutex::new(0),
50 test: |mutex, tctx| {
51 *mutex.lock() += tctx.thread_index();
52 },
53 before_each: |m| {
54 *m.lock() = 0;
55 },
56 after_each: |m| {
57 assert_eq!((0..16usize).sum::<usize>(), *m.lock());
58 },
59 ..Default::default()
60 });
61}Sourcepub fn sub_iteration(&self) -> usize
pub fn sub_iteration(&self) -> usize
Which iteration you’re on between 0 and TestCfg::sub_iterations (which
is usually 1).
Auto Trait Implementations§
impl !Freeze for TestCtx
impl !RefUnwindSafe for TestCtx
impl Send for TestCtx
impl !Sync for TestCtx
impl Unpin for TestCtx
impl UnsafeUnpin for TestCtx
impl UnwindSafe for TestCtx
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more