Ignore:
Timestamp:
02/28/19 14:34:17 (2 years ago)
Author:
gkronber
Message:

#2966: fixed calculation for intervals of Sqr, Sqrt, Cube, CubeRoot

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis-3.4/IntervalTest.cs

    r16407 r16631  
    11using System;
    2 using HeuristicLab.Problems.DataAnalysis;
    32using Microsoft.VisualStudio.TestTools.UnitTesting;
    43
     
    124123      Assert.AreEqual<Interval>(new Interval(1, Math.Exp(1)), Interval.Exponential(new Interval(0, 1)));
    125124    }
     125
     126
     127    [TestMethod]
     128    [TestCategory("Problems.DataAnalysis")]
     129    [TestProperty("Time", "short")]
     130    public void TestIntervalSqrOperator() {
     131      Assert.AreEqual<Interval>(new Interval(1, 4), Interval.Square(new Interval(1, 2)));
     132      Assert.AreEqual<Interval>(new Interval(1, 4), Interval.Square(new Interval(-2, -1)));
     133      Assert.AreEqual<Interval>(new Interval(0, 4), Interval.Square(new Interval(-2, 2)));
     134    }
     135
     136    [TestMethod]
     137    [TestCategory("Problems.DataAnalysis")]
     138    [TestProperty("Time", "short")]
     139    public void TestIntervalSqrtOperator() {
     140      Assert.AreEqual<Interval>(new Interval(1, 2), Interval.SquareRoot(new Interval(1, 4)));
     141      Assert.AreEqual<Interval>(new Interval(double.NaN, double.NaN), Interval.SquareRoot(new Interval(-4, -1)));
     142    }
     143
     144    [TestMethod]
     145    [TestCategory("Problems.DataAnalysis")]
     146    [TestProperty("Time", "short")]
     147    public void TestIntervalCubeOperator() {
     148      Assert.AreEqual<Interval>(new Interval(1, 8), Interval.Cube(new Interval(1, 2)));
     149      Assert.AreEqual<Interval>(new Interval(-8, -1), Interval.Cube(new Interval(-2, -1)));
     150      Assert.AreEqual<Interval>(new Interval(-8, 8), Interval.Cube(new Interval(-2, 2)));
     151    }
     152
     153    [TestMethod]
     154    [TestCategory("Problems.DataAnalysis")]
     155    [TestProperty("Time", "short")]
     156    public void TestIntervalCbrtOperator() {
     157      Assert.AreEqual<Interval>(new Interval(1, 2), Interval.CubicRoot(new Interval(1, 8)));
     158      Assert.AreEqual<Interval>(new Interval(double.NaN, double.NaN), Interval.CubicRoot(new Interval(-8, -1)));
     159    }
    126160  }
    127161}
Note: See TracChangeset for help on using the changeset viewer.