Additional coverage to CounterTest
Change-Id: I861a93a83612e612619562106282dee50787b400
diff --git a/utils/misc/src/test/java/org/onlab/util/CounterTest.java b/utils/misc/src/test/java/org/onlab/util/CounterTest.java
index cb085bb..124a571 100644
--- a/utils/misc/src/test/java/org/onlab/util/CounterTest.java
+++ b/utils/misc/src/test/java/org/onlab/util/CounterTest.java
@@ -17,6 +17,8 @@
import org.junit.Test;
+import com.google.common.testing.EqualsTester;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.onlab.junit.TestTools.delay;
@@ -81,4 +83,28 @@
assertEquals("incorrect duration", 1, tt.duration(), 0.1);
assertEquals("incorrect throughput", 1000, tt.throughput(), 1.0);
}
+
+ @Test
+ public void equals() {
+ long start = 100L;
+ long total = 300L;
+ long end = 200L;
+ Counter tt = new Counter(start, total, end);
+ Counter same = new Counter(start, total, end);
+ Counter diff = new Counter(300L, 700L, 400L);
+ new EqualsTester()
+ .addEqualityGroup(tt, same)
+ .addEqualityGroup(400)
+ .addEqualityGroup("")
+ .addEqualityGroup(diff);
+
+ }
+
+ @Test
+ public void toStringTest() {
+ Counter tt = new Counter(100L, 300L, 200L);
+ assertEquals("Counter{total=300, start=100, end=200}", tt.toString());
+ Counter another = new Counter(200L, 500L, 300L);
+ assertEquals("Counter{total=500, start=200, end=300}", another.toString());
+ }
}