Esempio n. 1
0
void test_sorts_array_of_String(){
    String names[5] = {"aaaa","bbbb","cccc","dddd","eeee"};
    void* arrayToSort[5] = {(names+3),(names+1),(names+4),(names+2),(names)};
    void* expected[5] = {(names+0),(names+1),(names+2),(names+3),(names+4)};
    sort(arrayToSort, 5, compareStrings);
    ASSERT(areArrayEqual(arrayToSort, expected, 5));
}
Esempio n. 2
0
void test_sorts_Accounts_according_to_account_number(){
    Account accounts[] = {{1, 10} , {2,100}, {3, 1000}, {4, 10}, {5, 100}};
    void* account[5] = {(accounts+3),(accounts+1),(accounts+4),(accounts+2),(accounts)};
    void* expected[5] = {(accounts+0),(accounts+1),(accounts+2),(accounts+3),(accounts+4)};
    sort(account, 5, compareAccounts);
    ASSERT(areArrayEqual(account, expected, 5));
}
Esempio n. 3
0
void test_sorts_array_of_doubles(){
    double nums[5] = {1.0,2.0,3.0,4.0,5.0};
    void* arrayToSort[5] = {&nums[4],&nums[3],&nums[2],&nums[1],&nums[0]};
    void* expected[5] = {&nums[0],&nums[1],&nums[2],&nums[3],&nums[4]};
    sort(arrayToSort, 5, compareIntegers);
    ASSERT(areArrayEqual(arrayToSort, expected, 5));
}
Esempio n. 4
0
void test_sorts_array_of_Characters(){
    char chars[5] = {'a','b','c','d','e'};
    void* arrayToSort[5] = {(chars+3),(chars+1),(chars+4),(chars+2),(chars)};
    void* expected[5] = {(chars+0),(chars+1),(chars+2),(chars+3),(chars+4)};
    sort(arrayToSort, 5, compareCharacters);
    ASSERT(areArrayEqual(arrayToSort, expected, 5));
}
Esempio n. 5
0
void test_sorts_array_of_Integers_odd_(){
    int nums[5] = {1,2,3,4,5};
    void* arrayToSort[5] = {&nums[4],&nums[3],&nums[2],&nums[1],&nums[0]};
    void* expected[5] = {&nums[0],&nums[1],&nums[2],&nums[3],&nums[4]};
    sort(arrayToSort, 5, compareIntegers);
    ASSERT(areArrayEqual(arrayToSort, expected, 5));
}
Esempio n. 6
0
void test_sorts_array_of_Integers_even_(){
    int nums[4] = {1,2,3,4};
    void* arrayToSort[4] = {&nums[3],&nums[2],&nums[1],&nums[0]};
    void* expected[4] = {&nums[0],&nums[1],&nums[2],&nums[3]};
    sort(arrayToSort, 4, compareIntegers);
    ASSERT(areArrayEqual(arrayToSort, expected, 4));
}
Esempio n. 7
0
void test_sorts_collection_of_Accounts_according_to_balance(){
    Account accounts[] = {{40, 3}, {12, 10}, {100, 100} , {23,1200}, {33, 10000}};
    void* ptrs[5] = {(accounts+3),(accounts+1),(accounts+4),(accounts+2),(accounts)};
    void* expected[5] = {(accounts+0),(accounts+1),(accounts+2),(accounts+3),(accounts+4)};
    isort(ptrs, 5, compareAccountsByBalance);
    ASSERT(areArrayEqual(ptrs, expected, 5));
}
Esempio n. 8
0
void test_sorts_collections_of_String(){
    String names[5] = {"Raaj","Raam","Raaz","Rahul","Rajan"};
    void* ptrs[5] = {(names+3),(names+1),(names+4),(names+2),(names)};
    void* expected[5] = {(names+0),(names+1),(names+2),(names+3),(names+4)};
    isort(ptrs, 5, compareStrings);
    ASSERT(areArrayEqual(ptrs, expected, 5));
}
Esempio n. 9
0
void test_sorts_collections_of_Characters(){
    char chars[5] = {'a','b','r','u','z'};
    void* ptrs[5] = {(chars+3),(chars+1),(chars+4),(chars+2),(chars)};
    void* expected[5] = {(chars+0),(chars+1),(chars+2),(chars+3),(chars+4)};
    isort(ptrs, 5, compareChars);
    ASSERT(areArrayEqual(ptrs, expected, 5));
}
Esempio n. 10
0
void test_sorts_collections_of_Doubles(){
    double nums[5] = {1.0,2.0,3.0,5.0,7.0};
    void* ptrs[5] = {(nums+3),(nums+1),(nums+4),(nums+2),(nums)};
    void* expected[5] = {(nums+0),(nums+1),(nums+2),(nums+3),(nums+4)};
    isort(ptrs, 5, compareDoubles);
    ASSERT(areArrayEqual(ptrs, expected, 5));
}
Esempio n. 11
0
void test_sorts_collections_of_Integers(){
    int nums[5] = {5,10,12,20,25};
    void* ptrs[5] = {&nums[4],&nums[3],&nums[2],&nums[1],&nums[0]};
    void* expected[5] = {&nums[0],&nums[1],&nums[2],&nums[3],&nums[4]};
    isort(ptrs, 5, compareInt);
    ASSERT(areArrayEqual(ptrs, expected, 5));
}