test-that 0.5.0

A rich assertion and matcher library based on GoogleTest
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
// Copyright 2022 Google LLC
// Copyright 2026 Bradford Hovinen <bradford@hovinen.me>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::{
    description::Description,
    matcher::{Describable, Matcher, MatcherResult},
    matchers::{
        containers::{
            OwnedItems, RefItems, container_contains::unordered_matcher::__internal::MatchMatrix,
        },
        eq, eq_deref_of,
    },
};
use alloc::{
    string::{String, ToString},
    vec::Vec,
};
use core::{fmt::Debug, marker::PhantomData};

use super::container_contains::Requirements;

/// Matches a container equal (in the sense of `==`) to `expected`.
///
/// This is similar to [`crate::matchers::eq`] except that an assertion failure
/// message generated from this matcher will include the missing and unexpected
/// items in the actual value, e.g.:
///
/// ```text
/// Expected container to equal [1, 2, 3]
///   but was: [1, 2, 4]
///   Missing: [3]
///   Unexpected: [4]
/// ```
///
/// The actual value must be a container such as a `Vec`, an array, or a
/// dereferenced slice. More precisely, a shared borrow of the actual value must
/// implement [`IntoIterator`] whose `Item` type implements
/// [`PartialEq<ExpectedT>`], where `ExpectedT` is the element type of the
/// expected value.
///
/// If the container type is a `Vec`, then the expected type may be a slice of
/// the same element type. For example:
///
/// ```
/// # use test_that::prelude::*;
/// # fn should_pass() -> TestResult<()> {
/// let vec = vec![1, 2, 3];
/// verify_that!(vec, container_eq([1, 2, 3]))?;
/// #     Ok(())
/// # }
/// # should_pass().unwrap();
/// ```
///
/// As an exception, if the actual type is a `Vec<String>`, the expected type
/// may be a slice of `&str`:
///
/// ```
/// # use test_that::prelude::*;
/// # fn should_pass() -> TestResult<()> {
/// let vec: Vec<String> = vec!["A string".into(), "Another string".into()];
/// verify_that!(vec, container_eq(["A string", "Another string"]))?;
/// #     Ok(())
/// # }
/// # should_pass().unwrap();
/// ```
///
/// These exceptions allow one to avoid unnecessary allocations in test
/// assertions.
///
/// One can also check container equality of a slice with an array. To do so,
/// dereference the slice:
///
/// ```
/// # use test_that::prelude::*;
/// # fn should_pass() -> TestResult<()> {
/// let value = &[1, 2, 3];
/// verify_that!(*value, container_eq([1, 2, 3]))?;
/// #     Ok(())
/// # }
/// # should_pass().unwrap();
/// ```
///
/// Otherwise, the actual and expected types must be identical.
///
/// *Performance note*: In the event of a mismatch leading to an assertion
/// failure, the construction of the lists of missing and unexpected values
/// uses a naive algorithm requiring time proportional to the product of the
/// sizes of the expected and actual values. This should therefore only be used
/// when the containers are small enough that this is not a problem.
///
/// ## Comparing conatiners while ignoring order
///
/// Use [ignoring_order()][ContainerEqMatcher::ignoring_order] to ignore the
/// order of the elements.
///
/// ```
/// # use test_that::prelude::*;
/// # fn should_pass() -> TestResult<()> {
/// verify_that!(vec![1, 2, 3], container_eq([3, 2, 1]).ignoring_order())?;
/// #     Ok(())
/// # }
/// # should_pass().unwrap();
/// ```
// This returns ContainerEqMatcher and not impl Matcher because
// ContainerEqMatcher has some specialisations for slice types (see
// documentation above). Returning impl Matcher would hide those from the
// compiler.
pub fn container_eq<ExpectedContainerT, Mode>(
    expected: ExpectedContainerT,
) -> ContainerEqMatcher<ExpectedContainerT, Mode> {
    ContainerEqMatcher { expected, ignore_order: false, phantom: Default::default() }
}

/// A matcher which matches a container equal (in the sense of [`PartialEq`])
/// to the given value.
pub struct ContainerEqMatcher<ExpectedContainerT, Mode> {
    expected: ExpectedContainerT,
    ignore_order: bool,
    phantom: PhantomData<Mode>,
}

impl<ExpectedContainerT, Mode> ContainerEqMatcher<ExpectedContainerT, Mode> {
    /// Ignores the order of the elements when comparing containers.
    ///
    /// The containers will be deemed equal if there is a 1:1 correspondence of
    /// elements in the actual and expected containers in which each actual
    /// element equals (in the sense of [`PartialEq`]) its corresponding
    /// expected element.
    pub fn ignoring_order(self) -> Self {
        Self { ignore_order: true, ..self }
    }
}

