|
1 | 1 | package events_test
|
2 | 2 |
|
3 | 3 | import (
|
| 4 | + "math" |
| 5 | + |
4 | 6 | fevents "github.com/cloudfoundry-community/splunk-firehose-nozzle/events"
|
5 | 7 | "github.com/cloudfoundry-community/splunk-firehose-nozzle/testing"
|
6 | 8 | . "github.com/cloudfoundry/sonde-go/events"
|
@@ -88,6 +90,45 @@ var _ = Describe("Events", func() {
|
88 | 90 | Expect(evt.Fields["unit"]).To(Equal(unit))
|
89 | 91 | })
|
90 | 92 |
|
| 93 | + It("ValueMetric NaN", func() { |
| 94 | + msg = NewValueMetric() |
| 95 | + nan := math.NaN() |
| 96 | + msg.ValueMetric.Value = &nan |
| 97 | + evt := fevents.ValueMetric(msg) |
| 98 | + Expect(evt).ToNot(BeNil()) |
| 99 | + Expect(evt.Fields).ToNot(BeNil()) |
| 100 | + Expect(evt.Msg).To(Equal("")) |
| 101 | + Expect(evt.Fields["name"]).To(Equal(name)) |
| 102 | + Expect(evt.Fields["value"]).To(Equal("NaN")) |
| 103 | + Expect(evt.Fields["unit"]).To(Equal(unit)) |
| 104 | + }) |
| 105 | + |
| 106 | + It("ValueMetric +Infinity", func() { |
| 107 | + msg = NewValueMetric() |
| 108 | + inf := math.Inf(1) |
| 109 | + msg.ValueMetric.Value = &inf |
| 110 | + evt := fevents.ValueMetric(msg) |
| 111 | + Expect(evt).ToNot(BeNil()) |
| 112 | + Expect(evt.Fields).ToNot(BeNil()) |
| 113 | + Expect(evt.Msg).To(Equal("")) |
| 114 | + Expect(evt.Fields["name"]).To(Equal(name)) |
| 115 | + Expect(evt.Fields["value"]).To(Equal("Infinity")) |
| 116 | + Expect(evt.Fields["unit"]).To(Equal(unit)) |
| 117 | + }) |
| 118 | + |
| 119 | + It("ValueMetric -Infinity", func() { |
| 120 | + msg = NewValueMetric() |
| 121 | + inf := math.Inf(-1) |
| 122 | + msg.ValueMetric.Value = &inf |
| 123 | + evt := fevents.ValueMetric(msg) |
| 124 | + Expect(evt).ToNot(BeNil()) |
| 125 | + Expect(evt.Fields).ToNot(BeNil()) |
| 126 | + Expect(evt.Msg).To(Equal("")) |
| 127 | + Expect(evt.Fields["name"]).To(Equal(name)) |
| 128 | + Expect(evt.Fields["value"]).To(Equal("-Infinity")) |
| 129 | + Expect(evt.Fields["unit"]).To(Equal(unit)) |
| 130 | + }) |
| 131 | + |
91 | 132 | It("CounterEvent", func() {
|
92 | 133 | msg = NewCounterEvent()
|
93 | 134 | evt := fevents.CounterEvent(msg)
|
|
0 commit comments