SummaryStatistics implements StatisticalSummary, Serializable { @Override public String toString() { StringBuilder outBuffer = new StringBuilder(); String endl = "\n"; outBuffer.append("SummaryStatistics:").append(endl); outBuffer.append("n: ").append(getN()).append(endl); outBuffer.append("min: ").append(getMin()).append(endl); outBuffer.append("max: ").append(getMax()).append(endl); outBuffer.append("sum: ").append(getSum()).append(endl); outBuffer.append("mean: ").append(getMean()).append(endl); outBuffer.append("geometric mean: ").append(getGeometricMean()) .append(endl); outBuffer.append("variance: ").append(getVariance()).append(endl); outBuffer.append("population variance: ").append(getPopulationVariance()).append(endl); outBuffer.append("second moment: ").append(getSecondMoment()).append(endl); outBuffer.append("sum of squares: ").append(getSumsq()).append(endl); outBuffer.append("standard deviation: ").append(getStandardDeviation()) .append(endl); outBuffer.append("sum of logs: ").append(getSumOfLogs()).append(endl); return outBuffer.toString(); } SummaryStatistics();  SummaryStatistics(SummaryStatistics original); StatisticalSummary getSummary(); void addValue(double value); long getN(); double getSum(); double getSumsq(); double getMean(); double getStandardDeviation(); double getVariance(); double getPopulationVariance(); double getMax(); double getMin(); double getGeometricMean(); double getSumOfLogs(); double getSecondMoment(); @Override String toString(); void clear(); @Override boolean equals(Object object); @Override int hashCode(); StorelessUnivariateStatistic getSumImpl(); void setSumImpl(StorelessUnivariateStatistic sumImpl); StorelessUnivariateStatistic getSumsqImpl(); void setSumsqImpl(StorelessUnivariateStatistic sumsqImpl); StorelessUnivariateStatistic getMinImpl(); void setMinImpl(StorelessUnivariateStatistic minImpl); StorelessUnivariateStatistic getMaxImpl(); void setMaxImpl(StorelessUnivariateStatistic maxImpl); StorelessUnivariateStatistic getSumLogImpl(); void setSumLogImpl(StorelessUnivariateStatistic sumLogImpl); StorelessUnivariateStatistic getGeoMeanImpl(); void setGeoMeanImpl(StorelessUnivariateStatistic geoMeanImpl); StorelessUnivariateStatistic getMeanImpl(); void setMeanImpl(StorelessUnivariateStatistic meanImpl); StorelessUnivariateStatistic getVarianceImpl(); void setVarianceImpl(StorelessUnivariateStatistic varianceImpl); SummaryStatistics copy(); static void copy(SummaryStatistics source, SummaryStatistics dest);  }
@Test public void testToString() { SummaryStatistics u = createSummaryStatistics(); for (int i = 0; i < 5; i++) { u.addValue(i); } final String[] labels = {"min", "max", "sum", "geometric mean", "variance", "population variance", "second moment", "sum of squares", "standard deviation", "sum of logs"}; final double[] values = {u.getMin(), u.getMax(), u.getSum(), u.getGeometricMean(), u.getVariance(), u.getPopulationVariance(), u.getSecondMoment(), u.getSumsq(), u.getStandardDeviation(), u.getSumOfLogs()}; final String toString = u.toString(); Assert.assertTrue(toString.indexOf("n: " + u.getN()) > 0); for (int i = 0; i < values.length; i++) { Assert.assertTrue(toString.indexOf(labels[i] + ": " + String.valueOf(values[i])) > 0); } }