当前位置: 首页>>代码示例>>Java>>正文


Java TestCase.assertTrue方法代码示例

本文整理汇总了Java中junit.framework.TestCase.assertTrue方法的典型用法代码示例。如果您正苦于以下问题:Java TestCase.assertTrue方法的具体用法?Java TestCase.assertTrue怎么用?Java TestCase.assertTrue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在junit.framework.TestCase的用法示例。


在下文中一共展示了TestCase.assertTrue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: detectShapeAABB

import junit.framework.TestCase; //导入方法依赖的package包/类
/**
 * Tests {@link Shape} AABB.
 */
@Test
public void detectShapeAABB() {
    Transform t1 = new Transform();
    Transform t2 = new Transform();

    // test containment
    TestCase.assertTrue(this.sap.detect(s, t1, e, t2));
    TestCase.assertTrue(this.sap.detect(e, t2, s, t1));

    // test overlap
    t1.translate(0.6, 0.0);
    TestCase.assertTrue(this.sap.detect(s, t1, e, t2));
    TestCase.assertTrue(this.sap.detect(e, t2, s, t1));

    // test only AABB overlap
    t2.translate(0.0, -0.5);
    TestCase.assertTrue(this.sap.detect(s, t1, e, t2));
    TestCase.assertTrue(this.sap.detect(e, t2, s, t1));

    // test no overlap
    t2.translate(-3.0, 0.0);
    TestCase.assertFalse(this.sap.detect(s, t1, e, t2));
    TestCase.assertFalse(this.sap.detect(e, t2, s, t1));
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:28,代码来源:SegmentHalfEllipseTest.java

示例2: detectCollidableAABB

import junit.framework.TestCase; //导入方法依赖的package包/类
/**
 * Tests {@link Collidable} AABB.
 */
@Test
public void detectCollidableAABB() {
    // create some collidables
    CollidableTest ct1 = new CollidableTest(capsule1);
    CollidableTest ct2 = new CollidableTest(capsule2);

    // test containment
    TestCase.assertTrue(this.sap.detect(ct1, ct2));
    TestCase.assertTrue(this.sap.detect(ct2, ct1));

    // test overlap
    ct1.translate(-0.5, 0.0);
    TestCase.assertTrue(this.sap.detect(ct1, ct2));
    TestCase.assertTrue(this.sap.detect(ct2, ct1));

    // test only AABB overlap
    ct2.translate(0.0, 0.7);
    TestCase.assertTrue(this.sap.detect(ct1, ct2));
    TestCase.assertTrue(this.sap.detect(ct2, ct1));

    // test no overlap
    ct2.translate(1.0, 0.0);
    TestCase.assertFalse(this.sap.detect(ct1, ct2));
    TestCase.assertFalse(this.sap.detect(ct2, ct1));
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:29,代码来源:CapsuleCapsuleTest.java

示例3: detectCollidableAABB

import junit.framework.TestCase; //导入方法依赖的package包/类
/**
 * Tests {@link Collidable} AABB.
 */
@Test
public void detectCollidableAABB() {
    // create some collidables
    CollidableTest ct1 = new CollidableTest(r);
    CollidableTest ct2 = new CollidableTest(e);

    // test containment
    TestCase.assertTrue(this.sap.detect(ct1, ct2));
    TestCase.assertTrue(this.sap.detect(ct2, ct1));

    // test overlap
    ct1.translate(-1.0, 0.0);
    TestCase.assertTrue(this.sap.detect(ct1, ct2));
    TestCase.assertTrue(this.sap.detect(ct2, ct1));

    // test AABB overlap
    ct2.translate(0.0, -1.2);
    TestCase.assertTrue(this.sap.detect(ct1, ct2));
    TestCase.assertTrue(this.sap.detect(ct1, ct2));

    // test no overlap
    ct2.translate(1.0, 0.0);
    TestCase.assertFalse(this.sap.detect(ct1, ct2));
    TestCase.assertFalse(this.sap.detect(ct2, ct1));
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:29,代码来源:RectangleHalfEllipseTest.java

示例4: detectCollidableAABB

import junit.framework.TestCase; //导入方法依赖的package包/类
/**
 * Tests {@link Collidable} AABB.
 */
@Test
public void detectCollidableAABB() {
    // create some collidables
    CollidableTest ct1 = new CollidableTest(c1);
    CollidableTest ct2 = new CollidableTest(c2);

    // test containment
    TestCase.assertTrue(this.sap.detect(ct1, ct2));
    TestCase.assertTrue(this.sap.detect(ct2, ct1));

    // test overlap
    ct1.translate(-0.5, 0.0);
    TestCase.assertTrue(this.sap.detect(ct1, ct2));
    TestCase.assertTrue(this.sap.detect(ct2, ct1));

    // test only AABB overlap
    ct2.translate(0.2, -0.65);
    TestCase.assertTrue(this.sap.detect(ct1, ct2));
    TestCase.assertTrue(this.sap.detect(ct2, ct1));

    // test no overlap
    ct1.translate(-1.0, 0.0);
    TestCase.assertFalse(this.sap.detect(ct1, ct2));
    TestCase.assertFalse(this.sap.detect(ct2, ct1));
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:29,代码来源:HalfEllipseHalfEllipseTest.java

示例5: detectCollidableAABB

import junit.framework.TestCase; //导入方法依赖的package包/类
/**
 * Tests {@link Collidable} AABB.
 */
@Test
public void detectCollidableAABB() {
    // create some collidables
    CollidableTest ct1 = new CollidableTest(polygon);
    CollidableTest ct2 = new CollidableTest(capsule);

    // test containment
    TestCase.assertTrue(this.sap.detect(ct1, ct2));
    TestCase.assertTrue(this.sap.detect(ct2, ct1));

    // test overlap
    ct1.translate(-0.5, 0.0);
    TestCase.assertTrue(this.sap.detect(ct1, ct2));
    TestCase.assertTrue(this.sap.detect(ct2, ct1));

    // test only AABB overlap
    ct2.translate(0.3, 0.4);
    TestCase.assertTrue(this.sap.detect(ct1, ct2));
    TestCase.assertTrue(this.sap.detect(ct2, ct1));

    // test no overlap
    ct2.translate(1.0, 0.0);
    TestCase.assertFalse(this.sap.detect(ct1, ct2));
    TestCase.assertFalse(this.sap.detect(ct2, ct1));
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:29,代码来源:PolygonCapsuleTest.java

示例6: successTridol3

import junit.framework.TestCase; //导入方法依赖的package包/类
/**
 * Tests the implementation against the tridol2 data file.
 *
 * @since 3.1.10
 */
@Test
public void successTridol3() {
    Vector2[] vertices = this.load(BayazitTest.class.getResourceAsStream("/featurea/physics/data/tridol3.dat"));

    // decompose the poly
    List<? extends Convex> result = this.algo.decompose(vertices);

    // the result should have n - 2 triangles shapes
    TestCase.assertTrue(result.size() <= vertices.length - 2);
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:16,代码来源:BayazitTest.java

示例7: successZoom6

import junit.framework.TestCase; //导入方法依赖的package包/类
/**
 * Tests the implementation against the zoom6 data file.
 *
 * @since 3.1.9
 */
@Test
public void successZoom6() {
    Vector2[] vertices = this.load(BayazitTest.class.getResourceAsStream("/featurea/physics/data/zoom6.dat"));

    // decompose the poly
    List<? extends Convex> result = this.algo.decompose(vertices);

    // the result should have n - 2 triangles shapes
    TestCase.assertTrue(result.size() <= vertices.length - 2);
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:16,代码来源:BayazitTest.java

示例8: equals

import junit.framework.TestCase; //导入方法依赖的package包/类
/**
 * Tests the equals method.
 */
@Test
public void equals() {
    Vector2 v = new Vector2(1.0, 2.0);

    TestCase.assertTrue(v.equals(v));
    TestCase.assertTrue(v.equals(v.copy()));
    TestCase.assertTrue(v.equals(new Vector2(1.0, 2.0)));
    TestCase.assertTrue(v.equals(1.0, 2.0));

    TestCase.assertFalse(v.equals(v.copy().set(2.0, 1.0)));
    TestCase.assertFalse(v.equals(2.0, 2.0));
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:16,代码来源:Vector2Test.java

示例9: contains

import junit.framework.TestCase; //导入方法依赖的package包/类
/**
 * Tests the contains method.
 */
@Test
public void contains() {
    Ellipse e = new Ellipse(2.0, 1.0);
    Transform t = new Transform();
    Vector2 p = new Vector2(0.75, 0.35);

    // shouldn't be in the circle
    TestCase.assertTrue(!e.contains(p, t));

    // move the circle a bit
    t.translate(0.5, 0.0);

    // should be in the circle
    TestCase.assertTrue(e.contains(p, t));

    p.set(1.5, 0.0);

    // should be on the edge
    TestCase.assertTrue(e.contains(p, t));

    // test with local translation
    e.rotate(Math.toRadians(90));
    e.translate(0.5, 1.0);

    TestCase.assertFalse(e.contains(p, t));
    p.set(1.0, 2.1);
    TestCase.assertFalse(e.contains(p, t));
    p.set(1.0, 2.0);
    TestCase.assertTrue(e.contains(p, t));
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:34,代码来源:EllipseTest.java

示例10: successZoom7

import junit.framework.TestCase; //导入方法依赖的package包/类
/**
 * Tests the implementation against the zoom7 data file.
 *
 * @since 3.1.9
 */
@Test
public void successZoom7() {
    Vector2[] vertices = this.load(SweepLineTest.class.getResourceAsStream("/featurea/physics/data/zoom7.dat"));

    // decompose the poly
    List<? extends Convex> result = this.algo.decompose(vertices);

    // the result should have n - 2 triangles shapes
    TestCase.assertTrue(result.size() <= vertices.length - 2);
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:16,代码来源:SweepLineTest.java

示例11: detectSat

import junit.framework.TestCase; //导入方法依赖的package包/类
/**
 * Tests that sat is unsupported.
 */
@Test
public void detectSat() {
    Penetration p = new Penetration();
    Transform t1 = new Transform();
    Transform t2 = new Transform();
    Vector2 n = null;

    // test containment
    TestCase.assertTrue(this.sat.detect(triangle, t1, capsule, t2, p));
    TestCase.assertTrue(this.sat.detect(triangle, t1, capsule, t2));
    n = p.getNormal();
    TestCase.assertEquals(-0.196, n.x, 1.0e-3);
    TestCase.assertEquals(-0.980, n.y, 1.0e-3);
    TestCase.assertEquals(0.797, p.getDepth(), 1.0e-3);
    // try reversing the shapes
    TestCase.assertTrue(this.sat.detect(capsule, t2, triangle, t1, p));
    TestCase.assertTrue(this.sat.detect(capsule, t2, triangle, t1));
    n = p.getNormal();
    TestCase.assertEquals(0.196, n.x, 1.0e-3);
    TestCase.assertEquals(0.980, n.y, 1.0e-3);
    TestCase.assertEquals(0.797, p.getDepth(), 1.0e-3);

    // test overlap
    t1.translate(-0.5, 0.0);
    TestCase.assertTrue(this.sat.detect(triangle, t1, capsule, t2, p));
    TestCase.assertTrue(this.sat.detect(triangle, t1, capsule, t2));
    n = p.getNormal();
    TestCase.assertEquals(0.505, n.x, 1.0e-3);
    TestCase.assertEquals(-0.863, n.y, 1.0e-3);
    TestCase.assertEquals(0.559, p.getDepth(), 1.0e-3);
    // try reversing the shapes
    TestCase.assertTrue(this.sat.detect(capsule, t2, triangle, t1, p));
    TestCase.assertTrue(this.sat.detect(capsule, t2, triangle, t1));
    n = p.getNormal();
    TestCase.assertEquals(-0.505, n.x, 1.0e-3);
    TestCase.assertEquals(0.863, n.y, 1.0e-3);
    TestCase.assertEquals(0.559, p.getDepth(), 1.0e-3);

    // test AABB overlap
    t2.translate(0.5, 0.7);
    TestCase.assertFalse(this.sat.detect(triangle, t1, capsule, t2, p));
    TestCase.assertFalse(this.sat.detect(triangle, t1, capsule, t2));
    // try reversing the shapes
    TestCase.assertFalse(this.sat.detect(capsule, t2, triangle, t1, p));
    TestCase.assertFalse(this.sat.detect(capsule, t2, triangle, t1));

    // test no overlap
    t2.translate(1.0, 0.0);
    TestCase.assertFalse(this.sat.detect(triangle, t1, capsule, t2, p));
    TestCase.assertFalse(this.sat.detect(triangle, t1, capsule, t2));
    // try reversing the shapes
    TestCase.assertFalse(this.sat.detect(capsule, t2, triangle, t1, p));
    TestCase.assertFalse(this.sat.detect(capsule, t2, triangle, t1));
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:58,代码来源:TriangleCapsuleTest.java

示例12: gjkDistance

import junit.framework.TestCase; //导入方法依赖的package包/类
/**
 * Tests the {@link Gjk} distance method.
 */
@Test
public void gjkDistance() {
    Separation s = new Separation();

    Transform t1 = new Transform();
    Transform t2 = new Transform();

    Vector2 n = null;
    Vector2 p1 = null;
    Vector2 p2 = null;

    // test containment
    TestCase.assertFalse(this.gjk.distance(polygon, t1, slice, t2, s));
    // try reversing the shapes
    TestCase.assertFalse(this.gjk.distance(slice, t2, polygon, t1, s));

    // test overlap
    t1.translate(-0.25, 0.0);
    TestCase.assertFalse(this.gjk.distance(polygon, t1, slice, t2, s));
    // try reversing the shapes
    TestCase.assertFalse(this.gjk.distance(slice, t2, polygon, t1, s));

    // test AABB overlap
    t2.translate(0.0, 0.4);
    TestCase.assertTrue(this.gjk.distance(polygon, t1, slice, t2, s));
    n = s.getNormal();
    p1 = s.getPoint1();
    p2 = s.getPoint2();
    TestCase.assertEquals(0.032, s.getDistance(), 1.0e-3);
    TestCase.assertEquals(0.809, n.x, 1.0e-3);
    TestCase.assertEquals(0.587, n.y, 1.0e-3);
    TestCase.assertEquals(-0.026, p1.x, 1.0e-3);
    TestCase.assertEquals(0.380, p1.y, 1.0e-3);
    TestCase.assertEquals(0.000, p2.x, 1.0e-3);
    TestCase.assertEquals(0.400, p2.y, 1.0e-3);
    // try reversing the shapes
    TestCase.assertTrue(this.gjk.distance(slice, t2, polygon, t1, s));
    n = s.getNormal();
    p1 = s.getPoint1();
    p2 = s.getPoint2();
    TestCase.assertEquals(0.032, s.getDistance(), 1.0e-3);
    TestCase.assertEquals(-0.809, n.x, 1.0e-3);
    TestCase.assertEquals(-0.587, n.y, 1.0e-3);
    TestCase.assertEquals(0.000, p1.x, 1.0e-3);
    TestCase.assertEquals(0.400, p1.y, 1.0e-3);
    TestCase.assertEquals(-0.026, p2.x, 1.0e-3);
    TestCase.assertEquals(0.380, p2.y, 1.0e-3);

    // test no overlap
    t2.translate(1.0, 0.0);
    TestCase.assertTrue(this.gjk.distance(polygon, t1, slice, t2, s));
    n = s.getNormal();
    p1 = s.getPoint1();
    p2 = s.getPoint2();
    TestCase.assertEquals(0.850, s.getDistance(), 1.0e-3);
    TestCase.assertEquals(0.882, n.x, 1.0e-3);
    TestCase.assertEquals(0.470, n.y, 1.0e-3);
    TestCase.assertEquals(0.250, p1.x, 1.0e-3);
    TestCase.assertEquals(0.000, p1.y, 1.0e-3);
    TestCase.assertEquals(1.000, p2.x, 1.0e-3);
    TestCase.assertEquals(0.400, p2.y, 1.0e-3);
    // try reversing the shapes
    TestCase.assertTrue(this.gjk.distance(slice, t2, polygon, t1, s));
    n = s.getNormal();
    p1 = s.getPoint1();
    p2 = s.getPoint2();
    TestCase.assertEquals(0.850, s.getDistance(), 1.0e-3);
    TestCase.assertEquals(-0.882, n.x, 1.0e-3);
    TestCase.assertEquals(-0.470, n.y, 1.0e-3);
    TestCase.assertEquals(1.000, p1.x, 1.0e-3);
    TestCase.assertEquals(0.400, p1.y, 1.0e-3);
    TestCase.assertEquals(0.250, p2.x, 1.0e-3);
    TestCase.assertEquals(0.000, p2.y, 1.0e-3);
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:78,代码来源:PolygonSliceTest.java

示例13: detectGjk

import junit.framework.TestCase; //导入方法依赖的package包/类
/**
 * Tests {@link Gjk}.
 */
@Test
public void detectGjk() {
    Penetration p = new Penetration();
    Transform t1 = new Transform();
    Transform t2 = new Transform();

    Vector2 n = null;

    // test containment
    TestCase.assertTrue(this.gjk.detect(poly, t1, ellipse, t2, p));
    TestCase.assertTrue(this.gjk.detect(poly, t1, ellipse, t2));
    n = p.getNormal();
    TestCase.assertEquals(1.092, p.getDepth(), 1.0e-3);
    TestCase.assertEquals(-0.309, n.x, 1.0e-3);
    TestCase.assertEquals(0.951, n.y, 1.0e-3);
    // try reversing the shapes
    TestCase.assertTrue(this.gjk.detect(ellipse, t2, poly, t1, p));
    TestCase.assertTrue(this.gjk.detect(ellipse, t2, poly, t1));
    n = p.getNormal();
    TestCase.assertEquals(1.092, p.getDepth(), 1.0e-3);
    TestCase.assertEquals(0.309, n.x, 1.0e-3);
    TestCase.assertEquals(-0.951, n.y, 1.0e-3);

    // test overlap
    t1.translate(-0.6, 0.0);
    TestCase.assertTrue(this.gjk.detect(poly, t1, ellipse, t2, p));
    TestCase.assertTrue(this.gjk.detect(poly, t1, ellipse, t2));
    n = p.getNormal();
    TestCase.assertEquals(0.753, p.getDepth(), 1.0e-3);
    TestCase.assertEquals(0.809, n.x, 1.0e-3);
    TestCase.assertEquals(-0.587, n.y, 1.0e-3);
    // try reversing the shapes
    TestCase.assertTrue(this.gjk.detect(ellipse, t2, poly, t1, p));
    TestCase.assertTrue(this.gjk.detect(ellipse, t2, poly, t1));
    n = p.getNormal();
    TestCase.assertEquals(0.753, p.getDepth(), 1.0e-3);
    TestCase.assertEquals(-0.809, n.x, 1.0e-3);
    TestCase.assertEquals(0.587, n.y, 1.0e-3);

    // test AABB overlap
    t2.translate(0.55, -0.55);
    TestCase.assertFalse(this.gjk.detect(poly, t1, ellipse, t2, p));
    TestCase.assertFalse(this.gjk.detect(poly, t1, ellipse, t2));
    // try reversing the shapes
    TestCase.assertFalse(this.gjk.detect(ellipse, t2, poly, t1, p));
    TestCase.assertFalse(this.gjk.detect(ellipse, t2, poly, t1));

    // test no overlap
    t2.translate(1.5, -1.5);
    TestCase.assertFalse(this.gjk.detect(poly, t1, ellipse, t2, p));
    TestCase.assertFalse(this.gjk.detect(poly, t1, ellipse, t2));
    // try reversing the shapes
    TestCase.assertFalse(this.gjk.detect(ellipse, t2, poly, t1, p));
    TestCase.assertFalse(this.gjk.detect(ellipse, t2, poly, t1));
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:59,代码来源:PolygonEllipseTest.java

示例14: gjkDistance

import junit.framework.TestCase; //导入方法依赖的package包/类
/**
 * Tests the {@link Gjk} distance method.
 */
@Test
public void gjkDistance() {
    Separation s = new Separation();

    Transform t1 = new Transform();
    Transform t2 = new Transform();

    Vector2 n = null;
    Vector2 p1 = null;
    Vector2 p2 = null;

    // test containment
    TestCase.assertFalse(this.gjk.distance(c, t1, e, t2, s));
    // try reversing the shapes
    TestCase.assertFalse(this.gjk.distance(e, t2, c, t1, s));

    // test overlap
    t1.translate(-0.75, 0.0);
    TestCase.assertFalse(this.gjk.distance(c, t1, e, t2, s));
    // try reversing the shapes
    TestCase.assertFalse(this.gjk.distance(e, t2, c, t1, s));

    // test AABB overlap
    t2.translate(0.0, -0.9);
    TestCase.assertTrue(this.gjk.distance(c, t1, e, t2, s));
    n = s.getNormal();
    p1 = s.getPoint1();
    p2 = s.getPoint2();
    TestCase.assertEquals(0.021, s.getDistance(), 1.0e-3);
    TestCase.assertEquals(0.332, n.x, 1.0e-3);
    TestCase.assertEquals(-0.943, n.y, 1.0e-3);
    TestCase.assertEquals(-0.583, p1.x, 1.0e-3);
    TestCase.assertEquals(-0.471, p1.y, 1.0e-3);
    TestCase.assertEquals(-0.576, p2.x, 1.0e-3);
    TestCase.assertEquals(-0.491, p2.y, 1.0e-3);
    // try reversing the shapes
    TestCase.assertTrue(this.gjk.distance(e, t2, c, t1, s));
    n = s.getNormal();
    p1 = s.getPoint1();
    p2 = s.getPoint2();
    TestCase.assertEquals(0.021, s.getDistance(), 1.0e-3);
    TestCase.assertEquals(-0.332, n.x, 1.0e-3);
    TestCase.assertEquals(0.943, n.y, 1.0e-3);
    TestCase.assertEquals(-0.576, p1.x, 1.0e-3);
    TestCase.assertEquals(-0.491, p1.y, 1.0e-3);
    TestCase.assertEquals(-0.583, p2.x, 1.0e-3);
    TestCase.assertEquals(-0.471, p2.y, 1.0e-3);

    // test no overlap
    t2.translate(1.0, 0.0);
    TestCase.assertTrue(this.gjk.distance(c, t1, e, t2, s));
    n = s.getNormal();
    p1 = s.getPoint1();
    p2 = s.getPoint2();
    TestCase.assertEquals(0.588, s.getDistance(), 1.0e-3);
    TestCase.assertEquals(0.762, n.x, 1.0e-3);
    TestCase.assertEquals(-0.647, n.y, 1.0e-3);
    TestCase.assertEquals(-0.368, p1.x, 1.0e-3);
    TestCase.assertEquals(-0.323, p1.y, 1.0e-3);
    TestCase.assertEquals(0.079, p2.x, 1.0e-3);
    TestCase.assertEquals(-0.704, p2.y, 1.0e-3);
    // try reversing the shapes
    TestCase.assertTrue(this.gjk.distance(e, t2, c, t1, s));
    n = s.getNormal();
    p1 = s.getPoint1();
    p2 = s.getPoint2();
    TestCase.assertEquals(0.588, s.getDistance(), 1.0e-3);
    TestCase.assertEquals(-0.762, n.x, 1.0e-3);
    TestCase.assertEquals(0.647, n.y, 1.0e-3);
    TestCase.assertEquals(0.079, p1.x, 1.0e-3);
    TestCase.assertEquals(-0.704, p1.y, 1.0e-3);
    TestCase.assertEquals(-0.368, p2.x, 1.0e-3);
    TestCase.assertEquals(-0.323, p2.y, 1.0e-3);
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:78,代码来源:CircleHalfEllipseTest.java

示例15: detectGjk

import junit.framework.TestCase; //导入方法依赖的package包/类
/**
 * Tests {@link Gjk}.
 */
@Test
public void detectGjk() {
    Penetration p = new Penetration();
    Transform t1 = new Transform();
    Transform t2 = new Transform();
    Vector2 n = null;

    // test containment
    TestCase.assertTrue(this.gjk.detect(circle, t1, slice, t2, p));
    TestCase.assertTrue(this.gjk.detect(circle, t1, slice, t2));
    n = p.getNormal();
    TestCase.assertEquals(0.654, n.x, 1.0e-3);
    TestCase.assertEquals(0.755, n.y, 1.0e-3);
    TestCase.assertEquals(0.500, p.getDepth(), 1.0e-3);
    // try reversing the shapes
    TestCase.assertTrue(this.gjk.detect(slice, t2, circle, t1, p));
    TestCase.assertTrue(this.gjk.detect(slice, t2, circle, t1));
    n = p.getNormal();
    TestCase.assertEquals(-0.654, n.x, 1.0e-3);
    TestCase.assertEquals(-0.755, n.y, 1.0e-3);
    TestCase.assertEquals(0.500, p.getDepth(), 1.0e-3);

    // test overlap
    t1.translate(-0.25, 0.0);
    TestCase.assertTrue(this.gjk.detect(circle, t1, slice, t2, p));
    TestCase.assertTrue(this.gjk.detect(circle, t1, slice, t2));
    n = p.getNormal();
    TestCase.assertEquals(0.999, n.x, 1.0e-3);
    TestCase.assertEquals(0.000, n.y, 1.0e-3);
    TestCase.assertEquals(0.250, p.getDepth(), 1.0e-3);
    // try reversing the shapes
    TestCase.assertTrue(this.gjk.detect(slice, t2, circle, t1, p));
    TestCase.assertTrue(this.gjk.detect(slice, t2, circle, t1));
    n = p.getNormal();
    TestCase.assertEquals(-0.999, n.x, 1.0e-3);
    TestCase.assertEquals(0.000, n.y, 1.0e-3);
    TestCase.assertEquals(0.250, p.getDepth(), 1.0e-3);

    // test AABB overlap
    t2.translate(0.0, 0.45);
    TestCase.assertFalse(this.gjk.detect(circle, t1, slice, t2, p));
    TestCase.assertFalse(this.gjk.detect(circle, t1, slice, t2));
    // try reversing the shapes
    TestCase.assertFalse(this.gjk.detect(slice, t2, circle, t1, p));
    TestCase.assertFalse(this.gjk.detect(slice, t2, circle, t1));

    // test no overlap
    t2.translate(1.0, 0.0);
    TestCase.assertFalse(this.gjk.detect(circle, t1, slice, t2, p));
    TestCase.assertFalse(this.gjk.detect(circle, t1, slice, t2));
    // try reversing the shapes
    TestCase.assertFalse(this.gjk.detect(slice, t2, circle, t1, p));
    TestCase.assertFalse(this.gjk.detect(slice, t2, circle, t1));
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:58,代码来源:CircleSliceTest.java


注:本文中的junit.framework.TestCase.assertTrue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。