All Pairs

This is the third and final fixture of a suite that make up the AllPairsExample. Like with AllFiles, we expand wildcard characters in path specifications to get lists of tests. And, like in AllCombinations, we enumerate cases drawing from these lists one test at a time in sequence. But here our goal is only to test all possible pairs of test, which will require fewer cases.


Here is the same specification we used to test the CalculatorExample in AllCombinations. Try it using AllPairs.

http:run.cgi

eg.AllPairs

input/AllPairs/magnitude/*.html

 

input/AllPairs/sign/*.html

 

input/AllPairs/function/*.html

 

1
180+30.html 1 right, 0 wrong, 0 ignores, 0 exceptions
change-sign.html 0 right, 0 wrong, 0 ignores, 0 exceptions
cosine.html 1 right, 0 wrong, 0 ignores, 0 exceptions
2
180+30.html 1 right, 0 wrong, 0 ignores, 0 exceptions
multiply.html 0 right, 0 wrong, 0 ignores, 0 exceptions
sine.html 1 right, 0 wrong, 0 ignores, 0 exceptions
3
180+30.html 1 right, 0 wrong, 0 ignores, 0 exceptions
no-change.html 0 right, 0 wrong, 0 ignores, 0 exceptions
cosine.html 1 right, 0 wrong, 0 ignores, 0 exceptions
4
30.html 1 right, 0 wrong, 0 ignores, 0 exceptions
change-sign.html 0 right, 0 wrong, 0 ignores, 0 exceptions
cosine.html 1 right, 0 wrong, 0 ignores, 0 exceptions
5
30.html 1 right, 0 wrong, 0 ignores, 0 exceptions
multiply.html 0 right, 0 wrong, 0 ignores, 0 exceptions
sine.html 1 right, 0 wrong, 0 ignores, 0 exceptions
6
30.html 1 right, 0 wrong, 0 ignores, 0 exceptions
no-change.html 0 right, 0 wrong, 0 ignores, 0 exceptions
sine.html 1 right, 0 wrong, 0 ignores, 0 exceptions
7
360+30.html 1 right, 0 wrong, 0 ignores, 0 exceptions
change-sign.html 0 right, 0 wrong, 0 ignores, 0 exceptions
cosine.html 1 right, 0 wrong, 0 ignores, 0 exceptions
8
360+30.html 1 right, 0 wrong, 0 ignores, 0 exceptions
multiply.html 0 right, 0 wrong, 0 ignores, 0 exceptions
sine.html 1 right, 0 wrong, 0 ignores, 0 exceptions
9
360+30.html 1 right, 0 wrong, 0 ignores, 0 exceptions
no-change.html 0 right, 0 wrong, 0 ignores, 0 exceptions
cosine.html 1 right, 0 wrong, 0 ignores, 0 exceptions
10
90-30.html 1 right, 0 wrong, 0 ignores, 0 exceptions
change-sign.html 0 right, 0 wrong, 0 ignores, 0 exceptions
cosine.html 0 right, 1 wrong, 0 ignores, 0 exceptions[!]
11
90-30.html 1 right, 0 wrong, 0 ignores, 0 exceptions
multiply.html 0 right, 0 wrong, 0 ignores, 0 exceptions
sine.html 0 right, 1 wrong, 0 ignores, 0 exceptions[!]
12
90-30.html 1 right, 0 wrong, 0 ignores, 0 exceptions
no-change.html 0 right, 0 wrong, 0 ignores, 0 exceptions
cosine.html 0 right, 1 wrong, 0 ignores, 0 exceptions[!]
13
180+30.html 1 right, 0 wrong, 0 ignores, 0 exceptions
change-sign.html 0 right, 0 wrong, 0 ignores, 0 exceptions
cosine.html 1 right, 0 wrong, 0 ignores, 0 exceptions
14
180+30.html 1 right, 0 wrong, 0 ignores, 0 exceptions
change-sign.html 0 right, 0 wrong, 0 ignores, 0 exceptions
sine.html 1 right, 0 wrong, 0 ignores, 0 exceptions
15
180+30.html 1 right, 0 wrong, 0 ignores, 0 exceptions
multiply.html 0 right, 0 wrong, 0 ignores, 0 exceptions
cosine.html 1 right, 0 wrong, 0 ignores, 0 exceptions
16
30.html 1 right, 0 wrong, 0 ignores, 0 exceptions
multiply.html 0 right, 0 wrong, 0 ignores, 0 exceptions
sine.html 1 right, 0 wrong, 0 ignores, 0 exceptions

To meet the "all pairs" requirement we need at least n X m cases, where n and m are the sizes of the two largest categories. That means with only two categories all combinations and all pairs are the same. The marvel of the all pairs algorithm is that it squeezes draws from additional categories into these same cases and possibly a few more.

fit.Summary

counts 45 right, 3 wrong, 0 ignores, 0 exceptions
input file input/AllPairs.html
input update Sun Apr 30 14:32:22 2006
output file output/AllPairs.html
run date Wed May  3 18:10:02 2006
run elapsed time 0 wallclock secs ( 0.00 usr +  0.02 sys =  0.02 CPU)

Implementation

The algorithm is largely JamesBach's from the source cited on the AllPairsExample page. My implementation can be summarized as follows.

The case currently being filled is called the slug. A pair will fit the slug only if the following hold.

The fixture uses these helper objects to represent the state of the algorithm.

See the source.

See AllPairsAlgorithm for some tests we've written for this algorithm itself.


Last edited November 9, 2002