瀏覽代碼

untabified

tags/V1_1_1
ehilsdal 21 年之前
父節點
當前提交
9ae0cfecd5

+ 16
- 16
docs/teaching/exercises/tests/Test.java 查看文件

@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/

package tests;
@@ -31,12 +31,12 @@ public class Test extends TestCase {
Group g;

public void setUp() {
p1 = new Point(10, 100);
p2 = new Point(20, 200);
l1 = new Line(p1, p2);
p1 = new Point(10, 100);
p2 = new Point(20, 200);
l1 = new Line(p1, p2);
bb = new Box(5, 5, 10, 10);
sloth1 = new SlothfulPoint(0, 0);
g = new Group(p1);
g = new Group(p1);
}

public final void testCreate() {
@@ -48,17 +48,17 @@ public class Test extends TestCase {
}

public final void testSetPoint() {
p1.setX(20);
p1.setX(20);
assertEquals(p1.getX(), 20);
assertEquals(p1.getY(), 100);

p1.setY(10);
p1.setY(10);
assertEquals(p1.getX(), 20);
assertEquals(p1.getY(), 10);
}

public final void testMoveLine1() {
l1.move(40, 40);
l1.move(40, 40);
assertEquals(l1.getP1(), p1);
assertEquals(l1.getP2(), p2);

@@ -70,7 +70,7 @@ public class Test extends TestCase {
}

public final void testMoveLine2() {
l1.move(-10, -10);
l1.move(-10, -10);
assertEquals(p1.getX(), 0);
assertEquals(p1.getY(), 90);


+ 12
- 12
docs/teaching/exercises/tests/Test1a.java 查看文件

@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/

package tests;
@@ -34,22 +34,22 @@ public class Test1a extends Test {
}

public void testSetXPointLog() {
p1.setX(20);
p1.setX(20);
assertEquals("set;", Log.getString());
}

public void testSetYPointLog() {
p1.setY(10);
p1.setY(10);
assertEquals("", Log.getString());
}

public void testGetYPointLog() {
p1.getY();
p1.getY();
assertEquals("", Log.getString());
}

public void testMoveLineLog() {
l1.move(40, 40);
l1.move(40, 40);
assertEquals("", Log.getString());
}
}

+ 8
- 8
docs/teaching/exercises/tests/Test2a.java 查看文件

@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/

package tests;

+ 9
- 9
docs/teaching/exercises/tests/Test2b.java 查看文件

@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/

package tests;
@@ -29,7 +29,7 @@ public class Test2b extends Test {

public void testNull() {
try {
g.add(null);
g.add(null);
fail("should have thrown IllegalArgumentException");
} catch (IllegalArgumentException ea) {
}

+ 10
- 10
docs/teaching/exercises/tests/Test2c.java 查看文件

@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/

package tests;
@@ -29,7 +29,7 @@ public class Test2c extends Test {

public void testNull() {
try {
g.add(null);
g.add(null);
fail("should have thrown IllegalArgumentException");
} catch (IllegalArgumentException ea) {
}
@@ -37,7 +37,7 @@ public class Test2c extends Test {

public void testSelf() {
try {
g.add(g);
g.add(g);
fail("should have thrown IllegalArgumentException");
} catch (IllegalArgumentException ea) {
}

+ 9
- 9
docs/teaching/exercises/tests/Test2d.java 查看文件

@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/

package tests;
@@ -29,7 +29,7 @@ public class Test2d extends Test {

public void testSetting() {
try {
sloth1.setX(10);
sloth1.setX(10);
fail("should have thrown RuntimeException");
} catch (RuntimeException ea) {
}

+ 9
- 9
docs/teaching/exercises/tests/Test2e.java 查看文件

@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/

package tests;
@@ -35,7 +35,7 @@ public class Test2e extends Test {

try {
sq.getP0().setX(100);
sq.move(37, 1);
sq.move(37, 1);
fail("should have thrown IllegalStateException");
} catch (IllegalStateException e) { }
}

+ 8
- 8
docs/teaching/exercises/tests/Test2f.java 查看文件

@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/

package tests;

+ 8
- 8
docs/teaching/exercises/tests/Test2g.java 查看文件

@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/

package tests;

+ 8
- 8
docs/teaching/exercises/tests/Test2h.java 查看文件

@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/

package tests;

+ 10
- 10
docs/teaching/exercises/tests/Test3a.java 查看文件

@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/

package tests;
@@ -34,7 +34,7 @@ public class Test3a extends Test {
}

public void testMovePointLog() {
p1.move(20, 30);
p1.move(20, 30);
assertEquals("moving;", Log.getString());
}

@@ -43,7 +43,7 @@ public class Test3a extends Test {
}

public void testGetYPointLog() {
p1.getY();
p1.getY();
assertEquals("", Log.getString());
}
}

+ 12
- 12
docs/teaching/exercises/tests/Test3b.java 查看文件

@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/

package tests;
@@ -34,21 +34,21 @@ public class Test3b extends Test {
}

public void testCreateWithPointLog() {
g = new Group(p1);
g = new Group(p1);
assertEquals("adding Point;", Log.getString());
}

public void testCreateWithoutPointLog() {
g = new Group(l1);
g = new Group(l1);
assertEquals("", Log.getString());
}

public void testAddPointLog() {
g.add(p1);
g.add(p1);
assertEquals("adding Point;", Log.getString());
}
public void testAddNonPointLog() {
g.add(l1);
g.add(l1);
assertEquals("", Log.getString());
}
}

+ 12
- 12
docs/teaching/exercises/tests/Test3c.java 查看文件

@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/

package tests;
@@ -34,14 +34,14 @@ public class Test3c extends Test {
}

public void testMoveLonePoint() {
p1 = new Point(0, 0);
p1.move(37, 88);
p1 = new Point(0, 0);
p1.move(37, 88);
assertEquals("moving as a part of null;", Log.getString());
}

public void testMoveGroupedPoint() {
g = new Group(p1);
p1.move(0, 0);
g = new Group(p1);
p1.move(0, 0);
assertEquals("moving as a part of " + g + ";", Log.getString());
}
}

+ 10
- 10
docs/teaching/exercises/tests/Test4a.java 查看文件

@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/

package tests;
@@ -19,8 +19,8 @@ import junit.framework.*;

public class Test4a extends Test {
Rectangle wholeCanvas =
new Rectangle(FigureElement.MIN_VALUE, FigureElement.MIN_VALUE,
FigureElement.MAX_VALUE, FigureElement.MAX_VALUE);
new Rectangle(FigureElement.MIN_VALUE, FigureElement.MIN_VALUE,
FigureElement.MAX_VALUE, FigureElement.MAX_VALUE);

public Test4a(String name) { super(name); }


+ 29
- 29
docs/teaching/exercises/tests/Test4b.java 查看文件

@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/

package tests;
@@ -30,30 +30,30 @@ public class Test4b extends Test {
}

public void testBasicEquality() {
assertTrue(g.getBounds() == g.getBounds());
assertTrue(g.getBounds() == g.getBounds());
}

public void testEqualityAfterAddition() {
Point p0 = new Point(1, 2);
Point p1 = new Point(2, 3);
Group g0 = new Group(p0);
Group g1 = new Group(p1);
Rectangle r0 = g0.getBounds();
Rectangle r1 = g1.getBounds();
assertTrue(r0 != r1);
g0.add(new Point(37, 90));
assertTrue(g0.getBounds() == r0);
assertTrue(g1.getBounds() != r0);
assertTrue(g0.getBounds() != r1);
assertTrue(g1.getBounds() == r1);
g1.add(new Point(4, 8));
assertTrue(g0.getBounds() == r0);
assertTrue(g1.getBounds() != r0);
assertTrue(g0.getBounds() != r1);
assertTrue(g1.getBounds() == r1);
Point p0 = new Point(1, 2);
Point p1 = new Point(2, 3);
Group g0 = new Group(p0);
Group g1 = new Group(p1);
Rectangle r0 = g0.getBounds();
Rectangle r1 = g1.getBounds();
assertTrue(r0 != r1);
g0.add(new Point(37, 90));
assertTrue(g0.getBounds() == r0);
assertTrue(g1.getBounds() != r0);
assertTrue(g0.getBounds() != r1);
assertTrue(g1.getBounds() == r1);
g1.add(new Point(4, 8));
assertTrue(g0.getBounds() == r0);
assertTrue(g1.getBounds() != r0);
assertTrue(g0.getBounds() != r1);
assertTrue(g1.getBounds() == r1);
}

public void testNotWholeCanvas() {

+ 50
- 50
docs/teaching/exercises/tests/Test4c.java 查看文件

@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/

package tests;
@@ -30,54 +30,54 @@ public class Test4c extends Test {
}

public void testBasicEquality() {
assertTrue(g.getBounds() == g.getBounds());
assertTrue(g.getBounds() == g.getBounds());
}

public void testEqualityAfterAddition() {
Point p0 = new Point(1, 2);
Point p1 = new Point(2, 3);
Group g0 = new Group(p0);
Group g1 = new Group(p1);
Rectangle r0 = g0.getBounds();
Rectangle r1 = g1.getBounds();
assertTrue(r0 != r1);
g0.add(new Point(37, 90));
assertTrue(g0.getBounds() == r0);
assertTrue(g1.getBounds() != r0);
assertTrue(g0.getBounds() != r1);
assertTrue(g1.getBounds() == r1);
g1.add(new Point(4, 8));
assertTrue(g0.getBounds() == r0);
assertTrue(g1.getBounds() != r0);
assertTrue(g0.getBounds() != r1);
assertTrue(g1.getBounds() == r1);
Point p0 = new Point(1, 2);
Point p1 = new Point(2, 3);
Group g0 = new Group(p0);
Group g1 = new Group(p1);
Rectangle r0 = g0.getBounds();
Rectangle r1 = g1.getBounds();
assertTrue(r0 != r1);
g0.add(new Point(37, 90));
assertTrue(g0.getBounds() == r0);
assertTrue(g1.getBounds() != r0);
assertTrue(g0.getBounds() != r1);
assertTrue(g1.getBounds() == r1);
g1.add(new Point(4, 8));
assertTrue(g0.getBounds() == r0);
assertTrue(g1.getBounds() != r0);
assertTrue(g0.getBounds() != r1);
assertTrue(g1.getBounds() == r1);
}

public void testEqualityAfterMove() {
Point p0 = new Point(1, 2);
Point p1 = new Point(2, 3);
Group g0 = new Group(p0);
Group g1 = new Group(p1);
Rectangle r0 = g0.getBounds();
Rectangle r1 = g1.getBounds();
assertTrue(r0 != r1);
assertTrue(g0.getBounds() == r0);
assertTrue(g1.getBounds() != r0);
assertTrue(g0.getBounds() != r1);
assertTrue(g1.getBounds() == r1);
g0.move(3, 1);
Rectangle r00 = g0.getBounds();
Rectangle r10 = g1.getBounds();
assertTrue(r10 != r00);
assertTrue(r0 != r00);
assertTrue(g0.getBounds() == r00);
Point p0 = new Point(1, 2);
Point p1 = new Point(2, 3);
Group g0 = new Group(p0);
Group g1 = new Group(p1);
Rectangle r0 = g0.getBounds();
Rectangle r1 = g1.getBounds();
assertTrue(r0 != r1);
assertTrue(g0.getBounds() == r0);
assertTrue(g1.getBounds() != r0);
assertTrue(g0.getBounds() != r1);
assertTrue(g1.getBounds() == r1);
g0.move(3, 1);
Rectangle r00 = g0.getBounds();
Rectangle r10 = g1.getBounds();
assertTrue(r10 != r00);
assertTrue(r0 != r00);
assertTrue(g0.getBounds() == r00);
}
}


+ 41
- 41
docs/teaching/exercises/tests/Test4d.java 查看文件

@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/

package tests;
@@ -30,51 +30,51 @@ public class Test4d extends Test {
}

public void testBasicEquality() {
assertTrue(g.getBounds() == g.getBounds());
assertTrue(g.getBounds() == g.getBounds());
}

public void testNonGroupMove() {
p1.move(3, 27);
p1.move(3, 27);
}

public void testEqualityAfterAddition() {
Rectangle r = g.getBounds();
g.add(new Point(37, 90));
assertTrue(g.getBounds() == r);
Rectangle r = g.getBounds();
g.add(new Point(37, 90));
assertTrue(g.getBounds() == r);
}

public void testEqualityAfterMove() {
Point p0 = new Point(1, 2);
Point p1 = new Point(2, 3);
Group g0 = new Group(p0);
Group g1 = new Group(p1);
Rectangle r0 = g0.getBounds();
Rectangle r1 = g1.getBounds();
assertTrue(r0 != r1);
assertTrue(g0.getBounds() == r0);
assertTrue(g1.getBounds() != r0);
assertTrue(g0.getBounds() != r1);
assertTrue(g1.getBounds() == r1);
p0.move(3, 1);
Rectangle r00 = g0.getBounds();
Rectangle r10 = g1.getBounds();
assertTrue(r10 != r00);
assertTrue(r0 != r00);
assertTrue(g0.getBounds() == r00);
Point p0 = new Point(1, 2);
Point p1 = new Point(2, 3);
Group g0 = new Group(p0);
Group g1 = new Group(p1);
Rectangle r0 = g0.getBounds();
Rectangle r1 = g1.getBounds();
assertTrue(r0 != r1);
assertTrue(g0.getBounds() == r0);
assertTrue(g1.getBounds() != r0);
assertTrue(g0.getBounds() != r1);
assertTrue(g1.getBounds() == r1);
p0.move(3, 1);
Rectangle r00 = g0.getBounds();
Rectangle r10 = g1.getBounds();
assertTrue(r10 != r00);
assertTrue(r0 != r00);
assertTrue(g0.getBounds() == r00);
}

public void testEqualityAfterMove0() {
g = new Group(p1);
Rectangle r0 = g.getBounds();
assertTrue(g.getBounds() == r0);
p1.move(3, 1);
Rectangle r1 = g.getBounds();
assertTrue(r0 != r1);
assertTrue(r1 == g.getBounds());
g = new Group(p1);
Rectangle r0 = g.getBounds();
assertTrue(g.getBounds() == r0);
p1.move(3, 1);
Rectangle r1 = g.getBounds();
assertTrue(r0 != r1);
assertTrue(r1 == g.getBounds());
}
}


+ 28
- 28
docs/teaching/exercises/tests/Test4e.java 查看文件

@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/

package tests;
@@ -30,38 +30,38 @@ public class Test4e extends Test {
}

public void testBasicEquality() {
assertTrue(g.getBounds() == g.getBounds());
assertTrue(g.getBounds() == g.getBounds());
}

public void testNonGroupMove() {
p1.move(3, 27);
p1.move(3, 27);
}

public void testEqualityAfterAddition() {
Rectangle r = g.getBounds();
g.add(new Point(37, 90));
assertTrue(g.getBounds() == r);
Rectangle r = g.getBounds();
g.add(new Point(37, 90));
assertTrue(g.getBounds() == r);
}

public void testEqualityAfterMove() {
g = new Group(p1);
Rectangle r0 = g.getBounds();
assertTrue(g.getBounds() == r0);
p1.move(3, 1);
Rectangle r1 = g.getBounds();
assertTrue(r0 != r1);
assertTrue(r1 == g.getBounds());
g = new Group(p1);
Rectangle r0 = g.getBounds();
assertTrue(g.getBounds() == r0);
p1.move(3, 1);
Rectangle r1 = g.getBounds();
assertTrue(r0 != r1);
assertTrue(r1 == g.getBounds());
}

public void testSecondEnclosingGroup() {
g = new Group(p1);
Group h = new Group(g);
Rectangle r0 = h.getBounds();
assertTrue(h.getBounds() == r0);
p1.move(3, 1);
Rectangle r1 = h.getBounds();
assertTrue(r0 != r1);
assertTrue(r1 == h.getBounds());
g = new Group(p1);
Group h = new Group(g);
Rectangle r0 = h.getBounds();
assertTrue(h.getBounds() == r0);
p1.move(3, 1);
Rectangle r1 = h.getBounds();
assertTrue(r0 != r1);
assertTrue(r1 == h.getBounds());
}
}


Loading…
取消
儲存