You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Test.java 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* *******************************************************************
  2. * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Common Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/cpl-v10.html
  8. *
  9. * Contributors:
  10. * PARC initial implementation
  11. * ******************************************************************/
  12. package tests;
  13. import figures.*;
  14. import junit.framework.*;
  15. public class Test extends TestCase {
  16. public Test(String name) { super(name); }
  17. public static void main(String[] args) {
  18. junit.textui.TestRunner.run(Test.class);
  19. }
  20. Box bb;
  21. Point p1;
  22. Point p2;
  23. Line l1;
  24. SlothfulPoint sloth1;
  25. Group g;
  26. public void setUp() {
  27. p1 = new Point(10, 100);
  28. p2 = new Point(20, 200);
  29. l1 = new Line(p1, p2);
  30. bb = new Box(5, 5, 10, 10);
  31. sloth1 = new SlothfulPoint(0, 0);
  32. g = new Group(p1);
  33. }
  34. public final void testCreate() {
  35. assertEquals(p1.getX(), 10);
  36. assertEquals(p1.getY(), 100);
  37. assertEquals(l1.getP1(), p1);
  38. assertEquals(l1.getP2(), p2);
  39. }
  40. public final void testSetPoint() {
  41. p1.setX(20);
  42. assertEquals(p1.getX(), 20);
  43. assertEquals(p1.getY(), 100);
  44. p1.setY(10);
  45. assertEquals(p1.getX(), 20);
  46. assertEquals(p1.getY(), 10);
  47. }
  48. public final void testMoveLine1() {
  49. l1.move(40, 40);
  50. assertEquals(l1.getP1(), p1);
  51. assertEquals(l1.getP2(), p2);
  52. assertEquals(p1.getX(), 50);
  53. assertEquals(p1.getY(), 140);
  54. assertEquals(p2.getX(), 60);
  55. assertEquals(p2.getY(), 240);
  56. }
  57. public final void testMoveLine2() {
  58. l1.move(-10, -10);
  59. assertEquals(p1.getX(), 0);
  60. assertEquals(p1.getY(), 90);
  61. assertEquals(p2.getX(), 10);
  62. assertEquals(p2.getY(), 190);
  63. }
  64. }