@@ -94,13 +94,15 @@ TEMPLATE_TEST_CASE( "test every probe with a 0 or 1 element", "[probe]",
9494 const std::vector<int > collection;
9595 auto disorder = measure (collection);
9696 CHECK ( disorder == 0 );
97+ CHECK ( measure.max_for_size (0 ) == 0 );
9798 }
9899
99100 SECTION ( " one-element collection" )
100101 {
101102 const std::vector<int > collection = { 42 };
102103 auto disorder = measure (collection);
103104 CHECK ( disorder == 0 );
105+ CHECK ( measure.max_for_size (0 ) == 0 );
104106 }
105107}
106108
@@ -370,3 +372,25 @@ TEMPLATE_TEST_CASE( "test monotonicity", "[probe]",
370372 : disorder_wyz <= disorder_wxz;
371373 });
372374}
375+
376+ TEMPLATE_TEST_CASE ( " test that probes never produce more disorder than their theoretical maximum" , " [probe]" ,
377+ decltype (cppsort::probe::block),
378+ decltype(cppsort::probe::dis),
379+ decltype(cppsort::probe::enc),
380+ decltype(cppsort::probe::exc),
381+ decltype(cppsort::probe::ham),
382+ decltype(cppsort::probe::inv),
383+ decltype(cppsort::probe::max),
384+ decltype(cppsort::probe::mono),
385+ decltype(cppsort::probe::osc),
386+ decltype(cppsort::probe::rem),
387+ decltype(cppsort::probe::runs),
388+ decltype(cppsort::probe::spear),
389+ decltype(cppsort::probe::sus) )
390+ {
391+ rc::prop (" M(X) ≤ max_for_size(|X|)" , [](const std::vector<int >& sequence) {
392+ using diff_t = std::vector<int >::difference_type;
393+ std::decay_t <TestType> measure;
394+ return measure (sequence) <= measure.template max_for_size <diff_t >(sequence.size ());
395+ });
396+ }
0 commit comments