Exemplo n.º 1
0
  @Test
  public void testAllStub() throws FileNotFoundException, UnsupportedEncodingException {
    MyExpression expression = new MyExpression();
    for (Interval i : intervals) {
      for (double x = i.getX0(); x <= i.getX1(); x += i.getD())
        assertEquals(pow(2.0, 6.0) + 1, expression.calc(x), 0.01);
    }

    Plotter.plot("/Users/Scotch/graph_all_stub.csv", expression, intervals);
  }
Exemplo n.º 2
0
 @Test
 public void cotangens() throws FileNotFoundException, UnsupportedEncodingException {
   MyExpression expression = new MyExpression();
   expression.cot = new Cot();
   for (Interval i : intervals) {
     for (double x = i.getX0(); x <= i.getX1(); x += i.getD())
       assertEquals(((((pow(2, 2.0 * 3.0) - (-1) * (1 / tan(x)))))), expression.calc(x), 0.01);
   }
   Plotter.plot("/Users/Scotch/graph_ctg.csv", expression, intervals);
 }
Exemplo n.º 3
0
 /** Синус - заменим все функции кроме косеканса на заглушки и будем тестировать только его */
 @Test
 public void sinus() throws FileNotFoundException, UnsupportedEncodingException {
   MyExpression expression = new MyExpression();
   expression.sin = new Sin();
   for (Interval i : intervals) {
     for (double x = i.getX0(); x <= i.getX1(); x += i.getD())
       assertEquals(
           ((((pow(1 + 1, 2.0 * 3.0) - ((sin(x) - 1) - 1) * (1))))), expression.calc(x), 0.01);
   }
   Plotter.plot("/Users/Scotch/graph_sin.csv", expression, intervals);
 }
Exemplo n.º 4
0
 /** Косеканс - заменим все функции кроме косеканса на заглушки и будем тестировать только его */
 @Test
 public void cosec() throws FileNotFoundException, UnsupportedEncodingException {
   MyExpression expression = new MyExpression();
   expression.csc = new Cosecant();
   for (Interval i : intervals) {
     for (double x = i.getX0(); x <= i.getX1(); x += i.getD()) {
       System.out.printf(" x = %.1f%n", x);
       assertEquals(pow(1.0 + 1 / sin(x), 6.0) - (-1), expression.calc(x), 0.01);
     }
   }
   Plotter.plot("/Users/Scotch/graph_csc.csv", expression, intervals);
 }
Exemplo n.º 5
0
  @Test
  public void testAllReal() throws FileNotFoundException, UnsupportedEncodingException {
    MyExpression expression = new MyExpression();
    expression.cos = new Cos();
    expression.sin = new Sin();
    expression.cot = new Cot();
    expression.tan = new Tg();
    expression.csc = new Cosecant();
    for (Interval i : intervals) {
      for (double x = i.getX0(); x <= i.getX1(); x += i.getD())
        assertEquals(
            ((((pow(cos(x) + csc(x), 2.0 * 3.0)
                - ((sin(x) - tan(x)) - cos(x)) * (cot(x) * tan(x)))))),
            expression.calc(x),
            0.01);
    }

    Plotter.plot("/Users/Scotch/graph_all_real.csv", expression, intervals);
  }