3c5e22d1a91b398372e67b9a0448f49d0534d839
1 package org
.eclipse
.linuxtools
.tmf
.ui
.tests
.statistics
;
3 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.statistics
.model
.TmfStatistics
;
5 import junit
.framework
.TestCase
;
8 * TmfStatistics Test Cases.
10 public class TmfStatisticsTest
extends TestCase
{
12 // ------------------------------------------------------------------------
14 // ------------------------------------------------------------------------
16 TmfStatistics stats
= new TmfStatistics();
18 // ------------------------------------------------------------------------
19 // Checks initial state
20 // ------------------------------------------------------------------------
23 * Test the initial state of the counters
25 public void testInitialState() {
26 assertEquals(0, stats
.getTotal());
27 assertEquals(0, stats
.getPartial());
30 // ------------------------------------------------------------------------
31 // Increment Total no parameter
32 // ------------------------------------------------------------------------
35 * Test incrementing the total counter
37 public void testIncrementTotal() {
38 for (int i
= 1; i
< 10; ++i
) {
39 stats
.incrementTotal();
40 assertEquals(i
, stats
.getTotal());
42 // Checks if the partial counter was affected
43 assertEquals(0, stats
.getPartial());
47 * Test incrementing the total counter by an amount
49 public void testIncrementTotal1Arg() {
50 int i
= 1, expected
= 0;
51 while (expected
< 100) {
53 stats
.incrementTotal(i
);
54 assertEquals(expected
, stats
.getTotal());
57 // Increment by a negative number do nothing
58 stats
.incrementTotal(-10);
59 assertEquals(expected
, stats
.getTotal());
61 // Checks if the partial counter was affected
62 assertEquals(0, stats
.getPartial());
66 * Test incrementing the partial counter
68 public void testIncrementPartial() {
69 for (int i
= 1; i
< 10; ++i
) {
70 stats
.incrementPartial();
71 assertEquals(i
, stats
.getPartial());
73 // Checks if the total counter was affected
74 assertEquals(0, stats
.getTotal());
78 * Test incrementing the partial counter by a certain amount
80 public void testIncrementPartial1Arg() {
81 int i
= 1, expected
= 0;
82 while (expected
< 100) {
84 stats
.incrementPartial(i
);
85 assertEquals(expected
, stats
.getPartial());
88 // Increment by a negative number. It should do nothing.
89 stats
.incrementPartial(-10);
90 assertEquals(expected
, stats
.getPartial());
92 // Checks if the total counter was affected
93 assertEquals(0, stats
.getTotal());
97 * Test of the reset for the total counter
99 public void testResetTotal() {
100 stats
.incrementTotal(123);
101 assertEquals(123, stats
.getTotal());
103 stats
.resetTotalCount();
104 assertEquals(0, stats
.getTotal());
106 // test when already at 0
107 stats
.resetTotalCount();
108 assertEquals(0, stats
.getTotal());
110 // The counters should still be in a usable state
111 stats
.incrementPartial();
112 stats
.incrementPartial(3);
113 assertEquals(4, stats
.getPartial());
115 stats
.incrementTotal();
116 stats
.incrementTotal(2);
117 assertEquals(3, stats
.getTotal());
121 * Test of the reset for the partial counter
123 public void testResetPartial() {
124 stats
.incrementPartial(456);
125 assertEquals(456, stats
.getPartial());
127 stats
.resetPartialCount();
128 assertEquals(0, stats
.getPartial());
130 // test when already at 0
131 stats
.resetPartialCount();
132 assertEquals(0, stats
.getPartial());
134 // The counters should still be in a usable state
135 stats
.incrementPartial();
136 stats
.incrementPartial(2);
137 assertEquals(3, stats
.getPartial());
139 stats
.incrementTotal();
140 stats
.incrementTotal(3);
141 assertEquals(4, stats
.getTotal());
This page took 0.034313 seconds and 4 git commands to generate.