jmonkeyengine/engine/test/com/jme/animation/CompactQuaternionArrayTest.java
nor..67 9e53abbb7a move jme3 to trunk
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@6971 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
2011-03-14 12:55:32 +00:00

49 lines
1.5 KiB
Java

package com.jme.animation;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
import com.jme3.animation.CompactQuaternionArray;
import com.jme3.math.Quaternion;
public class CompactQuaternionArrayTest {
@Before
public void setUp() throws Exception {
}
@Test
public void testCompactQuaternionArrayQuaternionArray() {
Quaternion[] objArray = new Quaternion[] {
new Quaternion(1, 0, 1, 1),
new Quaternion(1, 1, 1, 0),
new Quaternion(0, 1, 1, 0),
new Quaternion(1, 1, 1, 0),
new Quaternion(1, 0, 1, 1),
};
CompactQuaternionArray compact = new CompactQuaternionArray();
compact.add(objArray);
assertTrue(Arrays.equals(compact.getIndex(objArray), new int[] {0, 1, 2, 1, 0}));
assertTrue(Arrays.equals(compact.getSerializedData(), new float[] {1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0}));
}
@Test
public void testCompactQuaternionArrayDoubleArrayIntArray() {
int[] indexArray = new int[] {0, 1, 2, 1, 0};
float[] dataArray = new float[] {1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0};
Quaternion[] objArray = new Quaternion[] {
new Quaternion(1, 0, 1, 1),
new Quaternion(1, 1, 1, 0),
new Quaternion(0, 1, 1, 0),
new Quaternion(1, 1, 1, 0),
new Quaternion(1, 0, 1, 1),
};
CompactQuaternionArray compact = new CompactQuaternionArray(dataArray, indexArray);
assertTrue(Arrays.deepEquals(compact.toObjectArray(), objArray));
}
}