test/unit_tests/sequence-id-test.cc
changeset 0 2b3e5ec03512
equal deleted inserted replaced
-1:000000000000 0:2b3e5ec03512
       
     1 /*
       
     2  *    Copyright 2005-2008 Intel Corporation
       
     3  * 
       
     4  *    Licensed under the Apache License, Version 2.0 (the "License");
       
     5  *    you may not use this file except in compliance with the License.
       
     6  *    You may obtain a copy of the License at
       
     7  * 
       
     8  *        http://www.apache.org/licenses/LICENSE-2.0
       
     9  * 
       
    10  *    Unless required by applicable law or agreed to in writing, software
       
    11  *    distributed under the License is distributed on an "AS IS" BASIS,
       
    12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    13  *    See the License for the specific language governing permissions and
       
    14  *    limitations under the License.
       
    15  */
       
    16 
       
    17 #ifdef HAVE_CONFIG_H
       
    18 #include <dtn-config.h>
       
    19 #endif
       
    20 
       
    21 #include <oasys/util/UnitTest.h>
       
    22 #include "bundling/SequenceID.h"
       
    23 
       
    24 using namespace dtn;
       
    25 using namespace oasys;
       
    26 
       
    27 DECLARE_TEST(Basic) {
       
    28     SequenceID seq;
       
    29     seq.add(EndpointID("dtn://a"), 1);
       
    30     seq.add(EndpointID("dtn:none"), "void");
       
    31     seq.add(EndpointID("http://www.foo.com"), 10);
       
    32     
       
    33     CHECK_EQUAL_U64(seq.get_counter(EndpointID("dtn://a")), 1);
       
    34     CHECK_EQUALSTR(seq.get_identifier(EndpointID("dtn://a")), "");
       
    35     CHECK_EQUAL_U64(seq.get_counter(EndpointID("dtn:none")), 0);
       
    36     CHECK_EQUALSTR(seq.get_identifier(EndpointID("dtn:none")), "void");
       
    37     CHECK_EQUAL_U64(seq.get_counter(EndpointID("http://www.foo.com")), 10);
       
    38     CHECK_EQUALSTR(seq.get_identifier(EndpointID("http://www.foo.com")), "");
       
    39 
       
    40     CHECK_EQUALSTR(seq.to_str().c_str(),
       
    41                    "<(dtn://a 1) (dtn:none void) (http://www.foo.com 10)>");
       
    42 
       
    43     SequenceID seq2;
       
    44     CHECK(seq2.parse(seq.to_str()));
       
    45     CHECK_EQUALSTR(seq2.to_str().c_str(),
       
    46                    "<(dtn://a 1) (dtn:none void) (http://www.foo.com 10)>");
       
    47 
       
    48     CHECK(seq == seq2);
       
    49 
       
    50     return UNIT_TEST_PASSED;
       
    51 }
       
    52 
       
    53 DECLARE_TEST(Parse) {
       
    54     SequenceID seq;
       
    55     
       
    56     CHECK(seq.parse("<>"));
       
    57 
       
    58     CHECK(seq.parse("<(dtn://foo.com 23)>"));
       
    59     CHECK_EQUAL_U64(seq.get_counter(EndpointID("dtn://foo.com")), 23);
       
    60     
       
    61     CHECK(seq.parse("<(dtn:none 1)>"));
       
    62     CHECK(seq.parse("<       (dtn:none 1)>"));
       
    63     CHECK(seq.parse("<(dtn:none        1)>"));
       
    64     CHECK(seq.parse("<(dtn:none 1)        >"));
       
    65     CHECK(seq.parse("<(dtn:none 1)           (dtn://foo 2)       >"));
       
    66     CHECK(! seq.parse("<( dtn:none 1)>"));
       
    67     CHECK(! seq.parse("<(dtn:none 1 )>"));
       
    68     
       
    69     CHECK(seq.parse("<(dtn:none str)>"));
       
    70     CHECK(seq.parse("<(dtn:none 1str)>"));
       
    71     CHECK(seq.parse("<(dtn:none str1)>"));
       
    72     CHECK(seq.parse("<(dtn:none _str-2)>"));
       
    73     CHECK(seq.parse("<       (dtn:none str)>"));
       
    74     CHECK(seq.parse("<(dtn:none        str)>"));
       
    75     CHECK(seq.parse("<(dtn:none str)        >"));
       
    76     CHECK(seq.parse("<(dtn:none str)           (dtn://foo str2)       >"));
       
    77     CHECK(! seq.parse("<( dtn:none str)>"));
       
    78     CHECK(! seq.parse("<(dtn:none str )>"));
       
    79     
       
    80     CHECK(seq.parse("<(dtn://foo.com 999) (dtn:none str2) (http://www.google.com a1000)>"));
       
    81     CHECK_EQUAL_U64(seq.get_counter(EndpointID("dtn://foo.com")), 999);
       
    82     CHECK_EQUALSTR(seq.get_identifier(EndpointID("dtn:none")), "str2");
       
    83     CHECK_EQUALSTR(seq.get_identifier(EndpointID("http://www.google.com")), "a1000");
       
    84     CHECK_EQUAL_U64(seq.get_counter(EndpointID("http://www.dtnrg.org")), 0);
       
    85     CHECK_EQUALSTR(seq.get_identifier(EndpointID("http://www.dtnrg.org")), "");
       
    86 
       
    87     CHECK(! seq.parse(""));    
       
    88     CHECK(! seq.parse("<(dtn:none 1 >"));
       
    89     CHECK(! seq.parse("<(dtn:none 1>"));
       
    90     CHECK(! seq.parse("<(dtn:none 1)"));
       
    91 
       
    92     CHECK(! seq.parse("<( 1)>"));
       
    93     CHECK(! seq.parse("<(dtn:none )>"));
       
    94     CHECK(! seq.parse("<(dtn:none foo )>"));
       
    95     CHECK(! seq.parse("<(dtn:none foo )>"));
       
    96     CHECK(! seq.parse("<(foo 1)>"));
       
    97 
       
    98     return UNIT_TEST_PASSED;
       
    99 }
       
   100 
       
   101 // test brevity
       
   102 #define LT  SequenceID::LT
       
   103 #define GT  SequenceID::GT
       
   104 #define EQ  SequenceID::EQ
       
   105 #define NEQ SequenceID::NEQ
       
   106 
       
   107 SequenceID
       
   108 parse_sequence_id(std::string s)
       
   109 {
       
   110     SequenceID seq;
       
   111     bool ok = seq.parse(s);
       
   112     ASSERTF(ok, "sequence id string '%s' invalid", s.c_str());
       
   113     return seq;
       
   114 }
       
   115 
       
   116 // macro to invert order and try again
       
   117 #define CHECK_COMPARE(s1str, comp, s2str)                               \
       
   118 do {                                                                    \
       
   119     switch (comp) {                                                     \
       
   120     case LT:                                                            \
       
   121         CHECK(parse_sequence_id(s1str) < parse_sequence_id(s2str));     \
       
   122         CHECK(parse_sequence_id(s2str) > parse_sequence_id(s1str));     \
       
   123         break;                                                          \
       
   124     case SequenceID::GT:                                                \
       
   125         CHECK(parse_sequence_id(s1str) > parse_sequence_id(s2str));     \
       
   126         CHECK(parse_sequence_id(s2str) < parse_sequence_id(s1str));     \
       
   127         break;                                                          \
       
   128     case SequenceID::EQ:                                                \
       
   129         CHECK(parse_sequence_id(s1str) == parse_sequence_id(s2str));    \
       
   130         CHECK(parse_sequence_id(s2str) == parse_sequence_id(s1str));    \
       
   131         break;                                                          \
       
   132     case SequenceID::NEQ:                                               \
       
   133         CHECK(parse_sequence_id(s1str) != parse_sequence_id(s2str));    \
       
   134         CHECK(parse_sequence_id(s2str) != parse_sequence_id(s1str));    \
       
   135         break;                                                          \
       
   136     default:                                                            \
       
   137         NOTREACHED;                                                     \
       
   138     };                                                                  \
       
   139 } while (0)
       
   140 
       
   141 DECLARE_TEST(Compare) {
       
   142     CHECK_COMPARE("<>", EQ,
       
   143                   "<>");
       
   144     
       
   145     CHECK_COMPARE("<(dtn://host-0 0)>", EQ,
       
   146                   "<(dtn://host-0 0)>");
       
   147 
       
   148     CHECK_COMPARE("<(dtn://host-0 1)>", LT,
       
   149                   "<(dtn://host-0 2)>");
       
   150     
       
   151     CHECK_COMPARE("<(dtn://host-0 2)>", GT,
       
   152                   "<(dtn://host-0 1)>");
       
   153 
       
   154     CHECK_COMPARE("<(dtn://host-0 1)>", NEQ,
       
   155                   "<(dtn://host-1 1)>");
       
   156     
       
   157     CHECK_COMPARE("<(dtn://host-0 1) (dtn://host-1 0)>", NEQ,
       
   158                   "<(dtn://host-0 0) (dtn://host-1 1)>");
       
   159     
       
   160     CHECK_COMPARE("<(dtn://host-0 1) (dtn://host-1 0)>", LT,
       
   161                   "<(dtn://host-0 1) (dtn://host-1 1)>");
       
   162     
       
   163     CHECK_COMPARE("<(dtn://host-0 1) >", LT,
       
   164                   "<(dtn://host-0 1) (dtn://host-1 1)>");
       
   165     
       
   166     CHECK_COMPARE("<(dtn://host-0 1) (dtn://host-2 2)>", GT,
       
   167                   "<(dtn://host-0 1) >");
       
   168 
       
   169     CHECK_COMPARE("<(dtn://host-0 1) (dtn://host-2 2)>", GT,
       
   170                   "<>");
       
   171 
       
   172     CHECK_COMPARE("<(dtn://host-0 2)>", NEQ,
       
   173                   "<(dtn://host-0 1) (dtn://host-1 10)>");
       
   174     
       
   175     CHECK_COMPARE("<(dtn://host-0 0) (dtn://host-1 1)>", NEQ,
       
   176                   "<(dtn://host-0 0) (dtn://host-2 1)>");
       
   177 
       
   178     CHECK_COMPARE("<(dtn://host-0 foo)>", EQ,
       
   179                   "<(dtn://host-0 foo)>");
       
   180 
       
   181     CHECK_COMPARE("<(dtn://host-0 foo)>", NEQ,
       
   182                   "<(dtn://host-0 bar)>");
       
   183 
       
   184     CHECK_COMPARE("<(dtn://host-0 foo)>", NEQ,
       
   185                   "<(dtn://host-1 foo)>");
       
   186 
       
   187     CHECK_COMPARE("<(dtn://host-0 foo)>", NEQ,
       
   188                   "<(dtn://host-0 1)>");
       
   189 
       
   190     CHECK_COMPARE("<(dtn://host-0 1)>", NEQ,
       
   191                   "<(dtn://host-0 foo)>");
       
   192 
       
   193     return UNIT_TEST_PASSED;
       
   194 }
       
   195 
       
   196 // macro to test comparison operator overloads
       
   197 #define CHECK_COMPARE_OP(neg, s1str, op, s2str)                        \
       
   198     CHECK(neg (parse_sequence_id(s1str) op parse_sequence_id(s2str)));
       
   199 
       
   200 DECLARE_TEST(CompareOperators) {
       
   201     // equal counters
       
   202     CHECK_COMPARE_OP(  , "<(dtn://host-0 0)>", ==, "<(dtn://host-0 0)>");
       
   203     CHECK_COMPARE_OP( !, "<(dtn://host-0 0)>", <,  "<(dtn://host-0 0)>");
       
   204     CHECK_COMPARE_OP(  , "<(dtn://host-0 0)>", <=, "<(dtn://host-0 0)>");
       
   205     CHECK_COMPARE_OP( !, "<(dtn://host-0 0)>", !=, "<(dtn://host-0 0)>");
       
   206     CHECK_COMPARE_OP( !, "<(dtn://host-0 0)>", >,  "<(dtn://host-0 0)>");
       
   207     CHECK_COMPARE_OP(  , "<(dtn://host-0 0)>", >=, "<(dtn://host-0 0)>");
       
   208 
       
   209     // equal identifiers
       
   210     CHECK_COMPARE_OP(  , "<(dtn://host-0 foo)>", ==, "<(dtn://host-0 foo)>");
       
   211     CHECK_COMPARE_OP( !, "<(dtn://host-0 foo)>", <,  "<(dtn://host-0 foo)>");
       
   212     CHECK_COMPARE_OP(  , "<(dtn://host-0 foo)>", <=, "<(dtn://host-0 foo)>");
       
   213     CHECK_COMPARE_OP( !, "<(dtn://host-0 foo)>", !=, "<(dtn://host-0 foo)>");
       
   214     CHECK_COMPARE_OP( !, "<(dtn://host-0 foo)>", >,  "<(dtn://host-0 foo)>");
       
   215     CHECK_COMPARE_OP(  , "<(dtn://host-0 foo)>", >=, "<(dtn://host-0 foo)>");
       
   216 
       
   217     // not equal counters
       
   218     CHECK_COMPARE_OP( !, "<(dtn://host-0 1)>", ==, "<(dtn://host-0 2)>");
       
   219     CHECK_COMPARE_OP(  , "<(dtn://host-0 1)>", <,  "<(dtn://host-0 2)>");
       
   220     CHECK_COMPARE_OP(  , "<(dtn://host-0 1)>", <=, "<(dtn://host-0 2)>");
       
   221     CHECK_COMPARE_OP( !, "<(dtn://host-0 1)>", !=, "<(dtn://host-0 2)>");
       
   222     CHECK_COMPARE_OP( !, "<(dtn://host-0 1)>", >,  "<(dtn://host-0 2)>");
       
   223     CHECK_COMPARE_OP( !, "<(dtn://host-0 1)>", >=, "<(dtn://host-0 2)>");
       
   224 
       
   225     // not equal counters
       
   226     CHECK_COMPARE_OP( !, "<(dtn://host-0 2)>", ==, "<(dtn://host-0 1)>");
       
   227     CHECK_COMPARE_OP( !, "<(dtn://host-0 2)>", <,  "<(dtn://host-0 1)>");
       
   228     CHECK_COMPARE_OP( !, "<(dtn://host-0 2)>", <=, "<(dtn://host-0 1)>");
       
   229     CHECK_COMPARE_OP( !, "<(dtn://host-0 2)>", !=, "<(dtn://host-0 1)>");
       
   230     CHECK_COMPARE_OP(  , "<(dtn://host-0 2)>", >,  "<(dtn://host-0 1)>");
       
   231     CHECK_COMPARE_OP(  , "<(dtn://host-0 2)>", >=, "<(dtn://host-0 1)>");
       
   232 
       
   233     // not equal identifiers
       
   234     CHECK_COMPARE_OP( !, "<(dtn://host-0 foo)>", ==, "<(dtn://host-0 bar)>");
       
   235     CHECK_COMPARE_OP( !, "<(dtn://host-0 foo)>", <,  "<(dtn://host-0 bar)>");
       
   236     CHECK_COMPARE_OP( !, "<(dtn://host-0 foo)>", <=, "<(dtn://host-0 bar)>");
       
   237     CHECK_COMPARE_OP(  , "<(dtn://host-0 foo)>", !=, "<(dtn://host-0 bar)>");
       
   238     CHECK_COMPARE_OP( !, "<(dtn://host-0 foo)>", >,  "<(dtn://host-0 bar)>");
       
   239     CHECK_COMPARE_OP( !, "<(dtn://host-0 foo)>", >=, "<(dtn://host-0 bar)>");
       
   240 
       
   241     // mismatched type
       
   242     CHECK_COMPARE_OP( !, "<(dtn://host-0 foo)>", ==, "<(dtn://host-0 0)>");
       
   243     CHECK_COMPARE_OP( !, "<(dtn://host-0 foo)>", <,  "<(dtn://host-0 0)>");
       
   244     CHECK_COMPARE_OP( !, "<(dtn://host-0 foo)>", <=, "<(dtn://host-0 0)>");
       
   245     CHECK_COMPARE_OP(  , "<(dtn://host-0 foo)>", !=, "<(dtn://host-0 0)>");
       
   246     CHECK_COMPARE_OP( !, "<(dtn://host-0 foo)>", >,  "<(dtn://host-0 0)>");
       
   247     CHECK_COMPARE_OP( !, "<(dtn://host-0 foo)>", >=, "<(dtn://host-0 0)>");
       
   248 
       
   249     // mismatched eid
       
   250     CHECK_COMPARE_OP( !, "<(dtn://host-0 1)>", ==, "<(dtn://host-1 1)>");
       
   251     CHECK_COMPARE_OP( !, "<(dtn://host-0 1)>", <,  "<(dtn://host-1 1)>");
       
   252     CHECK_COMPARE_OP( !, "<(dtn://host-0 1)>", <=, "<(dtn://host-1 1)>");
       
   253     CHECK_COMPARE_OP(  , "<(dtn://host-0 1)>", !=, "<(dtn://host-1 1)>");
       
   254     CHECK_COMPARE_OP( !, "<(dtn://host-0 1)>", >,  "<(dtn://host-1 1)>");
       
   255     CHECK_COMPARE_OP( !, "<(dtn://host-0 1)>", >=, "<(dtn://host-1 1)>");
       
   256 
       
   257     // mismatched eid
       
   258     CHECK_COMPARE_OP( !, "<(dtn://host-0 foo)>", ==, "<(dtn://host-1 foo)>");
       
   259     CHECK_COMPARE_OP( !, "<(dtn://host-0 foo)>", <,  "<(dtn://host-1 foo)>");
       
   260     CHECK_COMPARE_OP( !, "<(dtn://host-0 foo)>", <=, "<(dtn://host-1 foo)>");
       
   261     CHECK_COMPARE_OP(  , "<(dtn://host-0 foo)>", !=, "<(dtn://host-1 foo)>");
       
   262     CHECK_COMPARE_OP( !, "<(dtn://host-0 foo)>", >,  "<(dtn://host-1 foo)>");
       
   263     CHECK_COMPARE_OP( !, "<(dtn://host-0 foo)>", >=, "<(dtn://host-1 foo)>");
       
   264 
       
   265     // empty other value
       
   266     CHECK_COMPARE_OP( !, "<(dtn://host-0 1)>", ==, "<>");
       
   267     CHECK_COMPARE_OP( !, "<(dtn://host-0 1)>", <,  "<>");
       
   268     CHECK_COMPARE_OP( !, "<(dtn://host-0 1)>", <=, "<>");
       
   269     CHECK_COMPARE_OP( !, "<(dtn://host-0 1)>", !=, "<>");
       
   270     CHECK_COMPARE_OP(  , "<(dtn://host-0 1)>", >,  "<>");
       
   271     CHECK_COMPARE_OP(  , "<(dtn://host-0 1)>", >=, "<>");
       
   272 
       
   273     // empty other value
       
   274     CHECK_COMPARE_OP( !, "<(dtn://host-0 foo)>", ==, "<>");
       
   275     CHECK_COMPARE_OP( !, "<(dtn://host-0 foo)>", <,  "<>");
       
   276     CHECK_COMPARE_OP( !, "<(dtn://host-0 foo)>", <=, "<>");
       
   277     CHECK_COMPARE_OP(  , "<(dtn://host-0 foo)>", !=, "<>");
       
   278     CHECK_COMPARE_OP( !, "<(dtn://host-0 foo)>", >,  "<>");
       
   279     CHECK_COMPARE_OP( !, "<(dtn://host-0 foo)>", >=, "<>");
       
   280     return UNIT_TEST_PASSED;
       
   281 }
       
   282 
       
   283 DECLARE_TEST(Update) {
       
   284     SequenceID seq;
       
   285 
       
   286     DO(seq.update(parse_sequence_id("<>")));
       
   287     CHECK_EQUALSTR(seq.to_str(), "<>");
       
   288     
       
   289     DO(seq.update(parse_sequence_id("<(dtn://host-0 1)>")));
       
   290     CHECK_EQUALSTR(seq.to_str(), "<(dtn://host-0 1)>");
       
   291     
       
   292     DO(seq.update(parse_sequence_id("<(dtn://host-1 1)>")));
       
   293     CHECK_EQUALSTR(seq.to_str(), "<(dtn://host-0 1) (dtn://host-1 1)>");
       
   294     
       
   295     DO(seq.update(parse_sequence_id("<(dtn://host-0 2) (dtn://host-1 2)>")));
       
   296     CHECK_EQUALSTR(seq.to_str(), "<(dtn://host-0 2) (dtn://host-1 2)>");
       
   297     
       
   298     DO(seq.update(parse_sequence_id("<(dtn://host-0 1) (dtn://host-1 1)>")));
       
   299     CHECK_EQUALSTR(seq.to_str(), "<(dtn://host-0 2) (dtn://host-1 2)>");
       
   300     
       
   301     DO(seq.update(parse_sequence_id("<(dtn://host-0 2) (dtn://host-1 2)>")));
       
   302     CHECK_EQUALSTR(seq.to_str(), "<(dtn://host-0 2) (dtn://host-1 2)>");
       
   303 
       
   304     DO(seq.update(parse_sequence_id("<(dtn://host-0 0) (dtn://host-1 0) (dtn://host-2 0)>")));
       
   305     CHECK_EQUALSTR(seq.to_str(), "<(dtn://host-0 2) (dtn://host-1 2) (dtn://host-2 0)>");
       
   306 
       
   307     SequenceID seq2;
       
   308 
       
   309     DO(seq2.update(parse_sequence_id("<>")));
       
   310     CHECK_EQUALSTR(seq2.to_str(), "<>");
       
   311     
       
   312     DO(seq2.update(parse_sequence_id("<(dtn://host-0 foo)>")));
       
   313     CHECK_EQUALSTR(seq2.to_str(), "<(dtn://host-0 foo)>");
       
   314     
       
   315     DO(seq2.update(parse_sequence_id("<(dtn://host-1 foo)>")));
       
   316     CHECK_EQUALSTR(seq2.to_str(), "<(dtn://host-0 foo) (dtn://host-1 foo)>");
       
   317     
       
   318     DO(seq2.update(parse_sequence_id("<(dtn://host-0 bar) (dtn://host-1 bar)>")));
       
   319     CHECK_EQUALSTR(seq2.to_str(), "<(dtn://host-0 bar) (dtn://host-1 bar)>");
       
   320     
       
   321     DO(seq2.update(parse_sequence_id("<(dtn://host-0 foo) (dtn://host-1 foo)>")));
       
   322     CHECK_EQUALSTR(seq2.to_str(), "<(dtn://host-0 foo) (dtn://host-1 foo)>");
       
   323     
       
   324     DO(seq2.update(parse_sequence_id("<(dtn://host-0 bar) (dtn://host-1 bar)>")));
       
   325     CHECK_EQUALSTR(seq2.to_str(), "<(dtn://host-0 bar) (dtn://host-1 bar)>");
       
   326 
       
   327     DO(seq2.update(parse_sequence_id("<(dtn://host-0 foo) (dtn://host-1 bar) (dtn://host-2 10)>")));
       
   328     CHECK_EQUALSTR(seq2.to_str(), "<(dtn://host-0 foo) (dtn://host-1 bar) (dtn://host-2 10)>");
       
   329 
       
   330     DO(seq2.update(parse_sequence_id("<(dtn://host-0 foo) (dtn://host-1 bar) (dtn://host-2 0)>")));
       
   331     CHECK_EQUALSTR(seq2.to_str(), "<(dtn://host-0 foo) (dtn://host-1 bar) (dtn://host-2 10)>");
       
   332 
       
   333     return UNIT_TEST_PASSED;
       
   334 }
       
   335 
       
   336 DECLARE_TEST(Assign) {
       
   337     SequenceID seq;
       
   338 
       
   339     DO(seq.assign(parse_sequence_id("<>")));
       
   340     CHECK_EQUALSTR(seq.to_str(), "<>");
       
   341     
       
   342     DO(seq.assign(parse_sequence_id("<(dtn://host-0 1)>")));
       
   343     CHECK_EQUALSTR(seq.to_str(), "<(dtn://host-0 1)>");
       
   344     
       
   345     DO(seq.assign(parse_sequence_id("<(dtn://host-1 1)>")));
       
   346     CHECK_EQUALSTR(seq.to_str(), "<(dtn://host-1 1)>");
       
   347     
       
   348     DO(seq.assign(parse_sequence_id("<(dtn://host-0 2) (dtn://host-1 2)>")));
       
   349     CHECK_EQUALSTR(seq.to_str(), "<(dtn://host-0 2) (dtn://host-1 2)>");
       
   350     
       
   351     DO(seq.assign(parse_sequence_id("<(dtn://host-0 1) (dtn://host-1 1)>")));
       
   352     CHECK_EQUALSTR(seq.to_str(), "<(dtn://host-0 1) (dtn://host-1 1)>");
       
   353     
       
   354     DO(seq.assign(parse_sequence_id("<(dtn://host-0 2) (dtn://host-1 2)>")));
       
   355     CHECK_EQUALSTR(seq.to_str(), "<(dtn://host-0 2) (dtn://host-1 2)>");
       
   356 
       
   357     DO(seq.assign(parse_sequence_id("<(dtn://host-0 0) (dtn://host-1 0) (dtn://host-2 0)>")));
       
   358     CHECK_EQUALSTR(seq.to_str(), "<(dtn://host-0 0) (dtn://host-1 0) (dtn://host-2 0)>");
       
   359     
       
   360     return UNIT_TEST_PASSED;
       
   361 }
       
   362 
       
   363 DECLARE_TESTER(SequenceIDTester) {
       
   364     ADD_TEST(Basic);
       
   365     ADD_TEST(Parse);
       
   366     ADD_TEST(Compare);
       
   367     ADD_TEST(CompareOperators);
       
   368     ADD_TEST(Update);
       
   369     ADD_TEST(Assign);
       
   370 }
       
   371 
       
   372 DECLARE_TEST_FILE(SequenceIDTester, "sequence id test");