]> git.stg.codes - ssmd.git/blob - tests/test_data_parser.cpp
Fix build on osx.
[ssmd.git] / tests / test_data_parser.cpp
1 #include <iostream>
2
3 #include "datatypes.h"
4 #include "logger.h"
5
6 SSMD::Logger logger;
7
8 int main()
9 {
10     SSMD::Lines lines;
11     std::string data(
12 "172.16.47.10,gts_community_r,gts_community_w,10,1,001CC0B16177,64,128,64,128\n"
13 "172.16.47.11,gts_community_r,gts_community_w,10,1,001CC0B16178,65,129,66,138\n"
14 "172.16.47.10,gts_community_r,gts_community_w,16,1,001CC0B16179,66,130,68,148\n"
15 "172.16.47.10,gts_community_r,gts_community_w,16,8,001CC0B16180,67,131,70,158\n"
16     );
17
18     std::cout << data << std::endl;
19
20     if (!parseData(data, lines)) {
21         logger << "Failed to parse data" << std::endl;
22     } else {
23         SSMD::Lines::const_iterator it;
24         for (it = lines.begin(); it != lines.end(); ++it) {
25             logger << "line: "
26                    << it->switchIP << ","
27                    << it->readCommunity << ","
28                    << it->writeCommunity << ","
29                    << it->uplinkPort << ","
30                    << it->userPort << ","
31                    << it->mac << ","
32                    << it->upShape << ","
33                    << it->downShape << ","
34                    << it->upBurst << ","
35                    << it->downBurst << std::endl;
36         }
37     }
38
39     return 0;
40 }