| 1 | /* |
| 2 | * MDSTest.java |
| 3 | * |
| 4 | * Copyright (c) 2002-2014 Alexei Drummond, Andrew Rambaut and Marc Suchard |
| 5 | * |
| 6 | * This file is part of BEAST. |
| 7 | * See the NOTICE file distributed with this work for additional |
| 8 | * information regarding copyright ownership and licensing. |
| 9 | * |
| 10 | * BEAST is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU Lesser General Public License as |
| 12 | * published by the Free Software Foundation; either version 2 |
| 13 | * of the License, or (at your option) any later version. |
| 14 | * |
| 15 | * BEAST is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU Lesser General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU Lesser General Public |
| 21 | * License along with BEAST; if not, write to the |
| 22 | * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, |
| 23 | * Boston, MA 02110-1301 USA |
| 24 | */ |
| 25 | |
| 26 | package test.dr.multidimensionalscaling; |
| 27 | |
| 28 | import dr.inference.multidimensionalscaling.NativeMDSSingleton; |
| 29 | import test.dr.math.MathTestCase; |
| 30 | |
| 31 | /** |
| 32 | * @author Marc A. Suchard |
| 33 | * @author Andrew Rambaut |
| 34 | */ |
| 35 | public class MDSTest extends MathTestCase { |
| 36 | |
| 37 | private static NativeMDSSingleton mds = loadLibrary(); |
| 38 | |
| 39 | private static NativeMDSSingleton loadLibrary() { |
| 40 | try { |
| 41 | return NativeMDSSingleton.loadLibrary(); |
| 42 | } catch (UnsatisfiedLinkError error) { |
| 43 | System.err.println("Unable to load MDS library; no trying tests"); |
| 44 | return null; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | public void testInitialization() { |
| 49 | if (mds != null) { |
| 50 | int i = mds.initialize(2, 100, 0); |
| 51 | assertEquals(i, 0); |
| 52 | i = mds.initialize(2, 100, 0); |
| 53 | assertEquals(i, 1); |
| 54 | } else { |
| 55 | System.out.println("testInitialization skipped"); |
| 56 | } |
| 57 | |
| 58 | } |
| 59 | |
| 60 | public void testMakeDirty() { |
| 61 | if (mds != null) { |
| 62 | mds.makeDirty(0); |
| 63 | } else { |
| 64 | System.out.println("testMakeDirty skipped"); |
| 65 | } |
| 66 | |
| 67 | } |
| 68 | |
| 69 | |
| 70 | } |