Last active
November 18, 2016 17:50
-
-
Save raarce/755c1daa7733704abe555051c0b6f962 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Given a vector will return true if sorted ascending | |
// Dado un vector regresa true si sus datos estan en orden ascendente | |
bool isSorted(const vector<int> &V) { | |
for (unsigned int i = 0; i < V.size() - 1; i++) { | |
if (V[i] > V[i+1]) return false; | |
} | |
return true; | |
} | |
void test_Sort() { | |
vector<int> V; | |
// Create a vector with random values | |
// Crear un vector con valores random | |
srand(time(NULL)); | |
for (int i = 0; i < 100; i++) V.push_back(i); | |
// Create a dummy window to invoke PixelSort | |
// Crear una ventana temporera para poder invocarle la función PixelSort | |
Sort(V); | |
assert(isSorted(V)); | |
cout << "Sort passed the test!!" << endl; | |
} | |
void test_Median() { | |
int A[] = {0, 10, 8}; | |
vector<int> VA(A,A+3); | |
assert(Median(VA)==8); | |
int B[] = {-1, 0, 10, 80}; | |
vector<int> VB(B,B+4); | |
assert(Median(VB)==5); | |
cout << "Function Median passed the tests!!" << endl; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment