mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-13 06:12:49 -06:00
.upptst
git-svn-id: svn://ultimatepp.org/upp/trunk@6660 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
01613e65fb
commit
76cccf417e
9 changed files with 177 additions and 9 deletions
54
upptst/FixedMap/FixedMap.cpp
Normal file
54
upptst/FixedMap/FixedMap.cpp
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
#include <Core/Core.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
StdLogSetup(LOG_FILE|LOG_COUT);
|
||||
|
||||
FixedVectorMap<String, String> fmap;
|
||||
|
||||
ASSERT(fmap.IsEmpty());
|
||||
|
||||
for(int i = 0; i < 10; i++)
|
||||
fmap.Add(AsString(100 + (i & 1 ? -1 : 1) * i), AsString(i));
|
||||
|
||||
DUMPM(fmap);
|
||||
fmap.Finish();
|
||||
DUMPM(fmap);
|
||||
|
||||
ASSERT(!fmap.IsEmpty());
|
||||
ASSERT(fmap.GetCount() == 10);
|
||||
ASSERT(fmap.Find("foo") < 0);
|
||||
ASSERT(fmap.FindPtr("foo") == NULL);
|
||||
|
||||
for(int i = 0; i < 10; i++) {
|
||||
ASSERT(fmap.Get(AsString(100 + (i & 1 ? -1 : 1) * i)) == AsString(i));
|
||||
ASSERT(*fmap.FindPtr(AsString(100 + (i & 1 ? -1 : 1) * i)) == AsString(i));
|
||||
}
|
||||
|
||||
fmap.Clear();
|
||||
|
||||
ASSERT(fmap.IsEmpty());
|
||||
|
||||
for(int i = 1; i < 10; i++)
|
||||
for(int j = 0; j < i; j++)
|
||||
fmap.Add(AsString(j)) = AsString(j);
|
||||
|
||||
fmap.Finish();
|
||||
|
||||
DUMPM(fmap);
|
||||
|
||||
for(int i = 0; i < 10; i++) {
|
||||
int q = fmap.Find(AsString(i));
|
||||
int n = 0;
|
||||
while(q >= 0) {
|
||||
n++;
|
||||
ASSERT(fmap[q] == AsString(i));
|
||||
q = fmap.FindNext(q);
|
||||
}
|
||||
ASSERT(n == 9 - i);
|
||||
}
|
||||
|
||||
LOG("========= EVERYTHING OK ==========");
|
||||
}
|
||||
9
upptst/FixedMap/FixedMap.upp
Normal file
9
upptst/FixedMap/FixedMap.upp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
uses
|
||||
Core;
|
||||
|
||||
file
|
||||
FixedMap.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "SSE2";
|
||||
|
||||
4
upptst/FixedMap/init
Normal file
4
upptst/FixedMap/init
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#ifndef _FixedMap_icpp_init_stub
|
||||
#define _FixedMap_icpp_init_stub
|
||||
#include "Core/init"
|
||||
#endif
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
uses
|
||||
Core;
|
||||
|
||||
file
|
||||
Heap.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "";
|
||||
|
||||
uses
|
||||
Core;
|
||||
|
||||
file
|
||||
Heap.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "";
|
||||
|
||||
|
|
|
|||
4
upptst/Heap/init
Normal file
4
upptst/Heap/init
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#ifndef _Heap_icpp_init_stub
|
||||
#define _Heap_icpp_init_stub
|
||||
#include "Core/init"
|
||||
#endif
|
||||
64
upptst/NanoStrings/NanoStrings.cpp
Normal file
64
upptst/NanoStrings/NanoStrings.cpp
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
#include <Core/Core.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
// WARNING: 64-bit OS and 8GB RAM required to run this test
|
||||
|
||||
String RandomString(int maxlen = 70)
|
||||
{
|
||||
int len = Random(maxlen);
|
||||
String h;
|
||||
for(int i = 0; i < len; i++)
|
||||
h.Cat(Random(26) + 'a');
|
||||
return h;
|
||||
}
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
StdLogSetup(LOG_COUT|LOG_FILE);
|
||||
|
||||
MemoryLimitKb(8000000);
|
||||
for(int sz = 0; sz < 2; sz++) {
|
||||
for(int pass = 0; pass < 2; pass++) {
|
||||
LOG("--------------------");
|
||||
DUMP(sz);
|
||||
DUMP(pass);
|
||||
{
|
||||
NanoStrings ns;
|
||||
Vector<dword> ws;
|
||||
|
||||
ns.ZeroTerminated(sz);
|
||||
|
||||
SeedRandom();
|
||||
for(int i = 0; i < 140000000; i++) {
|
||||
if(i % 10000000 == 0)
|
||||
RLOG("Created " << i);
|
||||
String s = pass ? "x" : RandomString(Random(4) ? 5 : 50);
|
||||
ws.Add(ns.Add(s));
|
||||
}
|
||||
|
||||
ns.DumpProfile();
|
||||
LOG("---- Strings " << MemoryUsedKb() << " KB used -------");
|
||||
LOG(MemoryProfile());
|
||||
|
||||
SeedRandom();
|
||||
for(int i = 0; i < ws.GetCount(); i++) {
|
||||
if(i % 10000000 == 0)
|
||||
RLOG("Tested " << i);
|
||||
String s = pass ? "x" : RandomString(Random(4) ? 5 : 50);
|
||||
if((sz ? String(ns.GetPtr(ws[i])) : ns.Get(ws[i])) != s) {
|
||||
DUMP(i);
|
||||
DUMP(ns.Get(ws[i]));
|
||||
DUMP(s);
|
||||
NEVER();
|
||||
}
|
||||
}
|
||||
LOG("Test OK");
|
||||
}
|
||||
LOG("===== EMPTY " << MemoryUsedKb() << " KB used -------");
|
||||
LOG(MemoryProfile());
|
||||
}
|
||||
}
|
||||
|
||||
LOG("============ Everything OK ===================");
|
||||
}
|
||||
9
upptst/NanoStrings/NanoStrings.upp
Normal file
9
upptst/NanoStrings/NanoStrings.upp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
uses
|
||||
Core;
|
||||
|
||||
file
|
||||
NanoStrings.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "SSE2";
|
||||
|
||||
4
upptst/NanoStrings/init
Normal file
4
upptst/NanoStrings/init
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#ifndef _NanoStrings_icpp_init_stub
|
||||
#define _NanoStrings_icpp_init_stub
|
||||
#include "Core/init"
|
||||
#endif
|
||||
|
|
@ -53,6 +53,20 @@ void TestMap()
|
|||
Test(data);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void TestFixedMap()
|
||||
{
|
||||
T data;
|
||||
|
||||
data.Add(1, typeid(T).name());
|
||||
data.Add(2, "123");
|
||||
data.Add(3, "433");
|
||||
|
||||
data.Finish();
|
||||
|
||||
Test(data);
|
||||
}
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
StdLogSetup(LOG_FILE|LOG_COUT);
|
||||
|
|
@ -90,5 +104,11 @@ CONSOLE_APP_MAIN
|
|||
TestMap< SortedArrayMap<int, String> >();
|
||||
TestMap< WithDeepCopy< SortedArrayMap<int, String> > >();
|
||||
|
||||
TestFixedMap< FixedVectorMap<int, String> >();
|
||||
TestFixedMap< WithDeepCopy< FixedVectorMap<int, String> > >();
|
||||
|
||||
TestFixedMap< FixedArrayMap<int, String> >();
|
||||
TestFixedMap< WithDeepCopy< FixedArrayMap<int, String> > >();
|
||||
|
||||
LOG("========= EVERYTHING OK ==========");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue