• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LearnLib / automatalib / 12651580329

07 Jan 2025 12:29PM UTC coverage: 91.569% (+0.03%) from 91.542%
12651580329

push

github

web-flow
Update dependencies (#85)

* bump basic dependency versions

* bump checkstyle + cleanups

* bump spotbugs + cleanups

* bump pmd + cleanups

* bump checkerframework + cleanups

* some more cleanups

* ExceptionUtil: support nulls

* improve comments

* cleanup naming + formatting

* formatting

* formatting

* do not fail on javadoc warnings

completness of documentation is now checked by checkstyle and we would have to disable failing anyways when moving on to JDK 17

192 of 217 new or added lines in 63 files covered. (88.48%)

4 existing lines in 4 files now uncovered.

16573 of 18099 relevant lines covered (91.57%)

1.69 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.33
/util/src/main/java/net/automatalib/util/automaton/conformance/WMethodTestsIterator.java
1
/* Copyright (C) 2013-2024 TU Dortmund University
2
 * This file is part of AutomataLib, http://www.automatalib.net/.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package net.automatalib.util.automaton.conformance;
17

18
import java.util.Collection;
19
import java.util.Collections;
20
import java.util.Iterator;
21
import java.util.List;
22

23
import net.automatalib.automaton.UniversalDeterministicAutomaton;
24
import net.automatalib.common.util.collection.AbstractThreeLevelIterator;
25
import net.automatalib.common.util.collection.IterableUtil;
26
import net.automatalib.common.util.collection.IteratorUtil;
27
import net.automatalib.common.util.collection.ReusableIterator;
28
import net.automatalib.util.automaton.cover.Covers;
29
import net.automatalib.util.automaton.equivalence.CharacterizingSets;
30
import net.automatalib.word.Word;
31
import net.automatalib.word.WordBuilder;
32

33
/**
34
 * Iterator that returns test words generated by the W method.
35
 * <p>
36
 * See "Testing software design modeled by finite-state machines" by Tsun S. Chow.
37
 *
38
 * @param <I>
39
 *         input symbol type
40
 */
41
public class WMethodTestsIterator<I> extends AbstractThreeLevelIterator<Word<I>, List<I>, Word<I>, Word<I>> {
42

43
    private final Collection<? extends I> inputs;
44
    private final int maxDepth;
45

46
    private final Iterable<Word<I>> suffixes;
47

48
    /**
49
     * Convenience-constructor for {@link #WMethodTestsIterator(UniversalDeterministicAutomaton, Collection, int)} that
50
     * selects {@code 0} as {@code maxDepth}.
51
     *
52
     * @param automaton
53
     *         the automaton for which the testing sequences should be generated
54
     * @param inputs
55
     *         the input symbols that should be considered for test sequence generation
56
     */
57
    public WMethodTestsIterator(UniversalDeterministicAutomaton<?, I, ?, ?, ?> automaton,
58
                                Collection<? extends I> inputs) {
59
        this(automaton, inputs, 0);
2✔
60
    }
2✔
61

62
    /**
63
     * Constructor.
64
     *
65
     * @param automaton
66
     *         the automaton for which the testing sequences should be generated
67
     * @param inputs
68
     *         the input symbols that should be considered for test sequence generation
69
     * @param maxDepth
70
     *         the maximum number of symbols that are appended to the transition-cover part of the test sequences
71
     */
72
    public WMethodTestsIterator(UniversalDeterministicAutomaton<?, I, ?, ?, ?> automaton,
73
                                Collection<? extends I> inputs,
74
                                int maxDepth) {
75
        super(IteratorUtil.concat(IteratorUtil.singleton(Word.epsilon()),
2✔
76
                                  Covers.transitionCoverIterator(automaton, inputs)));
2✔
77

78
        this.inputs = inputs;
2✔
79
        this.maxDepth = maxDepth;
2✔
80

81
        final Iterator<Word<I>> characterizingSet = CharacterizingSets.characterizingSetIterator(automaton, inputs);
2✔
82

83
        // Special case: List of characterizing suffixes may be empty,
84
        // but in this case we still need to iterate over the prefixes!
85
        if (characterizingSet.hasNext()) {
2✔
86
            this.suffixes = new ReusableIterator<>(characterizingSet);
2✔
87
        } else {
NEW
88
            this.suffixes = Collections.singletonList(Word.epsilon());
×
89
        }
90
    }
2✔
91

92
    @Override
93
    protected Iterator<List<I>> l2Iterator(Word<I> l1Object) {
94
        return IterableUtil.<I>allTuples(inputs, 0, maxDepth).iterator();
2✔
95
    }
96

97
    @Override
98
    protected Iterator<Word<I>> l3Iterator(Word<I> prefix, List<I> middle) {
99
        return suffixes.iterator();
2✔
100
    }
101

102
    @Override
103
    protected Word<I> combine(Word<I> prefix, List<I> middle, Word<I> suffix) {
104
        final WordBuilder<I> wb = new WordBuilder<>(prefix.size() + middle.size() + suffix.size());
2✔
105
        return wb.append(prefix).append(middle).append(suffix).toWord();
2✔
106
    }
107
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc