mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
.autotest
git-svn-id: svn://ultimatepp.org/upp/trunk@9406 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
24be661c7c
commit
d862c9c456
9 changed files with 97 additions and 6 deletions
|
|
@ -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");
|
||||
}
|
||||
|
|
|
|||
4
autotest/StringCompare/init
Normal file
4
autotest/StringCompare/init
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#ifndef _StringCompare_icpp_init_stub
|
||||
#define _StringCompare_icpp_init_stub
|
||||
#include "Core/init"
|
||||
#endif
|
||||
25
autotest/StringCompare2/StringCompare2.cpp
Normal file
25
autotest/StringCompare2/StringCompare2.cpp
Normal 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");
|
||||
}
|
||||
9
autotest/StringCompare2/StringCompare2.upp
Normal file
9
autotest/StringCompare2/StringCompare2.upp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
uses
|
||||
Core;
|
||||
|
||||
file
|
||||
StringCompare2.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "";
|
||||
|
||||
4
autotest/StringCompare2/init
Normal file
4
autotest/StringCompare2/init
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#ifndef _StringCompare2_icpp_init_stub
|
||||
#define _StringCompare2_icpp_init_stub
|
||||
#include "Core/init"
|
||||
#endif
|
||||
|
|
@ -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()
|
||||
|
|
|
|||
25
autotest/fast_memcmp/fast_memcmp.cpp
Normal file
25
autotest/fast_memcmp/fast_memcmp.cpp
Normal 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");
|
||||
}
|
||||
9
autotest/fast_memcmp/fast_memcmp.upp
Normal file
9
autotest/fast_memcmp/fast_memcmp.upp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
uses
|
||||
Core;
|
||||
|
||||
file
|
||||
fast_memcmp.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "";
|
||||
|
||||
4
autotest/fast_memcmp/init
Normal file
4
autotest/fast_memcmp/init
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#ifndef _fast_memcmp_icpp_init_stub
|
||||
#define _fast_memcmp_icpp_init_stub
|
||||
#include "Core/init"
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue