From efd128cc7044e5fc065fd5080b53c79edfd84378 Mon Sep 17 00:00:00 2001 From: cxl Date: Sat, 11 Jun 2016 15:56:01 +0000 Subject: [PATCH] .upptst git-svn-id: svn://ultimatepp.org/upp/trunk@9922 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- upptst/Assist/main.cpp | 9 ++++ upptst/CheckCompile/CheckCompile.h | 17 +++++++ upptst/CheckCompile/CheckCompile.lay | 3 ++ upptst/CheckCompile/CheckCompile.upp | 12 +++++ upptst/CheckCompile/init | 5 ++ upptst/CheckCompile/main.cpp | 17 +++++++ upptst/MapRange/MapRange.cpp | 43 ++++++++++++++++ upptst/MapRange/MapRange.upp | 9 ++++ upptst/MapRange/init | 4 ++ upptst/Range/Range.cpp | 74 ++++++++++++++++++++++++++++ upptst/Range/Range.upp | 9 ++++ upptst/Range/init | 4 ++ upptst/Tuple/Tuple.cpp | 71 ++++++++++++++++++++++++++ upptst/Tuple/Tuple.upp | 9 ++++ upptst/Tuple/init | 4 ++ 15 files changed, 290 insertions(+) create mode 100644 upptst/CheckCompile/CheckCompile.h create mode 100644 upptst/CheckCompile/CheckCompile.lay create mode 100644 upptst/CheckCompile/CheckCompile.upp create mode 100644 upptst/CheckCompile/init create mode 100644 upptst/CheckCompile/main.cpp create mode 100644 upptst/MapRange/MapRange.cpp create mode 100644 upptst/MapRange/MapRange.upp create mode 100644 upptst/MapRange/init create mode 100644 upptst/Range/Range.cpp create mode 100644 upptst/Range/Range.upp create mode 100644 upptst/Range/init create mode 100644 upptst/Tuple/Tuple.cpp create mode 100644 upptst/Tuple/Tuple.upp create mode 100644 upptst/Tuple/init diff --git a/upptst/Assist/main.cpp b/upptst/Assist/main.cpp index 104e1d8ab..14f93e739 100644 --- a/upptst/Assist/main.cpp +++ b/upptst/Assist/main.cpp @@ -497,6 +497,15 @@ void Autocomplete() { // ---------------------------------------------------- +void JumpToLayout() +{ + WithPrinterLayout h; + + SetLayout_PrinterLayout(h); +} + +// ---------------------------------------------------- + struct Foo { typedef Foo CLASSNAME; diff --git a/upptst/CheckCompile/CheckCompile.h b/upptst/CheckCompile/CheckCompile.h new file mode 100644 index 000000000..2b9adc72f --- /dev/null +++ b/upptst/CheckCompile/CheckCompile.h @@ -0,0 +1,17 @@ +#ifndef _CheckCompile_CheckCompile_h +#define _CheckCompile_CheckCompile_h + +#include + +using namespace Upp; + +#define LAYOUTFILE +#include + +class CheckCompile : public WithCheckCompileLayout { +public: + typedef CheckCompile CLASSNAME; + CheckCompile(); +}; + +#endif diff --git a/upptst/CheckCompile/CheckCompile.lay b/upptst/CheckCompile/CheckCompile.lay new file mode 100644 index 000000000..f93d9ea58 --- /dev/null +++ b/upptst/CheckCompile/CheckCompile.lay @@ -0,0 +1,3 @@ + +LAYOUT(CheckCompileLayout, 200, 100) +END_LAYOUT diff --git a/upptst/CheckCompile/CheckCompile.upp b/upptst/CheckCompile/CheckCompile.upp new file mode 100644 index 000000000..db57c9241 --- /dev/null +++ b/upptst/CheckCompile/CheckCompile.upp @@ -0,0 +1,12 @@ +uses + CtrlLib, + RichEdit; + +file + CheckCompile.h, + main.cpp, + CheckCompile.lay; + +mainconfig + "" = "GUI"; + diff --git a/upptst/CheckCompile/init b/upptst/CheckCompile/init new file mode 100644 index 000000000..30c813af8 --- /dev/null +++ b/upptst/CheckCompile/init @@ -0,0 +1,5 @@ +#ifndef _CheckCompile_icpp_init_stub +#define _CheckCompile_icpp_init_stub +#include "CtrlLib/init" +#include "RichEdit/init" +#endif diff --git a/upptst/CheckCompile/main.cpp b/upptst/CheckCompile/main.cpp new file mode 100644 index 000000000..1725b0d8c --- /dev/null +++ b/upptst/CheckCompile/main.cpp @@ -0,0 +1,17 @@ +#include "CheckCompile.h" + +CheckCompile::CheckCompile() +{ + CtrlLayout(*this, "Window title"); +} + +GUI_APP_MAIN +{ + + { + // Checks ambiguity issue with Lambda assignment vs operator<<(String&&, T) + EditString es; + es << [=] { LOG("HERE"); }; + String() << AsString(Random()); + } +} diff --git a/upptst/MapRange/MapRange.cpp b/upptst/MapRange/MapRange.cpp new file mode 100644 index 000000000..3b68c953e --- /dev/null +++ b/upptst/MapRange/MapRange.cpp @@ -0,0 +1,43 @@ +#include + +using namespace Upp; + +CONSOLE_APP_MAIN +{ + VectorMap h; + for(int i = 0; i < 20; i++) + h("key" + AsString(i), "value" + AsString(i)); + + for(auto& kv : ~h) { + DDUMP(kv.key); + DDUMP(kv.value); + } + + DLOG("========="); + + h.Unlink(11); + + for(auto& kv : ~h) { + DDUMP(kv.key); + DDUMP(kv.value); + kv.value = "123"; + } + + DLOG("========="); + + const VectorMap& ch = h; + for(auto& kv : ~ch) { + DDUMP(kv.key); + DDUMP(kv.value); + } + + DLOG("========="); + for(int i = 0; i < h.GetCount(); i++) + if(!h.IsUnlinked(i)) + h.Unlink(i); + + for(auto& kv : ~h) { + DDUMP(kv.key); + DDUMP(kv.value); + } +} diff --git a/upptst/MapRange/MapRange.upp b/upptst/MapRange/MapRange.upp new file mode 100644 index 000000000..710271a45 --- /dev/null +++ b/upptst/MapRange/MapRange.upp @@ -0,0 +1,9 @@ +uses + Core; + +file + MapRange.cpp; + +mainconfig + "" = ""; + diff --git a/upptst/MapRange/init b/upptst/MapRange/init new file mode 100644 index 000000000..12d556ecc --- /dev/null +++ b/upptst/MapRange/init @@ -0,0 +1,4 @@ +#ifndef _MapRange_icpp_init_stub +#define _MapRange_icpp_init_stub +#include "Core/init" +#endif diff --git a/upptst/Range/Range.cpp b/upptst/Range/Range.cpp new file mode 100644 index 000000000..c9a59eb8f --- /dev/null +++ b/upptst/Range/Range.cpp @@ -0,0 +1,74 @@ +#include + +using namespace Upp; + +CONSOLE_APP_MAIN +{ + SeedRandom(0); + + Vector h = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 }; + Sort(SubRange(h, 2, 5).Write()); + DDUMP(h); + Sort(SubRange(h.begin() + 1, h.end()).Write()); + DDUMP(h); +// Sort(Range(h.begin(), 5), std::greater()); + DDUMP(h); + + DDUMPC(FilterRange(h, [=](int x) { return x & 1; })); + + for(int i = 0; i < 10; i++) + h.Add(Random(25)); + + DDUMP(FilterRange(h, [=](int x) { return x & 1; })); + DDUMP(FilterRange(h, [=](int x) { return !(x & 1); })); + + Sort(FilterRange(h, [=](int x) { return x & 1; }).Write()); + Sort(FilterRange(h, [=](int x) { return !(x & 1); }).Write(), std::greater()); + DDUMP(h); + + DDUMPC(ConstRange(12, 5)); + + h.Set(5, ConstRange(123, 3)); + DDUMP(h); + + h.Insert(5, ConstRange(10, 5)); + DDUMP(h); + + String vs = String::GetVoid(); + DDUMP(vs.IsVoid()); + vs.Clear(); + DDUMP(vs.IsVoid()); + + Array ah; + ah.Append(h); + DDUMP(ah); + ah.Insert(4, ConstRange(54321, 2)); + DDUMP(ah); + + Sort(h); + DDUMP(h); + Reverse(SubRange(h, 5, 5).Write()); + DDUMP(h); + + DDUMP(FindMin(h)); + DDUMP(FindMax(h)); + DDUMP(Min(h)); + DDUMP(Max(h)); + + Sort(h); + DDUMPC(h); + DDUMP(FindUpperBound(h, 8)); + DDUMP(FindLowerBound(h, 8)); + + DDUMP(FindUpperBound(h, 9)); + DDUMP(FindLowerBound(h, 9)); + + DDUMP(FindBinary(h, 10)); + DDUMP(FindBinary(h, 20)); + + DDUMP(Sum(h)); + + Vector empty; + DDUMP(Min(empty, 11)); + DDUMP(Max(empty, 12)); +} diff --git a/upptst/Range/Range.upp b/upptst/Range/Range.upp new file mode 100644 index 000000000..cf9002a19 --- /dev/null +++ b/upptst/Range/Range.upp @@ -0,0 +1,9 @@ +uses + Core; + +file + Range.cpp; + +mainconfig + "" = "MT"; + diff --git a/upptst/Range/init b/upptst/Range/init new file mode 100644 index 000000000..b2dba6aaa --- /dev/null +++ b/upptst/Range/init @@ -0,0 +1,4 @@ +#ifndef _Range_icpp_init_stub +#define _Range_icpp_init_stub +#include "Core/init" +#endif diff --git a/upptst/Tuple/Tuple.cpp b/upptst/Tuple/Tuple.cpp new file mode 100644 index 000000000..b273ad1a1 --- /dev/null +++ b/upptst/Tuple/Tuple.cpp @@ -0,0 +1,71 @@ +#include + +using namespace Upp; + +struct NonVal { + Tuple h; + + int x; + int y; +}; + +CONSOLE_APP_MAIN +{ + Tuple i4; + DDUMP(sizeof(i4)); + + Vector> testv; + testv.Add(MakeTuple(13, "Hello")); + DDUMP(testv); + + static Tuple h[] = { { 1, "Ahoj" } }; + + DDUMP(h[0]); + + Tuple x; + x.a = 171; + x.b = "HHH"; + + DDUMP(x.Get()); + DDUMP(x.Get()); + + x.Get<0>() = 666; + DDUMP(x.Get()); + + x.Get() = 777; + DDUMP(x.Get<0>()); + + Tuple z; + z.a = 0; + z.b = Point(1, 2); + z.c = "HHH"; + + DDUMP(z.c); + + DDUMP(z.Get(0)); + DDUMP(z.Get(1)); + DDUMP(z.Get(2)); + + DDUMP(z.Get<0>()); + DDUMP(z.Get<1>()); + DDUMP(z.Get<2>()); + + DDUMP(z.GetArray()); + + { + ValueArray h = z.GetArray(); + h.Set(1, Point(5, 6)); + z.SetArray(h); + DDUMP(z); + } + + Tuple y; + y.a.x = 5; + + Tuple it; + it.a = 10; + it.b = 11; + Tuple ft = it; + DDUMP(ft.a / 7); + DDUMP(ft.b); +} diff --git a/upptst/Tuple/Tuple.upp b/upptst/Tuple/Tuple.upp new file mode 100644 index 000000000..3408f7c69 --- /dev/null +++ b/upptst/Tuple/Tuple.upp @@ -0,0 +1,9 @@ +uses + Core; + +file + Tuple.cpp; + +mainconfig + "" = "MT"; + diff --git a/upptst/Tuple/init b/upptst/Tuple/init new file mode 100644 index 000000000..906e2783e --- /dev/null +++ b/upptst/Tuple/init @@ -0,0 +1,4 @@ +#ifndef _Tuple_icpp_init_stub +#define _Tuple_icpp_init_stub +#include "Core/init" +#endif