a simple bubblesort example.

BubblesTest.java 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import static org.junit.Assert.*;
  2. import org.junit.After;
  3. import org.junit.Before;
  4. import org.junit.Test;
  5. /**
  6. * The test class BubblesTest.
  7. *
  8. * @author (your name)
  9. * @version (a version number or a date)
  10. */
  11. public class BubblesTest
  12. {
  13. /**
  14. * Default constructor for test class BubblesTest
  15. */
  16. public BubblesTest()
  17. {
  18. }
  19. /**
  20. * Sets up the test fixture.
  21. *
  22. * Called before every test case method.
  23. */
  24. @Before
  25. public void setUp()
  26. {
  27. }
  28. /**
  29. * Tears down the test fixture.
  30. *
  31. * Called after every test case method.
  32. */
  33. @After
  34. public void tearDown()
  35. {
  36. }
  37. @Test
  38. public void bTest()
  39. {
  40. Bubbles bubbles1 = new Bubbles();
  41. boolean flag = false;
  42. int[] test = new int[]{9, 8, 2, 3, 1, 5, 6};
  43. test = bubbles1.bubbleSort(test);
  44. for (int i = 0; i < test.length-2; i++) {
  45. if (test[i] < test[i+1]) {
  46. flag = true;
  47. }
  48. }
  49. assertEquals(true, flag);
  50. }
  51. }