Browse Source

Put the unit test for MedianPixel back

Rafael Arce Nazario 9 years ago
parent
commit
c2107d2c43
1 changed files with 24 additions and 5 deletions
  1. 24
    5
      Filter.cpp

+ 24
- 5
Filter.cpp View File

53
 }
53
 }
54
 
54
 
55
 void test_MedianPixel() {
55
 void test_MedianPixel() {
56
+    vector<QRgb> V;
56
 
57
 
57
-    // Implement your unit test for median pixel here .....
58
 
58
 
59
-    messageBox("MedianPixel unit test not yet implemented!!");
59
+    V.push_back(qRgb(10,20,30));
60
+    V.push_back(qRgb(10,30,10));
61
+    V.push_back(qRgb(20, 0,15));
62
+
63
+
64
+    QRgb result = MedianPixel(V);
65
+
66
+    assert(qRed(result) == 10);
67
+    assert(qGreen(result) == 20);
68
+    assert(qBlue(result) == 15);
69
+
70
+    V.push_back(qRgb(0, 10,20));
71
+
72
+    result = MedianPixel(V);
73
+    assert(qRed(result) == 10);
74
+    assert(qGreen(result) == 15);
75
+    assert(qBlue(result) == 17);
76
+
77
+
78
+    cout << "MedianPixel passed the test!!" << endl;
60
 }
79
 }
61
 
80
 
62
 
81
 
64
 
83
 
65
 void MainWindow::RemoveNoise(const vector<QImage> & images, QImage & finalImage){
84
 void MainWindow::RemoveNoise(const vector<QImage> & images, QImage & finalImage){
66
 
85
 
67
-    test_Sort();
68
-    test_Median();
69
-    test_MedianPixel();
86
+    // test_Sort();
87
+    // test_Median();
88
+    // test_MedianPixel();
70
 
89
 
71
     // Implement the filter here! See the algorithm in the lab
90
     // Implement the filter here! See the algorithm in the lab
72
     messageBox("RemoveNoise function not yet implemented!!!");
91
     messageBox("RemoveNoise function not yet implemented!!!");