Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.utils / src / test / java / org / gvsig / utils / TestMathExtension.java @ 40561

History | View | Annotate | Download (3.71 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.utils;
25

    
26
import org.gvsig.utils.MathExtension;
27
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
28
 *
29
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
30
 *
31
 * This program is free software; you can redistribute it and/or
32
 * modify it under the terms of the GNU General Public License
33
 * as published by the Free Software Foundation; either version 2
34
 * of the License, or (at your option) any later version.
35
 *
36
 * This program is distributed in the hope that it will be useful,
37
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
38
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
39
 * GNU General Public License for more details.
40
 *
41
 * You should have received a copy of the GNU General Public License
42
 * along with this program; if not, write to the Free Software
43
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
44
 *
45
 * For more information, contact:
46
 *
47
 *  Generalitat Valenciana
48
 *   Conselleria d'Infraestructures i Transport
49
 *   Av. Blasco Ib??ez, 50
50
 *   46010 VALENCIA
51
 *   SPAIN
52
 *
53
 *      +34 963862235
54
 *   gvsig@gva.es
55
 *      www.gvsig.gva.es
56
 *
57
 *    or
58
 *
59
 *   IVER T.I. S.A
60
 *   Salamanca 50
61
 *   46005 Valencia
62
 *   Spain
63
 *
64
 *   +34 963163400
65
 *   dac@iver.es
66
 */
67

    
68
/**
69
 * Tests for the MathExtension class
70
 * 
71
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
72
 */
73
public class TestMathExtension {
74
        /**
75
         * Test method for the TestMathExtension class
76
         * 
77
         * @param args
78
         */
79
        public static void main(String[] args)
80
        {
81
                // Test 1
82
                System.out.println("Test 1 -> log2(1)");
83
                showResultState(0, MathExtension.log2(1), 1);
84

    
85
                // Test 2
86
                System.out.println("Test 2 -> log2(16)");
87
                showResultState(4, MathExtension.log2(16), 2);
88

    
89
                // Test 3
90
                System.out.println("Test 3 -> log2Integer(15)");
91
                showResultState(3, MathExtension.log2Integer(15), 3);
92
                
93
                // Test 4
94
                System.out.println("Test 4 -> log2Integer(64)");
95
                showResultState(6, MathExtension.log2Integer(64), 4);
96
                
97
                // Test 5
98
                System.out.println("Test 5 -> logX(e2, e6)");
99
                showResultState(3, MathExtension.logX(Math.pow(Math.E, 2), Math.pow(Math.E, 6)), 5);
100
                
101
                // Test 6
102
                System.out.println("Test 6 -> logXInteger(5, 137.43)");
103
                showResultState(3, MathExtension.logXInteger(5, 137.43), 6);
104

    
105
                
106
                // There might be more tests
107
                
108
        }
109
        
110
        /**
111
         * Indicates if the result of the current test has been successfull or not
112
         * 
113
         * @param correct The correct result
114
         * @param result The result of the operation
115
         * @param testNumber The numer of the current test
116
         */
117
        private static void showResultState(double correct, double result, int testNumber) {
118
                if (correct == result)
119
                        System.out.println("Test " + testNumber + " OK    (Result: " + result + ")");
120
                else
121
                        System.out.println("Test " + testNumber + " FAILED    (Result: " + result + ")");
122
        }
123
}