Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arithmetic predicates for number (Integer or Float) #95

Closed
fabricereix opened this issue Nov 26, 2020 · 2 comments
Closed

Arithmetic predicates for number (Integer or Float) #95

fabricereix opened this issue Nov 26, 2020 · 2 comments
Labels
enhancement New feature or request
Milestone

Comments

@fabricereix
Copy link
Collaborator

Predicates with numbers such as (equals, greaterThan, ...) are "arithmetic".

For example:
for the following json response

{
    "count": 5,
    "total": 50.0
}

All the following asserts are valid

jsonpath "$.count" equals 5
jsonpath "$.count" equals 5.0
jsonpath "$.count" greaterThan 1
jsonpath "$.count" greaterThan 1.0
jsonpath "$.total" equals 50
jsonpath "$.total" equals 50.0
jsonpath "$.total" greaterThan 0.2
jsonpath "$.total" greaterThan 0

The value type can be checked with an additional predicate

jsonpath "$.count" isInteger
jsonpath "$.total" isFloat

Additional:

The intent for the following assert might not be clear:
jsonpath "$.count" equals 5.0
Do we expect a float value?

In this case, Hurl could emit a warning like:
"You expected value should be replaced by an integer value"

@fabricereix fabricereix added the enhancement New feature or request label Nov 26, 2020
@lepapareil
Copy link
Collaborator

👍

@fabricereix
Copy link
Collaborator Author

implemented in #99

@lepapareil lepapareil added this to the 1.0.0 milestone Jun 11, 2021
@lepapareil lepapareil removed the 1.0.0 label Oct 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants