001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Denis M. Kishenko
019: * @version $Revision$
020: */package java.awt.geom;
021:
022: public class QuadCurve2DDoubleTest extends GeomTestCase {
023:
024: QuadCurve2D.Double q;
025:
026: public QuadCurve2DDoubleTest(String name) {
027: super (name);
028: }
029:
030: @Override
031: protected void setUp() throws Exception {
032: super .setUp();
033: q = new QuadCurve2D.Double(1, 2, 3, 4, 5, 6);
034: }
035:
036: @Override
037: protected void tearDown() throws Exception {
038: q = null;
039: super .tearDown();
040: }
041:
042: public void testCreate() {
043: assertEquals(new QuadCurve2D.Double(), new QuadCurve2D.Double(
044: 0, 0, 0, 0, 0, 0), 0.0);
045: }
046:
047: public void testGetX1() {
048: assertEquals(1.0, q.getX1(), 0.0);
049: }
050:
051: public void testGetY1() {
052: assertEquals(2.0, q.getY1(), 0.0);
053: }
054:
055: public void testGetCtrlX() {
056: assertEquals(3.0, q.getCtrlX(), 0.0);
057: }
058:
059: public void testGetCtrlY() {
060: assertEquals(4.0, q.getCtrlY(), 0.0);
061: }
062:
063: public void testGetX2() {
064: assertEquals(5.0, q.getX2(), 0.0);
065: }
066:
067: public void testGetY2() {
068: assertEquals(6.0, q.getY2(), 0.0);
069: }
070:
071: public void testGetP1() {
072: assertEquals(new Point2D.Double(1, 2), q.getP1());
073: }
074:
075: public void testGetCtrlPt() {
076: assertEquals(new Point2D.Double(3, 4), q.getCtrlPt());
077: }
078:
079: public void testGetP2() {
080: assertEquals(new Point2D.Double(5, 6), q.getP2());
081: }
082:
083: public void testSetCurve1() {
084: q.setCurve(7.0, 8.0, 9.0, 10.0, 11.0, 12.0);
085: assertEquals(new QuadCurve2D.Double(7, 8, 9, 10, 11, 12), q,
086: 0.0);
087: }
088:
089: public void testSetCurve2() {
090: q.setCurve(7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f);
091: assertEquals(new QuadCurve2D.Double(7, 8, 9, 10, 11, 12), q,
092: 0.0);
093: }
094:
095: public void testGetBounds2D() {
096: for (double[][] element : QuadCurve2DTest.bounds) {
097: QuadCurve2D curve = new QuadCurve2D.Double();
098: curve.setCurve(element[0], 0);
099: assertEquals(quadToStr(curve), new Rectangle2D.Double(
100: (int) element[1][0], (int) element[1][1],
101: (int) element[1][2], (int) element[1][3]), curve
102: .getBounds2D());
103: }
104: }
105:
106: public static void main(String[] args) {
107: junit.textui.TestRunner.run(QuadCurve2DDoubleTest.class);
108: }
109:
110: }
|