Advertisement
Guest User

Untitled

a guest
May 28th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. package sample;
  2.  
  3. import junit.framework.TestCase;
  4.  
  5. /**
  6. *
  7. * @author nb
  8. */
  9. public class VectorsJUnit3Test extends TestCase {
  10.  
  11. public VectorsJUnit3Test(String testName) {
  12. super(testName);
  13. }
  14.  
  15. /**
  16. * Test of equal method, of class Vectors.
  17. */
  18. public void testEqual() {
  19. System.out.println("* VectorsJUnit3Test: testEqual()");
  20. assertTrue(Vectors.equal(new int[]{}, new int[]{}));
  21. assertTrue(Vectors.equal(new int[]{0}, new int[]{0}));
  22. assertTrue(Vectors.equal(new int[]{0, 0}, new int[]{0, 0}));
  23. assertTrue(Vectors.equal(new int[]{0, 0, 0}, new int[]{0, 0, 0}));
  24. assertTrue(Vectors.equal(new int[]{5, 6, 7}, new int[]{5, 6, 7}));
  25.  
  26. assertFalse(Vectors.equal(new int[]{}, new int[]{0}));
  27. assertFalse(Vectors.equal(new int[]{0}, new int[]{0, 0}));
  28. assertFalse(Vectors.equal(new int[]{0, 0}, new int[]{0, 0, 0}));
  29. assertFalse(Vectors.equal(new int[]{0, 0, 0}, new int[]{0, 0}));
  30. assertFalse(Vectors.equal(new int[]{0, 0}, new int[]{0}));
  31. assertFalse(Vectors.equal(new int[]{0}, new int[]{}));
  32.  
  33. assertFalse(Vectors.equal(new int[]{0, 0, 0}, new int[]{0, 0, 1}));
  34. assertFalse(Vectors.equal(new int[]{0, 0, 0}, new int[]{0, 1, 0}));
  35. assertFalse(Vectors.equal(new int[]{0, 0, 0}, new int[]{1, 0, 0}));
  36. assertFalse(Vectors.equal(new int[]{0, 0, 1}, new int[]{0, 0, 3}));
  37. }
  38.  
  39. /**
  40. * Test of scalarMultiplication method, of class Vectors.
  41. */
  42. public void testScalarMultiplication() {
  43. System.out.println("* VectorsJUnit3Test: testScalarMultiplication()");
  44. assertEquals(0, Vectors.scalarMultiplication(new int[]{0, 0}, new int[]{0, 0}));
  45. assertEquals(39, Vectors.scalarMultiplication(new int[]{3, 4}, new int[]{5, 6}));
  46. assertEquals(-39, Vectors.scalarMultiplication(new int[]{-3, 4}, new int[]{5, -6}));
  47. assertEquals(0, Vectors.scalarMultiplication(new int[]{5, 9}, new int[]{-9, 5}));
  48. assertEquals(100, Vectors.scalarMultiplication(new int[]{6, 8}, new int[]{6, 8}));
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement