@@ -76,4 +76,140 @@ class SummaryOfMath : SummaryTestCaseGeneratorTest(
7676
7777 check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames)
7878 }
79+
80+ @Test
81+ fun testOfDoubles () {
82+ val summary1 = " Test calls StatsAccumulator::addAll,\n " +
83+ " there it triggers recursion of addAll once, \n " +
84+ " Test throws NullPointerException in: acummulator.addAll(values);\n "
85+ val summary2 = " Test calls StatsAccumulator::addAll,\n " +
86+ " there it does not iterate for(double value: values), \n " +
87+ " Test next calls StatsAccumulator::snapshot,\n " +
88+ " there it returns from: return new Stats(count, mean, sumOfSquaresOfDeltas, min, max);\n " +
89+ " \n " +
90+ " Test later returns from: return acummulator.snapshot();\n "
91+ val summary3 = " Test calls StatsAccumulator::addAll,\n " +
92+ " there it iterates the loop for(double value: values) twice,\n " +
93+ " inside this loop, the test calls StatsAccumulator::add,\n " +
94+ " there it executes conditions:\n " +
95+ " (count == 0): True\n " +
96+ " (!isFinite(value)): True\n " +
97+ " calls StatsAccumulator::add,\n " +
98+ " there it executes conditions:\n " +
99+ " (count == 0): False\n " +
100+ " (isFinite(value) && isFinite(mean)): True\n " +
101+ " (if (isFinite(value) && isFinite(mean)) {\n " +
102+ " double delta = value - mean;\n " +
103+ " mean += delta / count;\n " +
104+ " sumOfSquaresOfDeltas += delta * (value - mean);\n " +
105+ " } else {\n " +
106+ " mean = calculateNewMeanNonFinite(mean, value);\n " +
107+ " sumOfSquaresOfDeltas = NaN;\n " +
108+ " }): False\n " +
109+ " Test afterwards calls StatsAccumulator::snapshot,\n " +
110+ " there it returns from: return new Stats(count, mean, sumOfSquaresOfDeltas, min, max);\n " +
111+ " \n " +
112+ " Test afterwards returns from: return acummulator.snapshot();\n "
113+ val summary4 = " Test calls StatsAccumulator::addAll,\n " +
114+ " there it iterates the loop for(double value: values) twice,\n " +
115+ " inside this loop, the test calls StatsAccumulator::add,\n " +
116+ " there it executes conditions:\n " +
117+ " (!isFinite(value)): False\n " +
118+ " Test next calls StatsAccumulator::snapshot,\n " +
119+ " there it returns from: return new Stats(count, mean, sumOfSquaresOfDeltas, min, max);\n " +
120+ " \n " +
121+ " Test then returns from: return acummulator.snapshot();\n "
122+ val summary5 = " Test calls StatsAccumulator::addAll,\n " +
123+ " there it iterates the loop for(double value: values) twice,\n " +
124+ " inside this loop, the test calls StatsAccumulator::add,\n " +
125+ " there it executes conditions:\n " +
126+ " (count == 0): True\n " +
127+ " (!isFinite(value)): False\n " +
128+ " calls StatsAccumulator::add,\n " +
129+ " there it executes conditions:\n " +
130+ " (count == 0): False\n " +
131+ " (isFinite(value) && isFinite(mean)): True\n " +
132+ " (if (isFinite(value) && isFinite(mean)) {\n " +
133+ " double delta = value - mean;\n " +
134+ " mean += delta / count;\n " +
135+ " sumOfSquaresOfDeltas += delta * (value - mean);\n " +
136+ " } else {\n " +
137+ " mean = calculateNewMeanNonFinite(mean, value);\n " +
138+ " sumOfSquaresOfDeltas = NaN;\n " +
139+ " }): True\n " +
140+ " Test later calls StatsAccumulator::snapshot,\n " +
141+ " there it returns from: return new Stats(count, mean, sumOfSquaresOfDeltas, min, max);\n " +
142+ " \n " +
143+ " Test then returns from: return acummulator.snapshot();\n "
144+ val summary6 = " Test calls StatsAccumulator::addAll,\n " +
145+ " there it iterates the loop for(double value: values) twice,\n " +
146+ " inside this loop, the test calls StatsAccumulator::add,\n " +
147+ " there it executes conditions:\n " +
148+ " (!isFinite(value)): True\n " +
149+ " Test afterwards calls StatsAccumulator::snapshot,\n " +
150+ " there it returns from: return new Stats(count, mean, sumOfSquaresOfDeltas, min, max);\n " +
151+ " \n " +
152+ " Test then returns from: return acummulator.snapshot();\n "
153+ val summary7 = " Test calls StatsAccumulator::addAll,\n " +
154+ " there it iterates the loop for(double value: values) twice,\n " +
155+ " inside this loop, the test calls StatsAccumulator::add,\n " +
156+ " there it executes conditions:\n " +
157+ " (!isFinite(value)): True\n " +
158+ " Test later calls StatsAccumulator::snapshot,\n " +
159+ " there it returns from: return new Stats(count, mean, sumOfSquaresOfDeltas, min, max);\n " +
160+ " \n " +
161+ " Test further returns from: return acummulator.snapshot();\n "
162+
163+ val methodName1 = " testOfDoubles_StatsAccumulatorAddAll"
164+ val methodName2 = " testOfDoubles_snapshot"
165+ val methodName3 = " testOfDoubles_IsFiniteAndIsFinite"
166+ val methodName4 = " testOfDoubles_IsFinite"
167+ val methodName5 = " testOfDoubles_IsFiniteAndIsFinite_1"
168+ val methodName6 = " testOfDoubles_NotIsFinite"
169+ val methodName7 = " testOfDoubles_NotIsFinite_1"
170+
171+ val displayName1 = " acummulator.addAll(values) : True -> ThrowNullPointerException"
172+ val displayName2 = " snapshot -> return new Stats(count, mean, sumOfSquaresOfDeltas, min, max)"
173+ val displayName3 = " !isFinite(value) : True -> StatsAccumulatorCalculateNewMeanNonFinite"
174+ val displayName4 = " add -> !isFinite(value) : False"
175+ val displayName5 = " !isFinite(value) : False -> isFinite(value) && isFinite(mean)"
176+ val displayName6 = " add -> !isFinite(value) : True"
177+ val displayName7 = " add -> !isFinite(value) : True"
178+
179+ val method = Stats ::ofDoubles
180+ val mockStrategy = MockStrategyApi .NO_MOCKS
181+ val coverage = DoNotCalculate
182+
183+ val summaryKeys = listOf (
184+ summary1,
185+ summary2,
186+ summary3,
187+ summary4,
188+ summary5,
189+ summary6,
190+ summary7
191+ )
192+
193+ val displayNames = listOf (
194+ displayName1,
195+ displayName2,
196+ displayName3,
197+ displayName4,
198+ displayName5,
199+ displayName6,
200+ displayName7
201+ )
202+
203+ val methodNames = listOf (
204+ methodName1,
205+ methodName2,
206+ methodName3,
207+ methodName4,
208+ methodName5,
209+ methodName6,
210+ methodName7
211+ )
212+
213+ check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames)
214+ }
79215}
0 commit comments