TeaSpeakLibrary/test/PropertyTest.cpp

70 lines
3.3 KiB
C++
Raw Normal View History

2019-06-26 16:11:22 -04:00
#include <iostream>
#include <src/Properties.h>
#include "src/misc/timer.h"
using namespace ts;
using namespace std;
int main() {
//assert(property::impl::validateUnique());
2019-06-26 16:11:22 -04:00
cout << property::describe(property::VIRTUALSERVER_HOST).name << endl;
cout << property::find(property::PROP_TYPE_SERVER, "virtualserver_host").name<< endl;
2019-06-26 16:11:22 -04:00
2020-01-23 20:49:59 -05:00
Properties props;
props.register_property_type<property::InstanceProperties>();
2019-06-26 16:11:22 -04:00
2020-01-23 20:49:59 -05:00
auto property = props[property::SERVERINSTANCE_QUERY_PORT];
2019-06-26 16:11:22 -04:00
2020-01-23 20:49:59 -05:00
cout << "Port: " << props[property::SERVERINSTANCE_QUERY_PORT].as<string>() << endl;
props[property::SERVERINSTANCE_QUERY_PORT] = "XX";
cout << "Port: " << props[property::SERVERINSTANCE_QUERY_PORT].as<string>() << endl;
props[property::SERVERINSTANCE_QUERY_PORT] = 2;
cout << "Port: " << props[property::SERVERINSTANCE_QUERY_PORT].as<string>() << endl;
cout << "Port: " << props[property::SERVERINSTANCE_QUERY_PORT].as<int32_t>() << endl;
2019-06-26 16:11:22 -04:00
/*
2020-01-23 20:49:59 -05:00
{
assert(property::impl::validateInput("022222", property::TYPE_UNSIGNED_NUMBER) == true);
assert(property::impl::validateInput("000000", property::TYPE_UNSIGNED_NUMBER) == true);
assert(property::impl::validateInput("011011", property::TYPE_UNSIGNED_NUMBER) == true);
2019-06-26 16:11:22 -04:00
2020-01-23 20:49:59 -05:00
assert(property::impl::validateInput("-022222", property::TYPE_UNSIGNED_NUMBER) == false);
assert(property::impl::validateInput(" 00000", property::TYPE_UNSIGNED_NUMBER) == false);
assert(property::impl::validateInput("01101.", property::TYPE_UNSIGNED_NUMBER) == false);
2019-06-26 16:11:22 -04:00
2020-01-23 20:49:59 -05:00
assert(property::impl::validateInput("022222", property::TYPE_SIGNED_NUMBER) == true);
assert(property::impl::validateInput("000000", property::TYPE_SIGNED_NUMBER) == true);
assert(property::impl::validateInput("011011", property::TYPE_SIGNED_NUMBER) == true);
assert(property::impl::validateInput("-022222", property::TYPE_SIGNED_NUMBER) == true);
assert(property::impl::validateInput("-00000", property::TYPE_SIGNED_NUMBER) == true);
2019-06-26 16:11:22 -04:00
2020-01-23 20:49:59 -05:00
assert(property::impl::validateInput("01101.", property::TYPE_SIGNED_NUMBER) == false);
assert(property::impl::validateInput("01-101", property::TYPE_SIGNED_NUMBER) == false);
2019-06-26 16:11:22 -04:00
2020-01-23 20:49:59 -05:00
assert(property::impl::validateInput("01101.", property::TYPE_FLOAT) == true);
assert(property::impl::validateInput("-01101.", property::TYPE_FLOAT) == true);
assert(property::impl::validateInput("-.1", property::TYPE_FLOAT) == true);
assert(property::impl::validateInput("-2.22222", property::TYPE_FLOAT) == true);
2019-06-26 16:11:22 -04:00
2020-01-23 20:49:59 -05:00
assert(property::impl::validateInput("01101.-2", property::TYPE_FLOAT) == false);
assert(property::impl::validateInput("-011.01.", property::TYPE_FLOAT) == false);
assert(property::impl::validateInput("-.1-", property::TYPE_FLOAT) == false);
assert(property::impl::validateInput("-2.22222.2", property::TYPE_FLOAT) == false);
}
*/
2019-06-26 16:11:22 -04:00
2020-01-23 20:49:59 -05:00
{
TIMING_START(timings);
this_thread::sleep_for(chrono::milliseconds(100));
TIMING_STEP(timings, "01");
this_thread::sleep_for(chrono::milliseconds(200));
TIMING_STEP(timings, "02");
this_thread::sleep_for(chrono::milliseconds(50));
TIMING_STEP(timings, "03");
this_thread::sleep_for(chrono::milliseconds(150));
cout << TIMING_FINISH(timings) << endl;
}
2019-06-26 16:11:22 -04:00
}