.autotest

git-svn-id: svn://ultimatepp.org/upp/trunk@9406 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2016-01-16 14:38:54 +00:00
parent 24be661c7c
commit d862c9c456
9 changed files with 97 additions and 6 deletions

View file

@ -1,14 +1,21 @@
#include <Core/Core.h>
#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");
}

View file

@ -0,0 +1,4 @@
#ifndef _StringCompare_icpp_init_stub
#define _StringCompare_icpp_init_stub
#include "Core/init"
#endif

View file

@ -0,0 +1,25 @@
#include <Core/Core.h>
#include <vector>
using namespace Upp;
#define N 1000000
CONSOLE_APP_MAIN
{
StdLogSetup(LOG_COUT | LOG_FILE);
Vector<String> a;
std::vector<std::string> 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");
}

View file

@ -0,0 +1,9 @@
uses
Core;
file
StringCompare2.cpp;
mainconfig
"" = "";

View file

@ -0,0 +1,4 @@
#ifndef _StringCompare2_icpp_init_stub
#define _StringCompare2_icpp_init_stub
#include "Core/init"
#endif

View file

@ -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()

View file

@ -0,0 +1,25 @@
#include <Core/Core.h>
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");
}

View file

@ -0,0 +1,9 @@
uses
Core;
file
fast_memcmp.cpp;
mainconfig
"" = "";

View file

@ -0,0 +1,4 @@
#ifndef _fast_memcmp_icpp_init_stub
#define _fast_memcmp_icpp_init_stub
#include "Core/init"
#endif