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: import java.awt.Point;
023:
024: public class Line2DFloatTest extends GeomTestCase {
025:
026: Line2D.Float l;
027:
028: public Line2DFloatTest(String name) {
029: super (name);
030: }
031:
032: @Override
033: protected void setUp() throws Exception {
034: super .setUp();
035: l = new Line2D.Float(1, 2, 3, 4);
036: }
037:
038: @Override
039: protected void tearDown() throws Exception {
040: l = null;
041: super .tearDown();
042: }
043:
044: public void testCreate1() {
045: assertEquals(new Line2D.Float(0, 0, 0, 0), new Line2D.Float());
046: }
047:
048: public void testCreate2() {
049: assertEquals(new Line2D.Float(1, 2, 3, 4), new Line2D.Float(
050: new Point(1, 2), new Point(3, 4)));
051: }
052:
053: public void testGetX1() {
054: assertEquals(1.0, l.getX1(), 0.0);
055: }
056:
057: public void testGetY1() {
058: assertEquals(2.0, l.getY1(), 0.0);
059: }
060:
061: public void testGetX2() {
062: assertEquals(3.0, l.getX2(), 0.0);
063: }
064:
065: public void testGetY2() {
066: assertEquals(4.0, l.getY2(), 0.0);
067: }
068:
069: public void testGetP1() {
070: assertEquals(new Point2D.Float(1, 2), l.getP1());
071: }
072:
073: public void testGetP2() {
074: assertEquals(new Point2D.Float(3, 4), l.getP2());
075: }
076:
077: public void testSetLine1() {
078: l.setLine(5.0, 6.0, 7.0, 8.0);
079: assertEquals(new Line2D.Float(5, 6, 7, 8), l);
080: }
081:
082: public void testSetLine2() {
083: l.setLine(5.0f, 6.0f, 7.0f, 8.0f);
084: assertEquals(new Line2D.Float(5, 6, 7, 8), l);
085: }
086:
087: public void testGetBounds2D() {
088: for (int[][] element : Line2DTest.bounds) {
089: assertEquals(new Rectangle2D.Float(element[1][0],
090: element[1][1], element[1][2], element[1][3]),
091: new Line2D.Float(element[0][0], element[0][1],
092: element[0][2], element[0][3]).getBounds2D());
093: }
094: }
095:
096: public static void main(String[] args) {
097: junit.textui.TestRunner.run(Line2DFloatTest.class);
098: }
099:
100: }
|