Changeset 16744 for branches/2994-AutoDiffForIntervals/Tests
- Timestamp:
- 04/02/19 13:55:49 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2994-AutoDiffForIntervals/Tests/AutoDiffTest.cs
r16738 r16744 107 107 108 108 { 109 // Interval tests 110 var intervals = new Dictionary<string, Interval>(); 111 intervals.Add("x", new Interval(-2.0, 3.0)); 112 intervals.Add("p", new Interval(1.0, 2.0)); 113 intervals.Add("n", new Interval(-2.0, -1.0)); 114 115 AssertInterval("10*x", intervals, -20, 30); 116 AssertInterval("sqr(p)", intervals, 1, 4); 117 AssertInterval("sqr(n)", intervals, 1, 4); 118 AssertInterval("sqr(x)", intervals, 0, 9); 119 120 AssertInterval("cube(p)", intervals, 1, 8); 121 AssertInterval("cube(n)", intervals, -8, -1); 122 AssertInterval("cube(x)", intervals, -8, 27); 123 } 124 125 { 109 126 // interval eval and auto-diff 110 127 var parser = new InfixExpressionParser(); … … 226 243 227 244 } 245 246 private void AssertInterval(string expression, Dictionary<string, Interval> intervals, double expectedLow, double expectedHigh) { 247 var parser = new InfixExpressionParser(); 248 var t = parser.Parse(expression); 249 var evaluator = new IntervalEvaluator(); 250 var result = evaluator.Evaluate(t, intervals); 251 Assert.AreEqual(expectedLow, result.LowerBound); 252 Assert.AreEqual(expectedHigh, result.UpperBound); 253 } 228 254 } 229 255 }
Note: See TracChangeset
for help on using the changeset viewer.