An automatic sort test frame work in Cmake and xmake
Xmake is preferred, update in CMake might be latter than Xmake
-
With Cmake:
cmake -B build build cmake --build build ./build/bin/sort
-
With xmake:
xmake xmake run
If you are using xmake, a debug version is built by default. If you want a fast version without debug symbols and so on, run:
xmake f -m fastest
xmake build
xmake run
In version 1.0.0, executable in fastest mode will cost 7ms while debug version costs 77 ms for 18 tests.
-
Implement your sorting algorithm, provide a callable object to
algorithms
insrc/main.cpp
. If you are not sure if your code fits the requirement, here is a small example:struct qsort_wrapper { inline __attribute__((always_inline)) void operator()(std::vector<int> &vec) { std::sort(vec.begin(), vec.end()); } };
Or you can inherit
sort_algorithm_base
ininclude/sort_algorithm_base.hpp
and overrideoperator()
and provide an instance of the class, just like the example codes insrc/main.cpp
. -
Compile and run codes as Quick Start