impl<ActualElementT, ActualContainerT, ExpectedElementT, ExpectedContainerT>
    Matcher<ActualContainerT> for ContainerEqMatcher<ExpectedContainerT, RefItems>
where
    ActualElementT: PartialEq<ExpectedElementT> + Debug + ?Sized,
    ActualContainerT: PartialEq<ExpectedContainerT> + Debug + ?Sized,
    ExpectedElementT: Debug,
    ExpectedContainerT: Debug,
    for<'a> &'a ActualContainerT: IntoIterator<Item = &'a ActualElementT>,
    for<'a> &'a ExpectedContainerT: IntoIterator<Item = &'a ExpectedElementT>,
{
    fn matches(&self, actual: &ActualContainerT) -> MatcherResult {
        if self.ignore_order {
            let expected: Vec<_> = self.expected.into_iter().map(eq_deref_of).collect();
            let match_matrix = MatchMatrix::generate_for_fixed_matcher::<_, ActualElementT, _>(
                actual.into_iter(),
                expected.len(),
                &expected,
            );
            match_matrix.is_match_for(Requirements::PerfectMatch).into()
        } else {
            (*actual == self.expected).into()
        }
    }

    fn explain_match(&self, actual: &ActualContainerT) -> Description {
        build_explanation(
            self.get_missing_items(actual),
            self.get_unexpected_items(actual),
            self.matches(actual),
        )
        .into()
    }
}

impl<ExpectedElementT, ExpectedContainerT> ContainerEqMatcher<ExpectedContainerT, RefItems>
where
    for<'a> &'a ExpectedContainerT: IntoIterator<Item = &'a ExpectedElementT>,
{
    fn get_missing_items<ActualElementT, ActualContainerT>(
        &self,
        actual: &ActualContainerT,
    ) -> Vec<&ExpectedElementT>
    where
        ActualElementT: PartialEq<ExpectedElementT> + ?Sized,
        ActualContainerT: PartialEq<ExpectedContainerT> + ?Sized,
        ExpectedElementT: Debug,
        for<'a> &'a ActualContainerT: IntoIterator<Item = &'a ActualElementT>,
    {
        self.expected.into_iter().filter(|&i| !actual.into_iter().any(|j| j == i)).collect()
    }

    fn get_unexpected_items<'a, ActualElementT, ActualContainerT>(
        &self,
        actual: &'a ActualContainerT,
    ) -> Vec<&'a ActualElementT>
    where
        ActualElementT: PartialEq<ExpectedElementT> + ?Sized,
        ActualContainerT: PartialEq<ExpectedContainerT> + ?Sized,
        ExpectedElementT: Debug,
        for<'b> &'b ActualContainerT: IntoIterator<Item = &'b ActualElementT>,
    {
        actual.into_iter().filter(|&i| !self.expected.into_iter().any(|j| i == j)).collect()
    }
}

impl<ActualElementT, ActualContainerT, ExpectedElementT, ExpectedContainerT>
    Matcher<ActualContainerT> for ContainerEqMatcher<ExpectedContainerT, OwnedItems>
where
    ActualElementT: PartialEq<ExpectedElementT> + Debug,
    ActualContainerT: PartialEq<ExpectedContainerT> + Debug + ?Sized,
    ExpectedElementT: Debug,
    ExpectedContainerT: Debug,
    for<'a> &'a ActualContainerT: IntoIterator<Item = ActualElementT>,
    for<'a> &'a ExpectedContainerT: IntoIterator<Item = ExpectedElementT>,
{
    fn matches(&self, actual: &ActualContainerT) -> MatcherResult {
        if self.ignore_order {
            let expected: Vec<_> = self.expected.into_iter().map(eq).collect();
            let match_matrix = MatchMatrix::generate_for_fixed_matcher(
                actual.into_iter(),
                expected.len(),
                &expected,
            );
            match_matrix.is_match_for(Requirements::PerfectMatch).into()
        } else {
            (*actual == self.expected).into()
        }
    }

    fn explain_match(&self, actual: &ActualContainerT) -> Description {
        build_explanation(
            self.get_missing_items(actual),
            self.get_unexpected_items(actual),
            self.matches(actual),
        )
        .into()
    }
}

