summaryrefslogtreecommitdiff
path: root/proto_test/main.cpp
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss@sss.chaoslab.ru>2013-02-13 20:32:10 +0200
committerGluzskiy Alexandr <sss@sss.chaoslab.ru>2013-02-13 20:32:10 +0200
commit728653fbb36727acfb5a4cd480b7fa5d45adfa89 (patch)
tree0f5f6c90749571af4375f9ff59f39cecaff6cfac /proto_test/main.cpp
parent49729a7593320662545b7c795f028d0f87827b0f (diff)
proto lib fixes
more tests
Diffstat (limited to 'proto_test/main.cpp')
-rw-r--r--proto_test/main.cpp61
1 files changed, 60 insertions, 1 deletions
diff --git a/proto_test/main.cpp b/proto_test/main.cpp
index ba0b8e8..1083e44 100644
--- a/proto_test/main.cpp
+++ b/proto_test/main.cpp
@@ -60,7 +60,7 @@ bool test_client_to_server_command()
bool test_services_extraction()
{
packet *p = packet::cli_make_request_services_packet();
- if(p->get_type() != TYPE_SERVICES_REQUEST)
+ if(p->get_type() != TYPE_SERVICES)
return false;
std::list<service_s> list1;
service_s s1;
@@ -124,6 +124,57 @@ bool test_services_extraction()
return true;
}
+bool test_command_exchange()
+{
+ packet *p = packet::cli_make_command_packet("test service", "test command");
+ svc_cmd c = packet::serv_extract_command(*p);
+ if(c.command != "test command")
+ return false;
+ if(c.service != "test service")
+ return false;
+ delete p;
+ p = packet::serv_make_command_reply_packet("success", STATUS_SUCCESS);
+ std::string s = packet::cli_parse_command_reply(*p);
+ if(s != "success")
+ return false;
+ if(p->get_status() != STATUS_SUCCESS)
+ return false;
+ delete p;
+ p = packet::serv_make_command_reply_packet("failure", STATUS_FAILURE);
+ s = packet::cli_parse_command_reply(*p);
+ if(s != "failure")
+ return false;
+ if(p->get_status() != STATUS_FAILURE)
+ return false;
+ delete p;
+ return true;
+}
+
+bool test_status_packet()
+{
+ packet *p = packet::serv_make_status_packet(TYPE_AUTH, STATUS_SUCCESS);
+ if(!p->is_good())
+ return false;
+ if(p->get_status() != STATUS_SUCCESS)
+ return false;
+ if(p->get_type() != TYPE_AUTH)
+ return false;
+ if(!p->is_server_packet())
+ return false;
+ delete p;
+ p = packet::cli_make_status_packet(TYPE_SERVICES, STATUS_FAILURE);
+ if(p->get_status() != STATUS_FAILURE)
+ return false;
+ if(p->get_type() != TYPE_SERVICES)
+ return false;
+ if(!p->is_good())
+ return false;
+ if(!p->is_client_packet())
+ return false;
+ delete p;
+ return true;
+}
+
int main()
{
std::list<std::string> bad_packets = test_creation();
@@ -147,5 +198,13 @@ int main()
std::cout<<"service extraction test: OK"<<std::endl;
else
std::cout<<"service extraction test: ERROR"<<std::endl;
+ if(test_command_exchange())
+ std::cout<<"command exchange test: OK"<<std::endl;
+ else
+ std::cout<<"command exchange test: ERROR"<<std::endl;
+ if(test_status_packet())
+ std::cout<<"status packet test: OK"<<std::endl;
+ else
+ std::cout<<"status packet test: ERROR"<<std::endl;
return 0;
}