forked from jdevillard/JmesPath.Net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJmesPathArithmeticExpressionTest.cs
26 lines (23 loc) · 1.43 KB
/
JmesPathArithmeticExpressionTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using DevLab.JmesPath;
using Xunit;
namespace jmespath.net.tests.Expressions
{
public class JmesPathArithmeticExpressionTest : JmesPathExpressionsTestBase
{
[Theory]
[InlineData("foo - bar", "{\"foo\": 44, \"bar\": 2}", "42.0")] // U+002D HYPHEN-MINUS
[InlineData("foo − bar", "{\"foo\": 44, \"bar\": 2}", "42.0")] // U+2212 MINUS SIGN
[InlineData("foo * bar", "{\"foo\": 40, \"bar\": 2}", "80.0")]
[InlineData("foo × bar", "{\"foo\": 40, \"bar\": 2}", "80.0")]
[InlineData("foo / bar", "{\"foo\": 40, \"bar\": 2}", "20.0")]
[InlineData("foo ÷ bar", "{\"foo\": 40, \"bar\": 2}", "20.0")]
[InlineData("foo % bar", "{\"foo\": 40, \"bar\": 3}", "1.0")]
[InlineData("foo // bar", "{\"foo\": 40, \"bar\": 3}", "13.0")]
[InlineData("a.b + c.d", "{ \"a\": { \"b\": 1 }, \"c\": { \"d\": 2 } }", "3.0")]
[InlineData("{ ab: a.b, cd: c.d } | ab + cd", "{ \"a\": { \"b\": 1 }, \"c\": { \"d\": 2 } }", "3.0")]
[InlineData("{ ab: a.b, cd: c.d } | ab + cd × cd", "{ \"a\": { \"b\": 1 }, \"c\": { \"d\": 2 } }", "5.0")]
[InlineData("{ ab: a.b, cd: c.d } | (ab + cd) × cd", "{ \"a\": { \"b\": 1 }, \"c\": { \"d\": 2 } }", "6.0")]
public void JmesPathArithmeticExpression_Transform(string expression, string document, string expected)
=> Assert(new JmesPath().Parse(expression), document, expected);
}
}