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 CubicCurve2DDoubleTest extends GeomTestCase {
023:
024: CubicCurve2D.Double c;
025:
026: public CubicCurve2DDoubleTest(String name) {
027: super (name);
028: }
029:
030: @Override
031: protected void setUp() throws Exception {
032: super .setUp();
033: c = new CubicCurve2D.Double(1, 2, 3, 4, 5, 6, 7, 8);
034: }
035:
036: @Override
037: protected void tearDown() throws Exception {
038: c = null;
039: super .tearDown();
040: }
041:
042: public void testCreate() {
043: assertEquals(new CubicCurve2D.Double(),
044: new CubicCurve2D.Double(0, 0, 0, 0, 0, 0, 0, 0), 0.0f);
045: }
046:
047: public void testGetX1() {
048: assertEquals(1.0, c.getX1(), 0.0);
049: }
050:
051: public void testGetY1() {
052: assertEquals(2.0, c.getY1(), 0.0);
053: }
054:
055: public void testGetCtrlX1() {
056: assertEquals(3.0, c.getCtrlX1(), 0.0);
057: }
058:
059: public void testGetCtrlY1() {
060: assertEquals(4.0, c.getCtrlY1(), 0.0);
061: }
062:
063: public void testGetCtrlX2() {
064: assertEquals(5.0, c.getCtrlX2(), 0.0);
065: }
066:
067: public void testGetCtrlY2() {
068: assertEquals(6.0, c.getCtrlY2(), 0.0);
069: }
070:
071: public void testGetX2() {
072: assertEquals(7.0, c.getX2(), 0.0);
073: }
074:
075: public void testGetY2() {
076: assertEquals(8.0, c.getY2(), 0.0);
077: }
078:
079: public void testGetP1() {
080: assertEquals(new Point2D.Double(1, 2), c.getP1());
081: }
082:
083: public void testGetCtrlP1() {
084: assertEquals(new Point2D.Double(3, 4), c.getCtrlP1());
085: }
086:
087: public void testGetCtrlP2() {
088: assertEquals(new Point2D.Double(5, 6), c.getCtrlP2());
089: }
090:
091: public void testGetP2() {
092: assertEquals(new Point2D.Double(7, 8), c.getP2());
093: }
094:
095: public void testSetCurve1() {
096: c.setCurve(9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0);
097: assertEquals(new CubicCurve2D.Double(9, 10, 11, 12, 13, 14, 15,
098: 16), c, 0.0);
099: }
100:
101: public void testSetCurve2() {
102: c.setCurve(9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f,
103: 16.0f);
104: assertEquals(new CubicCurve2D.Double(9, 10, 11, 12, 13, 14, 15,
105: 16), c, 0.0);
106: }
107:
108: public void testGetBounds2D() {
109: for (double[][] element : CubicCurve2DTest.bounds) {
110: CubicCurve2D curve = new CubicCurve2D.Double();
111: curve.setCurve(element[0], 0);
112: assertEquals(cubicToStr(curve), new Rectangle2D.Double(
113: (int) element[1][0], (int) element[1][1],
114: (int) element[1][2], (int) element[1][3]), curve
115: .getBounds2D());
116: }
117: }
118:
119: public static void main(String[] args) {
120: junit.textui.TestRunner.run(CubicCurve2DDoubleTest.class);
121: }
122:
123: }
|