mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
.reference
git-svn-id: svn://ultimatepp.org/upp/trunk@11364 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
443f7d3dc7
commit
e163f79974
4 changed files with 82 additions and 0 deletions
35
autotest/AsyncWork/AsyncWork.cpp
Normal file
35
autotest/AsyncWork/AsyncWork.cpp
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#include <Core/Core.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
template <class Range>
|
||||
ValueTypeOf<Range> ASum(const Range& rng)
|
||||
{
|
||||
int n = rng.GetCount();
|
||||
if(n == 1)
|
||||
return rng[0];
|
||||
if(n == 0)
|
||||
return 0;
|
||||
auto l = Async([&] { return ASum(SubRange(rng, 0, n / 2)); });
|
||||
auto r = Async([&] { return ASum(SubRange(rng, n / 2, n - n / 2)); });
|
||||
return l.Get() + r.Get();
|
||||
}
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
StdLogSetup(LOG_COUT|LOG_FILE);
|
||||
|
||||
Vector<int> h;
|
||||
for(int i = 0; i < 1000000; i++)
|
||||
h.Add(Random());
|
||||
|
||||
DDUMP(CoSum(h));
|
||||
DDUMP(Sum(h));
|
||||
DDUMP(ASum(h));
|
||||
ASSERT(ASum(h) == Sum(h));
|
||||
ASSERT(ASum(h) == CoSum(h));
|
||||
|
||||
LOG("------------- OK");
|
||||
}
|
||||
|
||||
|
||||
9
autotest/AsyncWork/AsyncWork.upp
Normal file
9
autotest/AsyncWork/AsyncWork.upp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
uses
|
||||
Core;
|
||||
|
||||
file
|
||||
AsyncWork.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "";
|
||||
|
||||
11
autotest/IdCtrls/IdCtrls.upp
Normal file
11
autotest/IdCtrls/IdCtrls.upp
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
description "Connecting Sqlite3 database\377";
|
||||
|
||||
uses
|
||||
CtrlLib;
|
||||
|
||||
file
|
||||
main.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "";
|
||||
|
||||
27
autotest/IdCtrls/main.cpp
Normal file
27
autotest/IdCtrls/main.cpp
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#include <CtrlLib/CtrlLib.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
StdLogSetup(LOG_COUT|LOG_FILE);
|
||||
|
||||
EditString a, b;
|
||||
IdCtrls idctrls;
|
||||
|
||||
idctrls("A", a)("B", b);
|
||||
|
||||
a <<= "Hello";
|
||||
b <<= "world";
|
||||
|
||||
ValueMap m = ~idctrls;
|
||||
DUMP(m);
|
||||
|
||||
ASSERT(m["A"] == "Hello");
|
||||
ASSERT(m["B"] == "world");
|
||||
|
||||
m("A") = "Test";
|
||||
idctrls <<= m;
|
||||
DUMP(~a);
|
||||
ASSERT(~a == "Test");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue