.autotest

git-svn-id: svn://ultimatepp.org/upp/trunk@7228 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2014-04-12 12:26:36 +00:00
parent 9db077ed90
commit c834f9edf3
4 changed files with 10 additions and 68 deletions

View file

@ -10,70 +10,70 @@ CONSOLE_APP_MAIN
{
Callback cb;
cb = [&] { a = 1; LOG("Callback"); };
cb = lambda([&] { a = 1; LOG("Callback"); });
cb();
ASSERT(a == 1);
}
{
Callback1<int> cb;
cb = [&](int b) { a = b; LOG("Callback1"); };
cb = lambda([&](int b) { a = b; LOG("Callback1"); });
cb(123);
ASSERT(a == 123);
}
{
Callback2<int, int> cb;
cb = [&](int b, int c) { a = b + c; LOG("Callback2"); };
cb = lambda([&](int b, int c) { a = b + c; LOG("Callback2"); });
cb(1, 20);
ASSERT(a == 21);
}
{
Callback3<int, int, int> cb;
cb = [&](int b, int c, int d) { a = b + c + d; LOG("Callback3"); };
cb = lambda([&](int b, int c, int d) { a = b + c + d; LOG("Callback3"); });
cb(1, 20, 300);
ASSERT(a == 321);
}
{
Callback4<int, int, int, int> cb;
cb = [&](int b, int c, int d, int e) { a = b + c + d + e; LOG("Callback4"); };
cb = lambda([&](int b, int c, int d, int e) { a = b + c + d + e; LOG("Callback4"); });
cb(1, 20, 300, 4000);
ASSERT(a == 4321);
}
{
Gate cb;
cb = [&] { a = 1; LOG("Gate"); return true; };
cb = lambda([&] { a = 1; LOG("Gate"); return true; });
ASSERT(cb());
ASSERT(a == 1);
}
{
Gate1<int> cb;
cb = [&](int b) { a = b; LOG("Gate1"); return false; };
cb = lambda([&](int b) { a = b; LOG("Gate1"); return false; });
ASSERT(!cb(123));
ASSERT(a == 123);
}
{
Gate2<int, int> cb;
cb = [&](int b, int c) { a = b + c; LOG("Gate2"); return true; };
cb = lambda([&](int b, int c) { a = b + c; LOG("Gate2"); return true; });
ASSERT(cb(1, 20));
ASSERT(a == 21);
}
{
Gate3<int, int, int> cb;
cb = [&](int b, int c, int d) { a = b + c + d; LOG("Gate3"); return true; };
cb = lambda([&](int b, int c, int d) { a = b + c + d; LOG("Gate3"); return true; });
ASSERT(cb(1, 20, 300));
ASSERT(a == 321);
}
{
Gate4<int, int, int, int> cb;
cb = [&](int b, int c, int d, int e) { a = b + c + d + e; LOG("Gate4"); return true; };
cb = lambda([&](int b, int c, int d, int e) { a = b + c + d + e; LOG("Gate4"); return true; });
ASSERT(cb(1, 20, 300, 4000));
ASSERT(a == 4321);
}

View file

@ -1,45 +0,0 @@
#include <Core/Core.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
StdLogSetup(LOG_COUT|LOG_FILE);
String rndset;
rndset << "[]<>;`%%%%";
rndset << rndset;
rndset << rndset;
rndset << rndset;
for(int i = 32; i < 128; i++)
if(IsAlpha(i) || IsDigit(i))
rndset.Cat(i);
SeedRandom();
int time0 = msecs();
while(msecs(time0) < 150000) {
String fmtstr;
while(Random(20))
fmtstr << (char)rndset[Random(rndset.GetCount())];
Vector<Value> v;
for(;;) {
int q = Random(5);
if(q == 0)
break;
switch(q) {
case 1:
v.Add((int)Random(100));
break;
case 2:
v.Add(AsString(Random(100)));
break;
case 3:
v.Add(GetSysDate() + Random(100));
break;
}
}
DUMP(fmtstr);
DUMP(v);
DUMP(NFormat(fmtstr, v));
}
LOG("============ OK");
}

View file

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

View file

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