annotate jvmci/com.oracle.jvmci.debug.test/src/com/oracle/jvmci/debug/test/DebugHistogramTest.java @ 21798:395ac43a8578

moved JVMCI sources from graal/ to jvmci/ directory
author Doug Simon <doug.simon@oracle.com>
date Tue, 09 Jun 2015 00:22:49 +0200
parents graal/com.oracle.jvmci.debug.test/src/com/oracle/jvmci/debug/test/DebugHistogramTest.java@f5b549811bac
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9103
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2013, 2013, Oracle and/or its affiliates. All rights reserved.
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
21554
b1530a6cce8c renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 17348
diff changeset
23 package com.oracle.jvmci.debug.test;
9103
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
25 import java.io.*;
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
26
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
27 import org.junit.*;
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
28
21554
b1530a6cce8c renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 17348
diff changeset
29 import com.oracle.jvmci.debug.*;
b1530a6cce8c renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 17348
diff changeset
30 import com.oracle.jvmci.debug.internal.*;
b1530a6cce8c renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 17348
diff changeset
31
9103
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32 public class DebugHistogramTest {
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
33
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34 @Test
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35 public void testEmptyHistogram() {
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36 DebugHistogram histogram = Debug.createHistogram("TestHistogram");
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
37 ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
11552
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
38
11551
63b4694d3627 split DebugHistogram printing out into separate service
Doug Simon <doug.simon@oracle.com>
parents: 9104
diff changeset
39 new DebugHistogramAsciiPrinter(new PrintStream(outputStream)).print(histogram);
17348
0ba1a6745070 unittest: fix newline issue on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15954
diff changeset
40 String line = outputStream.toString().split("\r?\n")[0];
0ba1a6745070 unittest: fix newline issue on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15954
diff changeset
41 Assert.assertEquals("TestHistogram is empty.", line);
11552
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
42
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
43 outputStream.reset();
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
44 new DebugHistogramRPrinter(new PrintStream(outputStream)).print(histogram);
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
45 Assert.assertEquals("", outputStream.toString());
9103
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
46 }
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
47
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
48 @Test
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
49 public void testSingleEntryHistogram() {
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50 DebugHistogram histogram = Debug.createHistogram("TestHistogram");
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
51 ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
52 histogram.add(new Integer(1));
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
53 histogram.add(new Integer(1));
11551
63b4694d3627 split DebugHistogram printing out into separate service
Doug Simon <doug.simon@oracle.com>
parents: 9104
diff changeset
54 new DebugHistogramAsciiPrinter(new PrintStream(outputStream)).print(histogram);
17348
0ba1a6745070 unittest: fix newline issue on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15954
diff changeset
55 String[] lines = outputStream.toString().split("\r?\n");
11552
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
56 // @formatter:off
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
57 String[] expected = {
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
58 "TestHistogram has 1 unique elements and 2 total elements:",
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
59 "--------------------------------------------------------------------------------------------------------------------------------------------------------------------------",
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
60 "| 1 | 2 | ==================================================================================================== |",
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
61 "--------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
62 };
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
63 // @formatter:on
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
64 Assert.assertArrayEquals(expected, lines);
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
65
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
66 outputStream.reset();
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
67 new DebugHistogramRPrinter(new PrintStream(outputStream)).print(histogram);
17348
0ba1a6745070 unittest: fix newline issue on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15954
diff changeset
68 lines = outputStream.toString().split("\r?\n");
11552
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
69 // @formatter:off
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
70 expected = new String[] {
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
71 "TestHistogram <- c(2);",
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
72 "names(TestHistogram) <- c(\"1\");"
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
73 };
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
74 // @formatter:on
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
75 Assert.assertArrayEquals(expected, lines);
9103
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
76 }
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
77
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
78 @Test
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
79 public void testMultipleEntryHistogram() {
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
80 DebugHistogram histogram = Debug.createHistogram("TestHistogram");
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
81 ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
82 histogram.add(new Integer(1));
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
83 histogram.add(new Integer(2));
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
84 histogram.add(new Integer(2));
11551
63b4694d3627 split DebugHistogram printing out into separate service
Doug Simon <doug.simon@oracle.com>
parents: 9104
diff changeset
85 new DebugHistogramAsciiPrinter(new PrintStream(outputStream)).print(histogram);
17348
0ba1a6745070 unittest: fix newline issue on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15954
diff changeset
86 String[] lines = outputStream.toString().split("\r?\n");
11552
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
87 // @formatter:off
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
88 String[] expected = new String[] {
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
89 "TestHistogram has 2 unique elements and 3 total elements:",
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
90 "--------------------------------------------------------------------------------------------------------------------------------------------------------------------------",
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
91 "| 2 | 2 | ==================================================================================================== |",
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
92 "| 1 | 1 | ================================================== |",
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
93 "--------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
94 };
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
95 // @formatter:on
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
96 Assert.assertArrayEquals(expected, lines);
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
97
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
98 outputStream.reset();
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
99 new DebugHistogramRPrinter(new PrintStream(outputStream)).print(histogram);
17348
0ba1a6745070 unittest: fix newline issue on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15954
diff changeset
100 lines = outputStream.toString().split("\r?\n");
11552
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
101 // @formatter:off
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
102 expected = new String[] {
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
103 "TestHistogram <- c(2, 1);",
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
104 "names(TestHistogram) <- c(\"2\", \"1\");"
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
105 };
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
106 // @formatter:on
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
107 Assert.assertArrayEquals(expected, lines);
9103
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
108 }
9104
3495149b9531 Added support for trimming the name of objects in the histogram and a corresponding test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9103
diff changeset
109
3495149b9531 Added support for trimming the name of objects in the histogram and a corresponding test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9103
diff changeset
110 @Test
3495149b9531 Added support for trimming the name of objects in the histogram and a corresponding test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9103
diff changeset
111 public void testTooLongValueString() {
3495149b9531 Added support for trimming the name of objects in the histogram and a corresponding test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9103
diff changeset
112 DebugHistogram histogram = Debug.createHistogram("TestHistogram");
3495149b9531 Added support for trimming the name of objects in the histogram and a corresponding test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9103
diff changeset
113 ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
3495149b9531 Added support for trimming the name of objects in the histogram and a corresponding test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9103
diff changeset
114 histogram.add("MyCustomValue");
15954
cda2a7d1dcff long values and scale on DebugHistogram
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11552
diff changeset
115 new DebugHistogramAsciiPrinter(new PrintStream(outputStream), Integer.MAX_VALUE, 10, 10, 1).print(histogram);
17348
0ba1a6745070 unittest: fix newline issue on windows
Bernhard Urban <bernhard.urban@jku.at>
parents: 15954
diff changeset
116 String[] lines = outputStream.toString().split("\r?\n");
9104
3495149b9531 Added support for trimming the name of objects in the histogram and a corresponding test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9103
diff changeset
117 Assert.assertEquals(4, lines.length);
3495149b9531 Added support for trimming the name of objects in the histogram and a corresponding test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9103
diff changeset
118 Assert.assertEquals("TestHistogram has 1 unique elements and 1 total elements:", lines[0]);
3495149b9531 Added support for trimming the name of objects in the histogram and a corresponding test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9103
diff changeset
119 Assert.assertEquals("----------------------------------------", lines[1]);
3495149b9531 Added support for trimming the name of objects in the histogram and a corresponding test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9103
diff changeset
120 Assert.assertEquals("| MyCusto... | 1 | ========== |", lines[2]);
3495149b9531 Added support for trimming the name of objects in the histogram and a corresponding test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9103
diff changeset
121 Assert.assertEquals("----------------------------------------", lines[3]);
3495149b9531 Added support for trimming the name of objects in the histogram and a corresponding test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9103
diff changeset
122 }
9103
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
123 }