impl<ExpectedElementT, ExpectedContainerT> ContainerEqMatcher<ExpectedContainerT, OwnedItems>
where
    for<'a> &'a ExpectedContainerT: IntoIterator<Item = ExpectedElementT>,
{
    fn get_missing_items<ActualElementT, ActualContainerT>(
        &self,
        actual: &ActualContainerT,
    ) -> Vec<ExpectedElementT>
    where
        ActualElementT: PartialEq<ExpectedElementT>,
        ActualContainerT: PartialEq<ExpectedContainerT> + ?Sized,
        ExpectedElementT: Debug,
        for<'a> &'a ActualContainerT: IntoIterator<Item = ActualElementT>,
    {
        self.expected.into_iter().filter(|i| !actual.into_iter().any(|j| j == *i)).collect()
    }

    fn get_unexpected_items<'a, ActualElementT, ActualContainerT>(
        &self,
        actual: &'a ActualContainerT,
    ) -> Vec<ActualElementT>
    where
        ActualElementT: PartialEq<ExpectedElementT>,
        ActualContainerT: PartialEq<ExpectedContainerT> + ?Sized,
        ExpectedElementT: Debug,
        for<'b> &'b ActualContainerT: IntoIterator<Item = ActualElementT>,
    {
        actual.into_iter().filter(|i| !self.expected.into_iter().any(|j| *i == j)).collect()
    }
}

impl<ExpectedContainerT: Debug, Mode> Describable for ContainerEqMatcher<ExpectedContainerT, Mode> {
    fn describe(&self, matcher_result: MatcherResult) -> Description {
        match matcher_result {
            MatcherResult::Match => format!("is equal to {:?}", self.expected).into(),
            MatcherResult::NoMatch => format!("isn't equal to {:?}", self.expected).into(),
        }
    }
}

fn build_explanation<T: Debug, U: Debug>(
    missing: Vec<T>,
    unexpected: Vec<U>,
    matcher_result: MatcherResult,
) -> String {
    match (missing.len(), unexpected.len(), matcher_result) {
        // TODO(b/261175849) add more data here (out of order elements, duplicated elements, etc...)
        (0, 0, MatcherResult::NoMatch) => {
            "which contains all the elements but in the wrong order".to_string()
        }
        (0, 0, MatcherResult::Match) => "which contains all the elements".to_string(),
        (0, 1, _) => format!("which contains the unexpected element {:?}", unexpected[0]),
        (0, _, _) => format!("which contains the unexpected elements {unexpected:?}",),
        (1, 0, _) => format!("which is missing the element {:?}", missing[0]),
        (1, 1, _) => {
            format!(
                "which is missing the element {:?} and contains the unexpected element {:?}",
                missing[0], unexpected[0]
            )
        }
        (1, _, _) => {
            format!(
                "which is missing the element {:?} and contains the unexpected elements {unexpected:?}",
                missing[0]
            )
        }
        (_, 0, _) => format!("which is missing the elements {missing:?}"),
        (_, 1, _) => {
            format!(
                "which is missing the elements {missing:?} and contains the unexpected element {:?}",
                unexpected[0]
            )
        }
        (_, _, _) => {
            format!(
                "which is missing the elements {missing:?} and contains the unexpected elements {unexpected:?}",
            )
        }
    }
}

#[cfg(test)]
mod tests {
    use crate::prelude::*;
    use alloc::{
        string::{String, ToString},
        vec::Vec,
    };
    use indoc::indoc;

    #[test]
    fn container_eq_returns_match_when_containers_match() -> TestResult<()> {
        verify_that!(vec![1, 2, 3], container_eq(vec![1, 2, 3]))
    }

    #[test]
    fn container_eq_matches_array_with_array() -> TestResult<()> {
        verify_that!([1, 2, 3], container_eq([1, 2, 3]))
    }

    #[test]
    fn container_eq_matches_vec_with_array() -> TestResult<()> {
        verify_that!(vec![1, 2, 3], container_eq([1, 2, 3]))
    }

    #[test]
    fn container_eq_matches_slice_using_points_to() -> TestResult<()> {
        let value = vec![1, 2, 3];
        let slice = value.as_slice();
        verify_that!(slice, points_to(container_eq([1, 2, 3])))
    }

    #[test]
    fn container_eq_matches_slice_using_deref_notation() -> TestResult<()> {
        let value = vec![1, 2, 3];
        let slice = value.as_slice();
        verify_that!(*slice, container_eq([1, 2, 3]))
    }

    #[test]
    fn container_eq_matches_ref_to_array_using_points_to() -> TestResult<()> {
        verify_that!(&[1, 2, 3], points_to(container_eq([1, 2, 3])))
    }

