diff options
author | dhuth <derickhuth@gmail.com> | 2014-09-17 18:09:29 -0600 |
---|---|---|
committer | dhuth <derickhuth@gmail.com> | 2014-09-17 18:09:29 -0600 |
commit | 600fa18324c21a162c50c40ae5f00c899a41dd24 (patch) | |
tree | d399a8ea49c71a85abf5c07cb96b24676df32a0a /test-chill/unit-tests/cprog/main.cc | |
parent | a2bd0557344bbd8d06e94814abd409f552b0efec (diff) | |
download | chill-600fa18324c21a162c50c40ae5f00c899a41dd24.tar.gz chill-600fa18324c21a162c50c40ae5f00c899a41dd24.tar.bz2 chill-600fa18324c21a162c50c40ae5f00c899a41dd24.zip |
removed submodule, added test-chill
Diffstat (limited to 'test-chill/unit-tests/cprog/main.cc')
-rw-r--r-- | test-chill/unit-tests/cprog/main.cc | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test-chill/unit-tests/cprog/main.cc b/test-chill/unit-tests/cprog/main.cc new file mode 100644 index 0000000..3fe960b --- /dev/null +++ b/test-chill/unit-tests/cprog/main.cc @@ -0,0 +1,45 @@ +#include <cstdio> +#include <cstdlib> +#include <map> +#include <string> +#include <vector> + +#include "Sorter.h" +#include "QuickSorter.h" +#include "MergeSorter.h" +//#include "InsertionSorter.h" +//#include "ShellSorter.h" + +void read_vector(std::vector<int>& vec, int start, int stop, char** argv) { + for(int i = start; i < stop; i++) { + vec.push_back((int)strtol(argv[i],NULL,0)); + } +} + +void print_vector(std::vector<int>& vec) { + printf("["); + for(std::vector<int>::iterator iter = vec.begin(); iter != vec.end(); iter++) { + printf(" %d ", *iter); + } + printf("]\n"); +} + +void addsorter(std::map<std::string, Sorter*>& m, Sorter* s) { + m[s->name] = s; +} + +int main(int argc, char** argv) { + std::map<std::string, Sorter*> sorter_map; + std::vector<int> vec; + + read_vector(vec, 2, argc, argv); + print_vector(vec); + + addsorter(sorter_map, new QuickSorter()); + addsorter(sorter_map, new MergeSorter()); + //addsorter(sorter_map, new InsertionSorter()); + //addsorter(sorter_map, new ShellSorter()); + sorter_map[std::string(argv[1])]->sort(vec); + print_vector(vec); +} + |