/[resiprocate]/main/resip/stack/test/testTuple.cxx
ViewVC logotype

Diff of /main/resip/stack/test/testTuple.cxx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 11152 by dpocock, Thu Feb 21 07:46:52 2013 UTC revision 11153 by dpetrie, Wed Apr 23 17:25:02 2014 UTC
# Line 7  Line 7 
7  #include "rutil/Inserter.hxx"  #include "rutil/Inserter.hxx"
8  #include "resip/stack/Connection.hxx"  #include "resip/stack/Connection.hxx"
9  #include "resip/stack/Tuple.hxx"  #include "resip/stack/Tuple.hxx"
10    #ifdef USE_NETNS
11    #   include "rutil/NetNs.hxx"
12    #endif
13    
14  using namespace resip;  using namespace resip;
15  using namespace std;  using namespace std;
# Line 237  Line 240 
240     }     }
241  #endif  #endif
242    
243    #ifdef USE_NETNS
244       {
245          Tuple testNetNsTuple("192.168.1.106", 5069, V4, TCP, Data::Empty, "namespace1");
246          assert(testNetNsTuple.getNetNs() == "namespace1");
247          // Check assignment copies netns
248          Tuple netNsTupleCopy = testNetNsTuple;
249          assert(netNsTupleCopy.getNetNs() == "namespace1");
250          assert(testNetNsTuple == netNsTupleCopy);
251          assert(!(testNetNsTuple < netNsTupleCopy));
252          assert(!(netNsTupleCopy < testNetNsTuple));
253          assert(!(Tuple::AnyPortCompare().operator()(testNetNsTuple, netNsTupleCopy)));
254          assert(!(Tuple::AnyPortCompare().operator()(netNsTupleCopy, testNetNsTuple)));
255    
256          netNsTupleCopy.setNetNs("namespace2");
257          assert(netNsTupleCopy.getNetNs() == "namespace2");
258          assert(!(testNetNsTuple == netNsTupleCopy));
259          assert(testNetNsTuple < netNsTupleCopy);
260          assert(!(netNsTupleCopy < testNetNsTuple));
261          assert((Tuple::AnyPortCompare().operator()(testNetNsTuple, netNsTupleCopy)));
262          assert(!(Tuple::AnyPortCompare().operator()(netNsTupleCopy, testNetNsTuple)));
263    
264          Tuple copyTuple2(netNsTupleCopy);
265          assert(copyTuple2.getNetNs() == "namespace2");
266    
267          Data binaryToken;
268          // NetNs keeps a dictionary of netns.  If we have not yet used a
269          // netns, its not in the dictionary.  So we need to prime the dictionary
270          // here.
271          NetNs::setNs("namespace1");
272          NetNs::setNs("");
273          //cout << "testNetNsTuple: " << testNetNsTuple << endl;
274          Tuple::writeBinaryToken(testNetNsTuple, binaryToken);
275          Tuple reconstructed = Tuple::makeTupleFromBinaryToken(binaryToken);
276          //cout << "reconstructed: " << reconstructed<< endl;
277          assert(reconstructed.getNetNs() == "namespace1");
278          assert(reconstructed == testNetNsTuple);
279          Data binaryTokenWithSalt;
280          Tuple::writeBinaryToken(testNetNsTuple, binaryTokenWithSalt, "iLikePeperToo");
281          Tuple reconstructedWithSalt = Tuple::makeTupleFromBinaryToken(binaryTokenWithSalt, "iLikePeperToo");
282          //cout << "reconstructedWithSalt: " << reconstructedWithSalt << endl;
283          assert(reconstructedWithSalt.getNetNs() == "namespace1");
284          assert(reconstructedWithSalt == testNetNsTuple);
285    
286          resipCerr << "NETNS OK and tested" << std::endl;
287       }
288    #endif
289    
290     resipCerr << "ALL OK" << std::endl;     resipCerr << "ALL OK" << std::endl;
291  }  }
292    

Legend:
Removed from v.11152  
changed lines
  Added in v.11153

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27