    #[test]
    fn container_eq_matches_ref_to_array_using_deref_notation() -> TestResult<()> {
        let value = &[1, 2, 3];
        verify_that!(*value, container_eq([1, 2, 3]))
    }

    #[test]
    fn container_eq_matches_owned_vec_of_owned_strings_with_array_of_string_slices()
    -> TestResult<()> {
        verify_that!(
            vec!["A string".to_string(), "Another string".to_string()],
            container_eq(["A string", "Another string"])
        )
    }

    #[test]
    fn container_eq_does_not_match_vec_of_owned_strings_with_shorter_array_of_string_slices()
    -> TestResult<()> {
        verify_that!(
            vec!["A string".to_string(), "Another string".to_string()],
            not(container_eq(["A string"]))
        )
    }

    #[test]
    fn container_eq_matches_vec_of_string_slices_with_array_of_string_slices() -> TestResult<()> {
        verify_that!(
            vec!["A string", "Another string"],
            container_eq(["A string", "Another string"])
        )
    }

    #[test]
    fn container_eq_matches_array_of_string_slices_with_array_of_string_slices() -> TestResult<()> {
        verify_that!(["A string", "Another string"], container_eq(["A string", "Another string"]))
    }

    #[test]
    fn container_eq_matches_array_of_string_slices_with_non_static_lifetime_with_array_of_string_slices()
    -> TestResult<()> {
        let string_1 = String::from("A string");
        let string_2 = String::from("Another string");
        verify_that!(
            [string_1.as_str(), string_2.as_str()],
            container_eq(["A string", "Another string"])
        )
    }

    #[cfg(feature = "std")]
    #[test]
    fn container_eq_matches_hash_set_with_array() -> TestResult<()> {
        use std::collections::HashSet;
        verify_that!(HashSet::from([1, 2, 3]), container_eq([1, 2, 3].into()))
    }

    #[test]
    fn container_eq_produces_correct_failure_message() -> TestResult<()> {
        let result = verify_that!(vec![1, 3, 2], container_eq(vec![1, 2, 3]));
        verify_that!(
            result,
            err(displays_as(contains_substring(indoc!(
                "
                    Value of: vec![1, 3, 2]
                    Expected: is equal to [1, 2, 3]
                    Actual: [1, 3, 2],
                      which contains all the elements but in the wrong order
                "
            ))))
        )
    }

    #[test]
    fn container_eq_returns_mismatch_when_elements_out_of_order() -> TestResult<()> {
        let result = verify_that!(vec![1, 3, 2], container_eq(vec![1, 2, 3]));
        verify_that!(
            result,
            err(displays_as(contains_substring(
                "which contains all the elements but in the wrong order"
            )))
        )
    }

    #[test]
    fn container_eq_does_not_show_part_about_wrong_order_when_ignoring_order() -> TestResult<()> {
        let result = verify_that!(vec![1, 3, 2], not(container_eq(vec![1, 2, 3]).ignoring_order()));
        verify_that!(result, err(displays_as(not(contains_substring("but in the wrong order")))))
    }

    #[test]
    fn container_eq_mismatch_shows_missing_elements_in_container() -> TestResult<()> {
        let result = verify_that!(vec![1, 2], container_eq(vec![1, 2, 3]));
        verify_that!(result, err(displays_as(contains_substring("which is missing the element 3"))))
    }

    #[test]
    fn container_eq_mismatch_shows_missing_elements_in_container_when_matching_vec_with_array()
    -> TestResult<()> {
        let result = verify_that!(vec![1, 2], container_eq([1, 2, 3]));
        verify_that!(result, err(displays_as(contains_substring("which is missing the element 3"))))
    }

    #[test]
    fn container_eq_mismatch_shows_surplus_elements_in_container() -> TestResult<()> {
        let result = verify_that!(vec![1, 2, 3], container_eq(vec![1, 2]));
        verify_that!(
            result,
            err(displays_as(contains_substring("which contains the unexpected element 3")))
        )
    }

    #[test]
    fn container_eq_mismatch_shows_missing_and_surplus_elements_in_container() -> TestResult<()> {
        let result = verify_that!(vec![1, 2, 4], container_eq(vec![1, 2, 3]));
        verify_that!(
            result,
            err(displays_as(contains_substring(
                "which is missing the element 3 and contains the unexpected element 4"
            )))
        )
    }

    #[test]
    fn container_eq_mismatch_does_not_show_duplicated_element() -> TestResult<()> {
        let result = verify_that!(vec![1, 2, 3, 3], container_eq(vec![1, 2, 3]));
        verify_that!(
            result,
            err(displays_as(contains_substring("which contains all the elements")))
        )
    }

