Ejemplo n.º 1
0
        private static IList<FilterTestMultiStmtExecution> ComputePermutationsCase(
            Type originator,
            PermutationSpec permutationSpec,
            FilterTestMultiStmtPermutable permutableCase,
            bool withStats)
        {
            if (!permutationSpec.IsAll) {
                return Collections.SingletonList(
                    CaseOf(originator, permutationSpec.Specific, permutableCase, withStats));
            }

            // determine that filters is different
            ISet<string> filtersUnique = new HashSet<string>(Arrays.AsList(permutableCase.Filters));
            if (filtersUnique.Count == 1 && permutableCase.Filters.Length > 1) {
                Assert.Fail("Filters are all the same, specify a single permutation instead");
            }

            IList<FilterTestMultiStmtExecution> executions = new List<FilterTestMultiStmtExecution>();
            var permutationEnumerator = PermutationEnumerator.Create(permutableCase.Filters.Length);
            foreach (var permutation in permutationEnumerator) {
                executions.Add(CaseOf(originator, permutation, permutableCase, withStats));
            }

            return executions;
        }
Ejemplo n.º 2
0
 private static FilterTestMultiStmtExecution CaseOf(
     Type originator,
     int[] permutation,
     FilterTestMultiStmtPermutable permutableCase,
     bool withStats)
 {
     var theCase = ComputePermutation(permutableCase, permutation);
     return new FilterTestMultiStmtExecution(originator, theCase, withStats);
 }
Ejemplo n.º 3
0
 public static void AddCase(
     IList<FilterTestMultiStmtPermutable> cases,
     FilterTestMultiStmtAssertStats[] statsPerPermutation,
     string filter,
     params FilterTestMultiStmtAssertItem[] items)
 {
     var theCase = new FilterTestMultiStmtPermutable(statsPerPermutation, filter);
     theCase.Items.AddAll(Arrays.AsList(items));
     cases.Add(theCase);
 }
Ejemplo n.º 4
0
        private static FilterTestMultiStmtCase ComputePermutation(
            FilterTestMultiStmtPermutable permutableCase,
            int[] permutation)
        {
            // permute filters
            var filtersPermuted = new string[permutableCase.Filters.Length];
            for (var i = 0; i < permutation.Length; i++) {
                filtersPermuted[i] = permutableCase.Filters[permutation[i]];
            }

            // permute expected values
            IList<FilterTestMultiStmtAssertItem> itemsPermuted = new List<FilterTestMultiStmtAssertItem>();
            foreach (var items in permutableCase.Items) {
                var expectedPermuted = new bool[items.ExpectedPerStmt.Length];
                for (var i = 0; i < permutation.Length; i++) {
                    expectedPermuted[i] = items.ExpectedPerStmt[permutation[i]];
                }

                itemsPermuted.Add(new FilterTestMultiStmtAssertItem(items.Bean, expectedPermuted));
            }

            // find stats for this permutation
            FilterTestMultiStmtAssertStats statsPermuted = null;
            foreach (var stats in permutableCase.StatsPerPermutation) {
                if (Arrays.AreEqual(stats.Permutation, permutation)) {
                    if (statsPermuted != null) {
                        throw new IllegalStateException("Permutation " + permutation.RenderAny() + " exists twice");
                    }

                    statsPermuted = stats;
                }
            }

            if (statsPermuted == null) {
                throw new IllegalStateException("Failed to find stats for permutation " + permutation.RenderAny());
            }

            return new FilterTestMultiStmtCase(filtersPermuted, statsPermuted.Stats, itemsPermuted);
        }