diff options
author | Yang Song <songy23@users.noreply.github.com> | 2018-09-17 10:15:15 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-17 10:15:15 -0700 |
commit | 3d98a788798898ca653d3d2ac0aa984410e2a436 (patch) | |
tree | 942887102efbeb0740164b62394da578e247c37f /api/src/test/java/io | |
parent | 5faef17f74e5d8d857b50cc9e66e0f595080c488 (diff) | |
download | opencensus-java-3d98a788798898ca653d3d2ac0aa984410e2a436.tar.gz |
Tracing: Add AttributeValueDouble. (#1442)
Also update Trace exporters and ZPages, and fix a few typos.
Diffstat (limited to 'api/src/test/java/io')
-rw-r--r-- | api/src/test/java/io/opencensus/trace/AttributeValueTest.java | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/api/src/test/java/io/opencensus/trace/AttributeValueTest.java b/api/src/test/java/io/opencensus/trace/AttributeValueTest.java index e505c59b..05ef43c0 100644 --- a/api/src/test/java/io/opencensus/trace/AttributeValueTest.java +++ b/api/src/test/java/io/opencensus/trace/AttributeValueTest.java @@ -124,6 +124,83 @@ public class AttributeValueTest { } @Test + public void doubleAttributeValue() { + AttributeValue attribute = AttributeValue.doubleAttributeValue(1.23456); + attribute.match( + new Function<String, Object>() { + @Override + @Nullable + public Object apply(String stringValue) { + fail("Expected a Double"); + return null; + } + }, + new Function<Boolean, Object>() { + @Override + @Nullable + public Object apply(Boolean booleanValue) { + fail("Expected a Double"); + return null; + } + }, + new Function<Long, Object>() { + @Override + @Nullable + public Object apply(Long longValue) { + fail("Expected a Double"); + return null; + } + }, + new Function<Double, Object>() { + @Override + @Nullable + public Object apply(Double doubleValue) { + assertThat(doubleValue).isEqualTo(1.23456); + return null; + } + }, + Functions.throwIllegalArgumentException()); + } + + @Test + public void doubleAttributeValue_DeprecatedMatchFunction() { + AttributeValue attribute = AttributeValue.doubleAttributeValue(1.23456); + attribute.match( + new Function<String, Object>() { + @Override + @Nullable + public Object apply(String stringValue) { + fail("Expected a Double"); + return null; + } + }, + new Function<Boolean, Object>() { + @Override + @Nullable + public Object apply(Boolean booleanValue) { + fail("Expected a Double"); + return null; + } + }, + new Function<Long, Object>() { + @Override + @Nullable + public Object apply(Long longValue) { + fail("Expected a Double"); + return null; + } + }, + new Function<Object, Object>() { + @Override + @Nullable + public Object apply(Object value) { + assertThat(value).isEqualTo(1.23456); + return null; + } + }); + } + + @Test public void attributeValue_EqualsAndHashCode() { EqualsTester tester = new EqualsTester(); tester.addEqualityGroup( @@ -136,6 +213,9 @@ public class AttributeValueTest { tester.addEqualityGroup( AttributeValue.longAttributeValue(123456L), AttributeValue.longAttributeValue(123456L)); tester.addEqualityGroup(AttributeValue.longAttributeValue(1234567L)); + tester.addEqualityGroup( + AttributeValue.doubleAttributeValue(1.23456), AttributeValue.doubleAttributeValue(1.23456)); + tester.addEqualityGroup(AttributeValue.doubleAttributeValue(1.234567)); tester.testEquals(); } @@ -147,5 +227,7 @@ public class AttributeValueTest { assertThat(attribute.toString()).contains("true"); attribute = AttributeValue.longAttributeValue(123456L); assertThat(attribute.toString()).contains("123456"); + attribute = AttributeValue.doubleAttributeValue(1.23456); + assertThat(attribute.toString()).contains("1.23456"); } } |