    #[test]
    fn container_eq_mismatch_with_str_slice_shows_missing_elements_in_container() -> TestResult<()>
    {
        let result =
            verify_that!(vec!["A".to_string(), "B".to_string()], container_eq(["A", "B", "C"]));
        verify_that!(
            result,
            err(displays_as(contains_substring(r#"which is missing the element "C""#)))
        )
    }

    #[test]
    fn container_eq_mismatch_with_str_slice_shows_surplus_elements_in_container() -> TestResult<()>
    {
        let result = verify_that!(
            vec!["A".to_string(), "B".to_string(), "C".to_string()],
            container_eq(["A", "B"])
        );
        verify_that!(
            result,
            err(displays_as(contains_substring(r#"which contains the unexpected element "C""#)))
        )
    }

    #[derive(Debug, PartialEq)]
    struct OwnedItemContainer(Vec<i32>);

    impl<'a> IntoIterator for &'a OwnedItemContainer {
        type Item = i32;
        type IntoIter = core::iter::Copied<core::slice::Iter<'a, i32>>;
        fn into_iter(self) -> Self::IntoIter {
            self.0.iter().copied()
        }
    }

    #[test]
    fn container_eq_matches_on_container_when_ref_to_container_has_into_iterator_producing_owned_values()
    -> TestResult<()> {
        verify_that!(OwnedItemContainer(vec![1]), container_eq(OwnedItemContainer(vec![1])))
    }

    #[test]
    fn container_eq_matches_vec_of_string_slices() -> TestResult<()> {
        verify_that!(
            vec!["String 1", "String 2", "String 3"],
            container_eq(["String 1", "String 2", "String 3"])
        )
    }

    #[test]
    fn container_eq_matches_vec_of_string_slices_with_non_static_lifetime() -> TestResult<()> {
        let string_1 = String::from("String 1");
        let string_2 = String::from("String 2");
        let string_3 = String::from("String 3");
        verify_that!(
            vec![string_1.as_str(), string_2.as_str(), string_3.as_str()],
            container_eq(["String 1", "String 2", "String 3"])
        )
    }

    #[test]
    fn container_eq_matches_slice_of_string_slices() -> TestResult<()> {
        let value = vec!["String 1", "String 2", "String 3"];
        verify_that!(
            value.as_slice(),
            points_to(container_eq(["String 1", "String 2", "String 3"]))
        )
    }

    #[test]
    fn container_eq_matches_slice_of_string_slices_with_non_static_lifetime() -> TestResult<()> {
        let string_1 = String::from("String 1");
        let string_2 = String::from("String 2");
        let string_3 = String::from("String 3");
        let value = vec![string_1.as_str(), string_2.as_str(), string_3.as_str()];
        verify_that!(
            value.as_slice(),
            points_to(container_eq(["String 1", "String 2", "String 3"]))
        )
    }

    #[test]
    fn container_eq_matches_ignoring_order_when_requested() -> TestResult<()> {
        verify_that!(vec![1, 2, 3], container_eq(vec![3, 2, 1]).ignoring_order())
    }

    #[test]
    fn container_eq_does_not_match_non_matching_container_when_ignoring_order() -> TestResult<()> {
        verify_that!(vec![1, 2, 3], not(container_eq(vec![4, 2, 1]).ignoring_order()))
    }

    #[test]
    fn container_eq_matches_slice_of_strings_while_ignoring_order() -> TestResult<()> {
        let string_1 = String::from("String 1");
        let string_2 = String::from("String 2");
        let string_3 = String::from("String 3");
        let value = vec![string_1, string_2, string_3];
        verify_that!(
            value.as_slice(),
            points_to(container_eq(["String 3", "String 2", "String 1"]).ignoring_order())
        )
    }

    #[test]
    fn container_eq_matches_with_owned_item_conatiner_ignoring_order_when_requested()
    -> TestResult<()> {
        verify_that!(
            OwnedItemContainer(vec![1, 2, 3]),
            container_eq(OwnedItemContainer(vec![3, 2, 1])).ignoring_order()
        )
    }

    #[test]
    fn container_eq_does_not_match_non_matching_with_owned_item_conatiner_when_ignoring_order()
    -> TestResult<()> {
        verify_that!(
            OwnedItemContainer(vec![1, 2, 3]),
            not(container_eq(OwnedItemContainer(vec![4, 2, 1])).ignoring_order())
        )
    }
}