(t *testing.T)
| 47 | } |
| 48 | |
| 49 | func TestSubgraphToFastJSON(t *testing.T) { |
| 50 | t.Run("With a string result", func(t *testing.T) { |
| 51 | sg := subgraphWithSingleResultAndSingleValue(task.FromString("ABC")) |
| 52 | assertJSON(t, `{"query":[{"val":"ABC"}]}`, sg) |
| 53 | }) |
| 54 | |
| 55 | t.Run("With an integer result", func(t *testing.T) { |
| 56 | sg := subgraphWithSingleResultAndSingleValue(task.FromInt(42)) |
| 57 | assertJSON(t, `{"query":[{"val":42}]}`, sg) |
| 58 | }) |
| 59 | |
| 60 | t.Run("With a valid float result", func(t *testing.T) { |
| 61 | sg := subgraphWithSingleResultAndSingleValue(task.FromFloat(42.0)) |
| 62 | assertJSON(t, `{"query":[{"val":42}]}`, sg) |
| 63 | }) |
| 64 | |
| 65 | t.Run("With invalid floating points", func(t *testing.T) { |
| 66 | assertJSON(t, `{"query":[]}`, subgraphWithSingleResultAndSingleValue(task.FromFloat(math.NaN()))) |
| 67 | assertJSON(t, `{"query":[]}`, subgraphWithSingleResultAndSingleValue(task.FromFloat(math.Inf(1)))) |
| 68 | }) |
| 69 | } |
| 70 | |
| 71 | func TestEncode(t *testing.T) { |
| 72 | enc := newEncoder() |
nothing calls this directly
no test coverage detected