Browse Source

non-trivial test

Kr Younger 6 years ago
parent
commit
f80643245f
8 changed files with 146 additions and 0 deletions
  1. BIN
      Bubbles.class
  2. 10
    0
      Bubbles.ctxt
  3. 48
    0
      Bubbles.java
  4. BIN
      BubblesTest.class
  5. 15
    0
      BubblesTest.ctxt
  6. 58
    0
      BubblesTest.java
  7. 12
    0
      README.TXT
  8. 3
    0
      package.bluej

BIN
Bubbles.class View File


+ 10
- 0
Bubbles.ctxt View File

@@ -0,0 +1,10 @@
1
+#BlueJ class context
2
+comment0.target=Bubbles
3
+comment0.text=\n\ Write\ a\ description\ of\ class\ Bubbles\ here.\n\n\ @author\ (your\ name)\n\ @version\ (a\ version\ number\ or\ a\ date)\n
4
+comment1.params=
5
+comment1.target=Bubbles()
6
+comment1.text=\n\ Constructor\ for\ objects\ of\ class\ Bubbles\n
7
+comment2.params=a
8
+comment2.target=int[]\ bubbleSort(int[])
9
+comment2.text=\n\ An\ example\ of\ a\ method\ -\ replace\ this\ comment\ with\ your\ own\n\n\ @param\ \ y\ \ a\ sample\ parameter\ for\ a\ method\n\ @return\ \ \ \ the\ sum\ of\ x\ and\ y\n
10
+numComments=3

+ 48
- 0
Bubbles.java View File

@@ -0,0 +1,48 @@
1
+import java.util.Arrays;
2
+
3
+/**
4
+ * Write a description of class Bubbles here.
5
+ *
6
+ * @author (your name)
7
+ * @version (a version number or a date)
8
+ */
9
+public class Bubbles
10
+{
11
+    // instance variables - replace the example below with your own
12
+    private int x;
13
+
14
+    /**
15
+     * Constructor for objects of class Bubbles
16
+     */
17
+    public Bubbles()
18
+    {
19
+        // initialise instance variables
20
+        x = 0;
21
+    }
22
+
23
+    /**
24
+     * An example of a method - replace this comment with your own
25
+     *
26
+     * @param  y  a sample parameter for a method
27
+     * @return    the sum of x and y
28
+     */
29
+    public int[] bubbleSort(int[] a)
30
+    {
31
+        System.out.println("0 : " +Arrays.toString(a));
32
+        boolean flag = true;
33
+        while (flag == true) {
34
+            flag=false;
35
+            for (int i = 0; i < a.length-1; i++) {
36
+                if (a[i] > a[i+1]) {
37
+                    flag = true;
38
+                    int temp = a[i];
39
+                    a[i] = a[i+1];
40
+                    a[i+1] = temp;
41
+                }
42
+            }
43
+            System.out.println("  : " + Arrays.toString(a));
44
+        }
45
+        System.out.println("end " + Arrays.toString(a));
46
+        return a;
47
+    }
48
+}

BIN
BubblesTest.class View File


+ 15
- 0
BubblesTest.ctxt View File

@@ -0,0 +1,15 @@
1
+#BlueJ class context
2
+comment0.target=BubblesTest
3
+comment0.text=\n\ The\ test\ class\ BubblesTest.\n\n\ @author\ \ (your\ name)\n\ @version\ (a\ version\ number\ or\ a\ date)\n
4
+comment1.params=
5
+comment1.target=BubblesTest()
6
+comment1.text=\n\ Default\ constructor\ for\ test\ class\ BubblesTest\n
7
+comment2.params=
8
+comment2.target=void\ setUp()
9
+comment2.text=\n\ Sets\ up\ the\ test\ fixture.\n\n\ Called\ before\ every\ test\ case\ method.\n
10
+comment3.params=
11
+comment3.target=void\ tearDown()
12
+comment3.text=\n\ Tears\ down\ the\ test\ fixture.\n\n\ Called\ after\ every\ test\ case\ method.\n
13
+comment4.params=
14
+comment4.target=void\ bTest()
15
+numComments=5

+ 58
- 0
BubblesTest.java View File

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

+ 12
- 0
README.TXT View File

@@ -0,0 +1,12 @@
1
+------------------------------------------------------------------------
2
+This is the project README file. Here, you should describe your project.
3
+Tell the reader (someone who does not know anything about this project)
4
+all he/she needs to know. The comments should usually include at least:
5
+------------------------------------------------------------------------
6
+
7
+PROJECT TITLE:
8
+PURPOSE OF PROJECT:
9
+VERSION or DATE:
10
+HOW TO START THIS PROJECT:
11
+AUTHORS:
12
+USER INSTRUCTIONS:

+ 3
- 0
package.bluej View File

@@ -0,0 +1,3 @@
1
+#BlueJ package file
2
+#Fri Jun 01 17:31:30 EDT 2018
3
+project.charset=UTF-8