Skip to content

Commit

Permalink
Added more tests for code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
asafm committed Jan 9, 2024
1 parent 6a124c5 commit 9b0d48e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ void testSanity() {
assertThat(buckets.getBucketCounts()).containsExactly(1L, 2L, 3L);
assertThat(buckets.getReusableBucketCountsList()).containsExactly(1L, 2L, 3L);

assertThat(buckets.toString())
.isEqualTo(
"MutableExponentialHistogramBuckets{scale=1, offset=2, bucketCounts=[1, 2, 3], totalCount=3}");

MutableExponentialHistogramBuckets sameBuckets = new MutableExponentialHistogramBuckets();
sameBuckets.set(1, 2, 3, DynamicPrimitiveLongList.of(1, 2, 3));
assertThat(sameBuckets).isEqualTo(buckets);
assertThat(sameBuckets.hashCode()).isEqualTo(buckets.hashCode());

assertThat(buckets.toString())
.isEqualTo(
"MutableExponentialHistogramBuckets{scale=1, offset=2, bucketCounts=[1, 2, 3], totalCount=3}");
sameBuckets.set(1, 2, 3, DynamicPrimitiveLongList.of(1, 20, 3));
assertThat(sameBuckets).isNotEqualTo(buckets);
assertThat(sameBuckets.hashCode()).isNotEqualTo(buckets.hashCode());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,26 @@ public void testSanity() {
Attributes.of(AttributeKey.stringKey("foo"), "bar"),
Collections.emptyList());
assertThat(samePointData).isEqualTo(pointData);
assertThat(samePointData.hashCode()).isEqualTo(pointData.hashCode());

MutableExponentialHistogramPointData differentPointData =
new MutableExponentialHistogramPointData();
differentPointData.set(
/* scale= */ 1,
/* sum= */ 2,
/* zeroCount= */ 10000000,
/* hasMin= */ true,
/* min= */ 100,
/* hasMax= */ true,
/* max= */ 1000,
positiveBuckets,
negativeBuckets,
/* startEpochNanos= */ 10,
/* epochNanos= */ 20,
Attributes.of(AttributeKey.stringKey("foo"), "bar"),
Collections.emptyList());

assertThat(differentPointData).isNotEqualTo(pointData);
assertThat(differentPointData.hashCode()).isNotEqualTo(pointData.hashCode());
}
}

0 comments on commit 9b0d48e

Please sign in to comment.