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


Java TestCase.assertEquals方法代码示例

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


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

示例1: createSuccess

import junit.framework.TestCase; //导入方法依赖的package包/类
/**
 * Tests a successful creation.
 */
@Test
public void createSuccess() {
    Rectangle r = new Rectangle(2.0, 2.0);
    // make sure the center is 0,0
    TestCase.assertEquals(0.000, r.center.x, 1.0e-3);
    TestCase.assertEquals(0.000, r.center.y, 1.0e-3);
    // make sure the points are correct
    TestCase.assertEquals(-1.000, r.vertices[0].x, 1.0e-3);
    TestCase.assertEquals(-1.000, r.vertices[0].y, 1.0e-3);

    TestCase.assertEquals(1.000, r.vertices[1].x, 1.0e-3);
    TestCase.assertEquals(-1.000, r.vertices[1].y, 1.0e-3);

    TestCase.assertEquals(1.000, r.vertices[2].x, 1.0e-3);
    TestCase.assertEquals(1.000, r.vertices[2].y, 1.0e-3);

    TestCase.assertEquals(-1.000, r.vertices[3].x, 1.0e-3);
    TestCase.assertEquals(1.000, r.vertices[3].y, 1.0e-3);
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:23,代码来源:RectangleTest.java

示例2: difference

import junit.framework.TestCase; //导入方法依赖的package包/类
/**
 * Tests the difference method.
 */
@Test
public void difference() {
    Matrix33 m1 = new Matrix33(0.0, 2.0, 0.0,
            3.0, 1.0, 1.0,
            2.0, 0.0, -1.0);
    Matrix33 m2 = new Matrix33(1.0, 1.0, 3.0,
            0.0, 4.0, 1.0,
            2.0, 2.0, 1.0);
    Matrix33 m3 = m1.difference(m2);
    // test the values
    TestCase.assertEquals(-1.0, m3.m00);
    TestCase.assertEquals(1.0, m3.m01);
    TestCase.assertEquals(-3.0, m3.m02);
    TestCase.assertEquals(3.0, m3.m10);
    TestCase.assertEquals(-3.0, m3.m11);
    TestCase.assertEquals(0.0, m3.m12);
    TestCase.assertEquals(0.0, m3.m20);
    TestCase.assertEquals(-2.0, m3.m21);
    TestCase.assertEquals(-2.0, m3.m22);
    // make sure we didnt modify the first matrix
    TestCase.assertFalse(m1.equals(m3));
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:26,代码来源:Matrix33Test.java

示例3: invert

import junit.framework.TestCase; //导入方法依赖的package包/类
/**
 * Tests the invert method.
 */
@Test
public void invert() {
    Matrix22 m1 = new Matrix22(1.0, 2.0,
            3.0, 4.0);
    m1.invert();
    TestCase.assertEquals(-2.0, m1.m00);
    TestCase.assertEquals(1.0, m1.m01);
    TestCase.assertEquals(1.5, m1.m10);
    TestCase.assertEquals(-0.5, m1.m11);
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:14,代码来源:Matrix22Test.java

示例4: triangulateSuccessNazcaHeron

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

    // decompose the poly
    List<Triangle> result = this.algo.triangulate(vertices);

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

示例5: setMaximum

import junit.framework.TestCase; //导入方法依赖的package包/类
/**
 * Tests the successful setting of the maximum distance.
 */
@Test
public void setMaximum() {
    RopeJoint rj = new RopeJoint(new Body(), new Body(), new Vector2(), new Vector2());
    rj.setUpperLimit(10);

    TestCase.assertEquals(10.0, rj.getUpperLimit());
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:11,代码来源:RopeJointTest.java

示例6: get

import junit.framework.TestCase; //导入方法依赖的package包/类
/**
 * Tests the getProperty methods.
 */
@Test
public void get() {
    Vector2 v = new Vector2(3.0, 4.0);

    Vector2 x = v.getXComponent();
    Vector2 y = v.getYComponent();

    TestCase.assertEquals(3.0, x.x);
    TestCase.assertEquals(0.0, x.y);
    TestCase.assertEquals(0.0, y.x);
    TestCase.assertEquals(4.0, y.y);

    TestCase.assertEquals(5.000, v.getMagnitude(), 1.0e-3);
    TestCase.assertEquals(25.000, v.getMagnitudeSquared(), 1.0e-3);
    TestCase.assertEquals(53.130, Math.toDegrees(v.getDirection()), 1.0e-3);

    Vector2 v2 = new Vector2(-4.0, 3.0);
    TestCase.assertEquals(90.000, Math.toDegrees(v.getAngleBetween(v2)), 1.0e-3);

    v2 = v.getLeftHandOrthogonalVector();
    TestCase.assertEquals(4.0, v2.x);
    TestCase.assertEquals(-3.0, v2.y);

    v2 = v.getRightHandOrthogonalVector();
    TestCase.assertEquals(-4.0, v2.x);
    TestCase.assertEquals(3.0, v2.y);

    v2 = v.getNegative();
    TestCase.assertEquals(-3.0, v2.x);
    TestCase.assertEquals(-4.0, v2.y);

    v2 = v.getNormalized();
    TestCase.assertEquals(0.600, v2.x, 1.0e-3);
    TestCase.assertEquals(0.800, v2.y, 1.0e-3);
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:39,代码来源:Vector2Test.java

示例7: ensureParent

import junit.framework.TestCase; //导入方法依赖的package包/类
/**
 * Ensure that the specified parent names are registered. Note that these
 * are components of the name. It waits in a loop up to 60 seconds before
 * failing if there is a mismatch. This will return the beans which are not
 * matched.
 * 
 * {@link https://issues.apache.org/jira/browse/ZOOKEEPER-1858}
 * 
 * @param expectedNames
 *            - expected beans
 * @return the beans which are not matched with the given expected names
 * 
 * @throws IOException
 * @throws InterruptedException
 * 
 */
public static Set<ObjectName> ensureParent(String... expectedNames)
        throws IOException, InterruptedException {
    LOG.info("ensureParent:" + Arrays.toString(expectedNames));

    Set<ObjectName> beans;
    int nTry = 0;
    Set<ObjectName> found = new HashSet<ObjectName>();
    do {
        if (nTry++ > 0) {
            Thread.sleep(500);
        }
        try {
            beans = conn().queryNames(
                    new ObjectName(CommonNames.DOMAIN + ":*"), null);
        } catch (MalformedObjectNameException e) {
            throw new RuntimeException(e);
        }
        found.clear();
        for (String name : expectedNames) {
            LOG.info("expect:" + name);
            for (ObjectName bean : beans) {
                // check the existence of name in bean
                if (compare(bean.toString(), name)) {
                    LOG.info("found:" + name + " " + bean);
                    found.add(bean);
                    break;
                }
            }
            beans.removeAll(found);
        }
    } while (expectedNames.length != found.size() && nTry < 120);
    TestCase.assertEquals("expected " + Arrays.toString(expectedNames),
            expectedNames.length, found.size());
    return beans;
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:52,代码来源:JMXEnv.java

示例8: createSuccess

import junit.framework.TestCase; //导入方法依赖的package包/类
/**
 * Tests the constructor.
 */
@Test
public void createSuccess() {
    Ellipse e = new Ellipse(1.0, 2.0);
    TestCase.assertEquals(1.0, e.getHalfHeight());
    TestCase.assertEquals(0.5, e.getHalfWidth());
    TestCase.assertEquals(1.0, e.getWidth());
    TestCase.assertEquals(2.0, e.getHeight());
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:12,代码来源:EllipseTest.java

示例9: versions

import junit.framework.TestCase; //导入方法依赖的package包/类
/**
 * Tests the getProperty verion number methods.
 */
@Test
public void versions() {
    // getProperty the version array
    int[] version = Version.getVersionNumbers();
    TestCase.assertEquals(Version.getMajorNumber(), version[0]);
    TestCase.assertEquals(Version.getMinorNumber(), version[1]);
    TestCase.assertEquals(Version.getRevisionNumber(), version[2]);
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:12,代码来源:VersionTest.java

示例10: copy

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

    TestCase.assertFalse(v == vc);
    TestCase.assertEquals(v.x, vc.x);
    TestCase.assertEquals(v.y, vc.y);
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:13,代码来源:Vector2Test.java

示例11: distance

import junit.framework.TestCase; //导入方法依赖的package包/类
/**
 * Tests the distance method.
 *
 * @since 3.1.0
 */
@Test
public void distance() {
    Interval i1 = new Interval(-2.0, 3.0);
    Interval i2 = new Interval(-1.0, 4.0);

    // overlapping intervals should return 0
    TestCase.assertEquals(0.0, i1.distance(i2));

    i2 = new Interval(4.0, 6.0);

    TestCase.assertEquals(1.0, i1.distance(i2));
    TestCase.assertEquals(1.0, i2.distance(i1));
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:19,代码来源:IntervalValueTest.java

示例12: removeAllFixtures

import junit.framework.TestCase; //导入方法依赖的package包/类
/**
 * Tests the removal of all fixtures.
 *
 * @since 3.0.2
 */
@Test
public void removeAllFixtures() {
    Body b = new Body();
    b.addFixture(Geometry.createCircle(1.0));
    b.addFixture(Geometry.createRectangle(1.0, 0.5));
    b.addFixture(Geometry.createSegment(new Vector2(1.0, -2.0)));

    TestCase.assertEquals(3, b.getFixtureCount());
    b.removeAllFixtures();
    TestCase.assertEquals(0, b.getFixtureCount());
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:17,代码来源:BodyTest.java

示例13: triangulateSuccessNazcaMonkey

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

    // decompose the poly
    List<Triangle> result = this.algo.triangulate(vertices);

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

示例14: testMarshalling

import junit.framework.TestCase; //导入方法依赖的package包/类
@Test
public void testMarshalling() throws Exception {
    String dpidStr = "00:00:00:23:20:2d:16:71";
    long dpid = HexString.toLong(dpidStr);
    String testStr = HexString.toHexString(dpid);
    TestCase.assertEquals(dpidStr, testStr);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:8,代码来源:HexStringTest.java

示例15: getAreaWeightedCenterZeroAreaArray

import junit.framework.TestCase; //导入方法依赖的package包/类
/**
 * Tests the getAreaWeightedCenter method passing a list of
 * points who are all the same yielding zero area.
 *
 * @since 2.0.0
 */
@Test
public void getAreaWeightedCenterZeroAreaArray() {
    Vector2[] points = new Vector2[4];
    points[0] = new Vector2(2.0, 1.0);
    points[1] = new Vector2(2.0, 1.0);
    points[2] = new Vector2(2.0, 1.0);
    points[3] = new Vector2(2.0, 1.0);

    Vector2 c = Geometry.getAreaWeightedCenter(points);

    TestCase.assertEquals(2.000, c.x, 1.0e-3);
    TestCase.assertEquals(1.000, c.y, 1.0e-3);
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:20,代码来源:GeometryTest.java


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