Mercurial > hg > truffle
annotate graal/com.oracle.jvmci.debug.test/src/com/oracle/jvmci/debug/test/DebugHistogramTest.java @ 21554:b1530a6cce8c
renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 26 May 2015 23:21:15 +0200 |
parents | graal/com.oracle.graal.debug.test/src/com/oracle/graal/debug/test/DebugHistogramTest.java@0ba1a6745070 |
children | f5b549811bac |
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 |
e7541d478e38
Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
33 public class DebugHistogramTest { |
e7541d478e38
Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
34 |
e7541d478e38
Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
35 @Test |
e7541d478e38
Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
36 public void testEmptyHistogram() { |
e7541d478e38
Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
37 DebugHistogram histogram = Debug.createHistogram("TestHistogram"); |
e7541d478e38
Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
38 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
|
39 |
11551
63b4694d3627
split DebugHistogram printing out into separate service
Doug Simon <doug.simon@oracle.com>
parents:
9104
diff
changeset
|
40 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
|
41 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
|
42 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
|
43 |
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 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
|
45 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
|
46 Assert.assertEquals("", outputStream.toString()); |
9103
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 |
e7541d478e38
Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 @Test |
e7541d478e38
Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
50 public void testSingleEntryHistogram() { |
e7541d478e38
Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 DebugHistogram histogram = Debug.createHistogram("TestHistogram"); |
e7541d478e38
Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
e7541d478e38
Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 histogram.add(new Integer(1)); |
e7541d478e38
Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
54 histogram.add(new Integer(1)); |
11551
63b4694d3627
split DebugHistogram printing out into separate service
Doug Simon <doug.simon@oracle.com>
parents:
9104
diff
changeset
|
55 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
|
56 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
|
57 // @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
|
58 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
|
59 "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
|
60 "--------------------------------------------------------------------------------------------------------------------------------------------------------------------------", |
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 "| 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
|
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 }; |
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 // @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
|
65 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
|
66 |
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 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
|
68 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
|
69 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
|
70 // @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
|
71 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
|
72 "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
|
73 "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
|
74 }; |
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 // @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
|
76 Assert.assertArrayEquals(expected, lines); |
9103
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 |
e7541d478e38
Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
79 @Test |
e7541d478e38
Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
80 public void testMultipleEntryHistogram() { |
e7541d478e38
Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
81 DebugHistogram histogram = Debug.createHistogram("TestHistogram"); |
e7541d478e38
Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
82 ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
e7541d478e38
Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
83 histogram.add(new Integer(1)); |
e7541d478e38
Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
84 histogram.add(new Integer(2)); |
e7541d478e38
Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
85 histogram.add(new Integer(2)); |
11551
63b4694d3627
split DebugHistogram printing out into separate service
Doug Simon <doug.simon@oracle.com>
parents:
9104
diff
changeset
|
86 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
|
87 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
|
88 // @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
|
89 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
|
90 "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
|
91 "--------------------------------------------------------------------------------------------------------------------------------------------------------------------------", |
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 "| 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
|
93 "| 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
|
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 }; |
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 // @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
|
97 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
|
98 |
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 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
|
100 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
|
101 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
|
102 // @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
|
103 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
|
104 "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 "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
|
106 }; |
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 // @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
|
108 Assert.assertArrayEquals(expected, lines); |
9103
e7541d478e38
Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
109 } |
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
|
110 |
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 @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
|
112 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
|
113 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
|
114 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
|
115 histogram.add("MyCustomValue"); |
15954
cda2a7d1dcff
long values and scale on DebugHistogram
Lukas Stadler <lukas.stadler@oracle.com>
parents:
11552
diff
changeset
|
116 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
|
117 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
|
118 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
|
119 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
|
120 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
|
121 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
|
122 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
|
123 } |
9103
e7541d478e38
Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
124 } |