Skip to content

Commit

Permalink
Add a test to reveal a bug with add_if and scientific notation
Browse files Browse the repository at this point in the history
There error returned is:
"Cannot transition token types from NUMERIC [1.2345] to VARIABLE [e]"
  • Loading branch information
ronensc committed Mar 7, 2022
1 parent 680ddb3 commit 83d22d7
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions pkg/pipeline/transform/transform_network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,39 @@ parameters:
require.Equal(t, "10.0.0.0/24", output["match-10.0.*"])
require.NotEqual(t, "10.0.0.0/24", output["match-11.0.*"])
}

func Test_Transform_AddIfScientificNotation(t *testing.T) {
newNetworkTransform := Network{
api.TransformNetwork{
Rules: api.NetworkTransformRules{
api.NetworkTransformRule{
Input: "value",
Output: "bigger_than_10",
Type: "add_if",
Parameters: ">10",
},
api.NetworkTransformRule{
Input: "value",
Output: "smaller_than_10",
Type: "add_if",
Parameters: "<10",
},
},
},
}

var entry config.GenericMap
entry = config.GenericMap{
"value": 1.2345e67,
}
output := newNetworkTransform.Transform(entry)
require.Equal(t, true, output["bigger_than_10_Evaluate"])
require.Equal(t, 1.2345e67, output["bigger_than_10"])

entry = config.GenericMap{
"value": 1.2345e-67,
}
output = newNetworkTransform.Transform(entry)
require.Equal(t, true, output["smaller_than_10_Evaluate"])
require.Equal(t, 1.2345e-67, output["smaller_than_10"])
}

0 comments on commit 83d22d7

Please sign in to comment.