diff --git a/autotest/StringCompare/StringCompare.cpp b/autotest/StringCompare/StringCompare.cpp index 82ab917f2..5ef1cbc68 100644 --- a/autotest/StringCompare/StringCompare.cpp +++ b/autotest/StringCompare/StringCompare.cpp @@ -1,14 +1,21 @@ #include -#define LDUMP(x) -#define LLOGHEXDUMP(a, b) +#define LDUMP(x) // DUMP(x) +#define LLOGHEXDUMP(a, b) // LOGHEXDUMP(a, b) using namespace Upp; #define N 10000000 +int RandomChar() +{ + return '0' + Random(64); +} + CONSOLE_APP_MAIN { + StdLogSetup(LOG_COUT|LOG_FILE); + for(int q = 0; q < N; q++) { LDUMP(q); if(q % 10000 == 0) @@ -18,14 +25,16 @@ CONSOLE_APP_MAIN int l2 = rand() % 40; String a, b; for(int i = 0; i < eq; i++) - a.Cat(rand() % 254 + 1); + a.Cat(RandomChar()); b = a; ASSERT(a.Compare(b) == 0); for(int i = 0; i < l1; i++) - a.Cat(rand() % 254 + 1); + a.Cat(RandomChar()); for(int i = 0; i < l2; i++) - b.Cat(rand() % 254 + 1); + b.Cat(RandomChar()); int l = min(l1, l2) + eq; + LDUMP(a); + LDUMP(b); LLOGHEXDUMP(a, a.GetLength()); LLOGHEXDUMP(b, b.GetLength()); LDUMP(a.Compare(b)); @@ -35,4 +44,6 @@ CONSOLE_APP_MAIN ASSERT(a.Compare(a) == 0); ASSERT(b.Compare(b) == 0); } + + LOG("------------ OK"); } diff --git a/autotest/StringCompare/init b/autotest/StringCompare/init new file mode 100644 index 000000000..4fc22d92e --- /dev/null +++ b/autotest/StringCompare/init @@ -0,0 +1,4 @@ +#ifndef _StringCompare_icpp_init_stub +#define _StringCompare_icpp_init_stub +#include "Core/init" +#endif diff --git a/autotest/StringCompare2/StringCompare2.cpp b/autotest/StringCompare2/StringCompare2.cpp new file mode 100644 index 000000000..75ea5629c --- /dev/null +++ b/autotest/StringCompare2/StringCompare2.cpp @@ -0,0 +1,25 @@ +#include +#include + +using namespace Upp; + +#define N 1000000 + +CONSOLE_APP_MAIN +{ + StdLogSetup(LOG_COUT | LOG_FILE); + + Vector a; + std::vector b; + for(int i = 0; i < N; i++) { + String h = FormatIntBase(Random(10000) * Random(10000), 2); + a.Add(h); + b.push_back(h.ToStd()); + } + Sort(a); + std::sort(b.begin(), b.end()); + for(int i = 0; i < N; i++) + ASSERT(a[i].ToStd() == b[i]); + + LOG("----------------- OK"); +} diff --git a/autotest/StringCompare2/StringCompare2.upp b/autotest/StringCompare2/StringCompare2.upp new file mode 100644 index 000000000..ad0bedb33 --- /dev/null +++ b/autotest/StringCompare2/StringCompare2.upp @@ -0,0 +1,9 @@ +uses + Core; + +file + StringCompare2.cpp; + +mainconfig + "" = ""; + diff --git a/autotest/StringCompare2/init b/autotest/StringCompare2/init new file mode 100644 index 000000000..e449e118b --- /dev/null +++ b/autotest/StringCompare2/init @@ -0,0 +1,4 @@ +#ifndef _StringCompare2_icpp_init_stub +#define _StringCompare2_icpp_init_stub +#include "Core/init" +#endif diff --git a/autotest/SvoValue/Raw.cpp b/autotest/SvoValue/Raw.cpp index 4ce9f8853..9fb231ac1 100644 --- a/autotest/SvoValue/Raw.cpp +++ b/autotest/SvoValue/Raw.cpp @@ -26,7 +26,7 @@ void CheckRawPickValue() ASSERT(x2.GetCount() == 1); ASSERT(x2[0] == 321); ASSERT(x.GetCount() == 1); - ASSERT(x[0] == 321); + ASSERT(x[0] == 321); } void CheckCreateRawValue() diff --git a/autotest/fast_memcmp/fast_memcmp.cpp b/autotest/fast_memcmp/fast_memcmp.cpp new file mode 100644 index 000000000..9d0fd63d6 --- /dev/null +++ b/autotest/fast_memcmp/fast_memcmp.cpp @@ -0,0 +1,25 @@ +#include + +using namespace Upp; + +#define N 100000000 + +CONSOLE_APP_MAIN +{ + StdLogSetup(LOG_COUT|LOG_FILE); + + for(int i = 0; i < N; i++) { + if(i % 1000000 == 0) + LOG(i); + String a('x', Random(10)); + String b('x', Random(10)); + a << AsString(Random()); + b << AsString(Random()); + + int n = min(a.GetLength(), b.GetLength()); + + ASSERT(sgn(fast_memcmp((byte *)~a, (byte *)~b, n)) == sgn(memcmp((byte *)~a, (byte *)~b, n))); + } + + LOG("------------ OK"); +} diff --git a/autotest/fast_memcmp/fast_memcmp.upp b/autotest/fast_memcmp/fast_memcmp.upp new file mode 100644 index 000000000..ac846af9b --- /dev/null +++ b/autotest/fast_memcmp/fast_memcmp.upp @@ -0,0 +1,9 @@ +uses + Core; + +file + fast_memcmp.cpp; + +mainconfig + "" = ""; + diff --git a/autotest/fast_memcmp/init b/autotest/fast_memcmp/init new file mode 100644 index 000000000..3b231e6dd --- /dev/null +++ b/autotest/fast_memcmp/init @@ -0,0 +1,4 @@ +#ifndef _fast_memcmp_icpp_init_stub +#define _fast_memcmp_icpp_init_stub +#include "Core/init" +#endif