Add simple key=value dictionary, sorta like java.util.Properties.
This commit is contained in:
parent
a816f56426
commit
fb975ead23
2 changed files with 160 additions and 0 deletions
24
selftest.cpp
24
selftest.cpp
|
@ -45,6 +45,7 @@
|
|||
#include "node/Peer.hpp"
|
||||
#include "node/Condition.hpp"
|
||||
#include "node/NodeConfig.hpp"
|
||||
#include "node/Dictionary.hpp"
|
||||
|
||||
using namespace ZeroTier;
|
||||
|
||||
|
@ -298,6 +299,29 @@ static int testOther()
|
|||
}
|
||||
std::cout << "PASS" << std::endl;
|
||||
|
||||
std::cout << "[other] Testing Dictionary... "; std::cout.flush();
|
||||
for(int k=0;k<10000;++k) {
|
||||
Dictionary a,b;
|
||||
int nk = rand() % 32;
|
||||
for(int q=0;q<nk;++q) {
|
||||
std::string k,v;
|
||||
int kl = (rand() % 512);
|
||||
int vl = (rand() % 512);
|
||||
for(int i=0;i<kl;++i)
|
||||
k.push_back((char)rand());
|
||||
for(int i=0;i<vl;++i)
|
||||
v.push_back((char)rand());
|
||||
a[k] = v;
|
||||
}
|
||||
std::string aser = a.toString();
|
||||
b.fromString(aser);
|
||||
if (a != b) {
|
||||
std::cout << "FAIL!" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
std::cout << "PASS" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue