diff --git a/upptst/Sort/Sort.cpp b/upptst/Sort/Sort.cpp new file mode 100644 index 000000000..55125dd1a --- /dev/null +++ b/upptst/Sort/Sort.cpp @@ -0,0 +1,48 @@ +#include + +using namespace Upp; + +Vector GetStringData() +{ + Vector data; + int n = Random(100) * Random(100) * Random(10); + for(int i = 0; i < n; i++) + data.Add(AsString(Random(n))); + return data; +} + +Vector GetIntData() +{ + Vector data; + int n = Random(100) * Random(100) * Random(10); + for(int i = 0; i < n; i++) + data.Add(Random(n)); + return data; +} + +template +void CheckSorted(C& data) +{ + for(int i = 0; i < data.GetCount() - 1; i++) { + if(!(data[i] <= data[i + 1])) { + RDUMPC(data); + RLOG("ERROR! " << i); + Exit(1); + } + } +} + +CONSOLE_APP_MAIN +{ + StdLogSetup(LOG_FILE|LOG_COUT); + for(;;) { + Vector data = GetIntData(); + LOG("int " << data.GetCount()); + Sort(data); + CheckSorted(data); + Vector sdata = GetStringData(); + LOG("String " << sdata.GetCount()); + Sort(sdata); + CheckSorted(sdata); + } +} diff --git a/upptst/Sort/Sort.upp b/upptst/Sort/Sort.upp new file mode 100644 index 000000000..c5e156710 --- /dev/null +++ b/upptst/Sort/Sort.upp @@ -0,0 +1,9 @@ +uses + Core; + +file + Sort.cpp; + +mainconfig + "" = "SSE2"; + diff --git a/upptst/Sort/init b/upptst/Sort/init new file mode 100644 index 000000000..469e7938f --- /dev/null +++ b/upptst/Sort/init @@ -0,0 +1,4 @@ +#ifndef _Sort_icpp_init_stub +#define _Sort_icpp_init_stub +#include "Core/init" +#endif diff --git a/upptst/StableSort/StableSort.upp b/upptst/StableSort/StableSort.upp index e65491935..0e78ff460 100644 --- a/upptst/StableSort/StableSort.upp +++ b/upptst/StableSort/StableSort.upp @@ -1,8 +1,9 @@ -uses - Core; - -file - StableSort.cpp; - -mainconfig - "" = ""; +uses + Core; + +file + StableSort.cpp; + +mainconfig + "" = ""; +