src/common/packet-metadata-test.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Sat, 21 Jun 2008 21:20:38 -0700
changeset 3306 3d8da3343514
parent 3303 e367e86d7886
child 4210 da9be6abb1b2
permissions -rw-r--r--
testcase and fix, symmetric to changeset c861a47407a8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
/*
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
 * Copyright (c) 2006,2007 INRIA
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
 *
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
 *
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
 * GNU General Public License for more details.
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
 *
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
 *
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
 */
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
#ifdef RUN_SELF_TESTS
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
#include <stdarg.h>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
#include <iostream>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
#include <sstream>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    25
#include "ns3/test.h"
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
#include "header.h"
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
#include "trailer.h"
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    28
#include "packet.h"
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
#include "packet-metadata.h"
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
3034
b96c58f42432 move test code to anon namespace
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2876
diff changeset
    31
using namespace ns3;
b96c58f42432 move test code to anon namespace
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2876
diff changeset
    32
b96c58f42432 move test code to anon namespace
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2876
diff changeset
    33
namespace {
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
3180
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    35
class HistoryHeaderBase : public Header
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    36
{
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    37
public:
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    38
  static TypeId GetTypeId (void);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    39
  HistoryHeaderBase ();
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    40
  bool IsOk (void) const;
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    41
protected:
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    42
  void ReportError (void);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    43
private:
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    44
  bool m_ok;
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    45
};
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    46
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    47
TypeId 
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    48
HistoryHeaderBase::GetTypeId (void)
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    49
{
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    50
  static TypeId tid = TypeId ("ns3::HistoryHeaderBase")
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    51
    .SetParent<Header> ()
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    52
    ;
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    53
  return tid;
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    54
}
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    55
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    56
HistoryHeaderBase::HistoryHeaderBase ()
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    57
  : m_ok (true)
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    58
{}
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    59
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    60
bool 
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    61
HistoryHeaderBase::IsOk (void) const
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    62
{
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    63
  return m_ok;
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    64
}
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    65
void 
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    66
HistoryHeaderBase::ReportError (void)
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    67
{
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    68
  m_ok = false;
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    69
}
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    70
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    71
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    72
template <int N>
3180
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    73
class HistoryHeader : public HistoryHeaderBase
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    74
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    75
public:
2646
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
    76
  HistoryHeader ();
2643
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
    77
  static TypeId GetTypeId (void);
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
    78
  virtual TypeId GetInstanceTypeId (void) const;
2646
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
    79
  virtual void Print (std::ostream &os) const;
2642
a35a68bdcd88 make the base Header and Trailer classes virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2640
diff changeset
    80
  virtual uint32_t GetSerializedSize (void) const;
a35a68bdcd88 make the base Header and Trailer classes virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2640
diff changeset
    81
  virtual void Serialize (Buffer::Iterator start) const;
a35a68bdcd88 make the base Header and Trailer classes virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2640
diff changeset
    82
  virtual uint32_t Deserialize (Buffer::Iterator start);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    83
};
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    84
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    85
template <int N>
2646
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
    86
HistoryHeader<N>::HistoryHeader ()
3180
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    87
  : HistoryHeaderBase ()
2646
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
    88
{}
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
    89
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
    90
template <int N>
2643
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
    91
TypeId
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
    92
HistoryHeader<N>::GetTypeId (void)
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
    93
{
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
    94
  std::ostringstream oss;
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
    95
  oss << "ns3::HistoryHeader<"<<N<<">";
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
    96
  static TypeId tid = TypeId (oss.str ().c_str ())
3180
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    97
    .SetParent<HistoryHeaderBase> ()
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
    98
    .AddConstructor<HistoryHeader<N> > ()
2643
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
    99
    ;
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   100
  return tid;
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   101
}
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   102
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   103
template <int N>
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   104
TypeId 
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   105
HistoryHeader<N>::GetInstanceTypeId (void) const
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   106
{
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   107
  return GetTypeId ();
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   108
}
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   109
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   110
void 
1232
2e8c3f8bb77f remove Chunk base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1151
diff changeset
   111
HistoryHeader<N>::Print (std::ostream &os) const
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   112
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   113
  NS_ASSERT (false);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   114
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   115
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   116
uint32_t 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   117
HistoryHeader<N>::GetSerializedSize (void) const
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   118
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   119
  return N;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   120
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   121
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   122
void 
1232
2e8c3f8bb77f remove Chunk base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1151
diff changeset
   123
HistoryHeader<N>::Serialize (Buffer::Iterator start) const
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   124
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   125
  start.WriteU8 (N, N);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   126
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   127
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   128
uint32_t
1232
2e8c3f8bb77f remove Chunk base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1151
diff changeset
   129
HistoryHeader<N>::Deserialize (Buffer::Iterator start)
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   130
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   131
  for (int i = 0; i < N; i++)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   132
    {
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   133
      if (start.ReadU8 () != N)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   134
        {
3180
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   135
          ReportError ();
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   136
        }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   137
    }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   138
  return N;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   139
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   140
3180
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   141
class HistoryTrailerBase : public Trailer
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   142
{
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   143
public:
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   144
  static TypeId GetTypeId (void);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   145
  HistoryTrailerBase ();
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   146
  bool IsOk (void) const;
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   147
protected:
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   148
  void ReportError (void);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   149
private:
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   150
  bool m_ok;
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   151
};
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   152
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   153
TypeId 
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   154
HistoryTrailerBase::GetTypeId (void)
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   155
{
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   156
  static TypeId tid = TypeId ("ns3::HistoryTrailerBase")
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   157
    .SetParent<Trailer> ()
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   158
    ;
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   159
  return tid;
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   160
}
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   161
HistoryTrailerBase::HistoryTrailerBase ()
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   162
  : m_ok (true)
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   163
{}
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   164
bool 
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   165
HistoryTrailerBase::IsOk (void) const
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   166
{
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   167
  return m_ok;
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   168
}
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   169
void 
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   170
HistoryTrailerBase::ReportError (void)
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   171
{
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   172
  m_ok = false;
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   173
}
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   174
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   175
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   176
template <int N>
3180
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   177
class HistoryTrailer : public HistoryTrailerBase
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   178
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   179
public:
2646
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
   180
  HistoryTrailer ();
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
   181
  bool IsOk (void) const;
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
   182
2643
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   183
  static TypeId GetTypeId (void);
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   184
  virtual TypeId GetInstanceTypeId (void) const;
2646
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
   185
  virtual void Print (std::ostream &os) const;
2642
a35a68bdcd88 make the base Header and Trailer classes virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2640
diff changeset
   186
  virtual uint32_t GetSerializedSize (void) const;
a35a68bdcd88 make the base Header and Trailer classes virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2640
diff changeset
   187
  virtual void Serialize (Buffer::Iterator start) const;
a35a68bdcd88 make the base Header and Trailer classes virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2640
diff changeset
   188
  virtual uint32_t Deserialize (Buffer::Iterator start);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   189
private:
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   190
  bool m_ok;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   191
};
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   192
2646
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
   193
template <int N>
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
   194
HistoryTrailer<N>::HistoryTrailer ()
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
   195
{}
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
   196
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
   197
template <int N>
2643
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   198
TypeId
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   199
HistoryTrailer<N>::GetTypeId (void)
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   200
{
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   201
  std::ostringstream oss;
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   202
  oss << "ns3::HistoryTrailer<"<<N<<">";
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   203
  static TypeId tid = TypeId (oss.str ().c_str ())
3180
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   204
    .SetParent<HistoryTrailerBase> ()
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   205
    .AddConstructor<HistoryTrailer<N> > ()
2643
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   206
    ;
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   207
  return tid;
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   208
}
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   209
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   210
template <int N>
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   211
TypeId 
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   212
HistoryTrailer<N>::GetInstanceTypeId (void) const
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   213
{
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   214
  return GetTypeId ();
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2642
diff changeset
   215
}
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   216
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   217
void 
1232
2e8c3f8bb77f remove Chunk base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1151
diff changeset
   218
HistoryTrailer<N>::Print (std::ostream &os) const
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   219
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   220
  NS_ASSERT (false);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   221
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   222
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   223
uint32_t 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   224
HistoryTrailer<N>::GetSerializedSize (void) const
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   225
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   226
  return N;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   227
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   228
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   229
void 
1232
2e8c3f8bb77f remove Chunk base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1151
diff changeset
   230
HistoryTrailer<N>::Serialize (Buffer::Iterator start) const
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   231
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   232
  start.Prev (N);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   233
  start.WriteU8 (N, N);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   234
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   235
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   236
uint32_t
1232
2e8c3f8bb77f remove Chunk base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1151
diff changeset
   237
HistoryTrailer<N>::Deserialize (Buffer::Iterator start)
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   238
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   239
  start.Prev (N);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   240
  for (int i = 0; i < N; i++)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   241
    {
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   242
      if (start.ReadU8 () != N)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   243
        {
3180
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   244
          ReportError ();
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   245
        }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   246
    }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   247
  return N;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   248
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   249
3034
b96c58f42432 move test code to anon namespace
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2876
diff changeset
   250
}
b96c58f42432 move test code to anon namespace
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2876
diff changeset
   251
b96c58f42432 move test code to anon namespace
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2876
diff changeset
   252
namespace ns3 {
b96c58f42432 move test code to anon namespace
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2876
diff changeset
   253
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   254
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   255
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   256
class PacketMetadataTest : public Test {
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   257
public:
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   258
  PacketMetadataTest ();
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   259
  virtual ~PacketMetadataTest ();
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   260
  bool CheckHistory (Ptr<Packet> p, const char *file, int line, uint32_t n, ...);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   261
  virtual bool RunTests (void);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   262
private:
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   263
  Ptr<Packet> DoAddHeader (Ptr<Packet> p);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   264
};
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   265
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   266
PacketMetadataTest::PacketMetadataTest ()
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   267
  : Test ("PacketMetadata")
2639
588221b7f892 replace PacketPrinter with an iterator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1866
diff changeset
   268
{}
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   269
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   270
PacketMetadataTest::~PacketMetadataTest ()
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   271
{}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   272
2639
588221b7f892 replace PacketPrinter with an iterator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1866
diff changeset
   273
bool 
588221b7f892 replace PacketPrinter with an iterator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1866
diff changeset
   274
PacketMetadataTest::CheckHistory (Ptr<Packet> p, const char *file, int line, uint32_t n, ...)
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   275
{
2639
588221b7f892 replace PacketPrinter with an iterator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1866
diff changeset
   276
  std::list<int> expected;
588221b7f892 replace PacketPrinter with an iterator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1866
diff changeset
   277
  va_list ap;
588221b7f892 replace PacketPrinter with an iterator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1866
diff changeset
   278
  va_start (ap, n);
588221b7f892 replace PacketPrinter with an iterator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1866
diff changeset
   279
  for (uint32_t j = 0; j < n; j++)
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   280
    {
2639
588221b7f892 replace PacketPrinter with an iterator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1866
diff changeset
   281
      int v = va_arg (ap, int);
588221b7f892 replace PacketPrinter with an iterator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1866
diff changeset
   282
      expected.push_back (v);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   283
    }
2639
588221b7f892 replace PacketPrinter with an iterator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1866
diff changeset
   284
  va_end (ap);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   285
2639
588221b7f892 replace PacketPrinter with an iterator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1866
diff changeset
   286
  PacketMetadata::ItemIterator k = p->BeginItem ();
588221b7f892 replace PacketPrinter with an iterator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1866
diff changeset
   287
  std::list<int> got;
588221b7f892 replace PacketPrinter with an iterator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1866
diff changeset
   288
  while (k.HasNext ())
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   289
    {
2639
588221b7f892 replace PacketPrinter with an iterator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1866
diff changeset
   290
      struct PacketMetadata::Item item = k.Next ();
3180
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   291
      if (item.isFragment || item.type == PacketMetadata::Item::PAYLOAD)
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   292
        {
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   293
          got.push_back (item.currentSize);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   294
          continue;
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   295
        }
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   296
      if (item.type == PacketMetadata::Item::HEADER)
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   297
        {
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   298
          Callback<ObjectBase *> constructor = item.tid.GetConstructor ();
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   299
          HistoryHeaderBase *header = dynamic_cast<HistoryHeaderBase *> (constructor ());
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   300
          if (header == 0)
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   301
            {
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   302
              goto error;
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   303
            }
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   304
          header->Deserialize (item.current);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   305
          if (!header->IsOk ())
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   306
            {
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   307
              delete header;
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   308
              goto error;
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   309
            }
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   310
          delete header;
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   311
        }
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   312
      else if (item.type == PacketMetadata::Item::TRAILER)
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   313
        {
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   314
          Callback<ObjectBase *> constructor = item.tid.GetConstructor ();
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   315
          HistoryTrailerBase *trailer = dynamic_cast<HistoryTrailerBase *> (constructor ());
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   316
          if (trailer == 0)
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   317
            {
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   318
              goto error;
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   319
            }
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   320
          trailer->Deserialize (item.current);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   321
          if (!trailer->IsOk ())
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   322
            {
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   323
              delete trailer;
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   324
              goto error;
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   325
            }
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   326
          delete trailer;
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   327
        }
2639
588221b7f892 replace PacketPrinter with an iterator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1866
diff changeset
   328
      got.push_back (item.currentSize);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   329
    }
2639
588221b7f892 replace PacketPrinter with an iterator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1866
diff changeset
   330
588221b7f892 replace PacketPrinter with an iterator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1866
diff changeset
   331
  for (std::list<int>::iterator i = got.begin (),
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   332
         j = expected.begin (); 
2639
588221b7f892 replace PacketPrinter with an iterator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1866
diff changeset
   333
       i != got.end (); i++, j++)
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   334
    {
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   335
      NS_ASSERT (j != expected.end ());
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   336
      if (*j != *i)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   337
        {
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   338
          goto error;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   339
        }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   340
    }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   341
  return true;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   342
 error:
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   343
  Failure () << "PacketMetadata error. file="<< file 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   344
            << ", line=" << line << ", got:\"";
2639
588221b7f892 replace PacketPrinter with an iterator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1866
diff changeset
   345
  for (std::list<int>::iterator i = got.begin (); 
588221b7f892 replace PacketPrinter with an iterator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1866
diff changeset
   346
       i != got.end (); i++)
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   347
    {
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   348
      Failure () << *i << ", ";
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   349
    }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   350
  Failure () << "\", expected: \"";
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   351
  for (std::list<int>::iterator j = expected.begin ();
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   352
       j != expected.end (); j++)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   353
    {
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   354
      Failure () << *j << ", ";
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   355
    }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   356
  Failure () << "\"" << std::endl;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   357
  return false;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   358
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   359
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   360
#define ADD_HEADER(p, n)                        \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   361
  {                                             \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   362
    HistoryHeader<n> header;                    \
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   363
    p->AddHeader (header);                      \
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   364
  }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   365
#define ADD_TRAILER(p, n)                       \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   366
  {                                             \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   367
    HistoryTrailer<n> trailer;                  \
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   368
    p->AddTrailer (trailer);                    \
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   369
  }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   370
#define REM_HEADER(p, n)                        \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   371
  {                                             \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   372
    HistoryHeader<n> header;                    \
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   373
    p->RemoveHeader (header);                   \
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   374
  }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   375
#define REM_TRAILER(p, n)                       \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   376
  {                                             \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   377
    HistoryTrailer<n> trailer;                  \
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   378
    p->RemoveTrailer (trailer);                 \
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   379
  }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   380
#define CHECK_HISTORY(p, ...)                   \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   381
  {                                             \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   382
    if (!CheckHistory (p, __FILE__,             \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   383
                      __LINE__, __VA_ARGS__))   \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   384
      {                                         \
3180
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   385
        result = false;                         \
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   386
      }                                         \
1148
a5a767daca79 test packet serialization/deserialization
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1141
diff changeset
   387
    Buffer buffer;                              \
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   388
    buffer = p->Serialize ();                   \
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   389
    Ptr<Packet> otherPacket = Create<Packet> ();\
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   390
    otherPacket->Deserialize  (buffer);         \
1148
a5a767daca79 test packet serialization/deserialization
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1141
diff changeset
   391
    if (!CheckHistory (otherPacket, __FILE__,   \
a5a767daca79 test packet serialization/deserialization
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1141
diff changeset
   392
                      __LINE__, __VA_ARGS__))   \
a5a767daca79 test packet serialization/deserialization
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1141
diff changeset
   393
      {                                         \
3180
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   394
        result = false;                         \
1148
a5a767daca79 test packet serialization/deserialization
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1141
diff changeset
   395
      }                                         \
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   396
  }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   397
1312
8bc3f26344b9 add failing test and fix for assignment to self
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1260
diff changeset
   398
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   399
Ptr<Packet>
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   400
PacketMetadataTest::DoAddHeader (Ptr<Packet> p)
1312
8bc3f26344b9 add failing test and fix for assignment to self
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1260
diff changeset
   401
{
8bc3f26344b9 add failing test and fix for assignment to self
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1260
diff changeset
   402
  ADD_HEADER (p, 10);
8bc3f26344b9 add failing test and fix for assignment to self
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1260
diff changeset
   403
  return p;
8bc3f26344b9 add failing test and fix for assignment to self
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1260
diff changeset
   404
}
8bc3f26344b9 add failing test and fix for assignment to self
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1260
diff changeset
   405
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   406
bool
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   407
PacketMetadataTest::RunTests (void)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   408
{
3180
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   409
  bool result = true;
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   410
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   411
  PacketMetadata::Enable ();
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   412
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   413
  Ptr<Packet> p = Create<Packet> (0);
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   414
  Ptr<Packet> p1 = Create<Packet> (0);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   415
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   416
  p = Create<Packet> (10);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   417
  ADD_TRAILER (p, 100);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   418
  CHECK_HISTORY (p, 2, 10, 100);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   419
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   420
  p = Create<Packet> (10);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   421
  ADD_HEADER (p, 1);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   422
  ADD_HEADER (p, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   423
  ADD_HEADER (p, 3);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   424
  CHECK_HISTORY (p, 4, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   425
                 3, 2, 1, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   426
  ADD_HEADER (p, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   427
  CHECK_HISTORY (p, 5, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   428
                 5, 3, 2, 1, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   429
  ADD_HEADER (p, 6);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   430
  CHECK_HISTORY (p, 6, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   431
                 6, 5, 3, 2, 1, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   432
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   433
  p = Create<Packet> (10);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   434
  ADD_HEADER (p, 1);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   435
  ADD_HEADER (p, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   436
  ADD_HEADER (p, 3);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   437
  REM_HEADER (p, 3);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   438
  CHECK_HISTORY (p, 3, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   439
                 2, 1, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   440
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   441
  p = Create<Packet> (10);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   442
  ADD_HEADER (p, 1);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   443
  ADD_HEADER (p, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   444
  ADD_HEADER (p, 3);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   445
  REM_HEADER (p, 3);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   446
  REM_HEADER (p, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   447
  CHECK_HISTORY (p, 2, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   448
                 1, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   449
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   450
  p = Create<Packet> (10);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   451
  ADD_HEADER (p, 1);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   452
  ADD_HEADER (p, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   453
  ADD_HEADER (p, 3);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   454
  REM_HEADER (p, 3);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   455
  REM_HEADER (p, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   456
  REM_HEADER (p, 1);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   457
  CHECK_HISTORY (p, 1, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   458
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   459
  p = Create<Packet> (10);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   460
  ADD_HEADER (p, 1);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   461
  ADD_HEADER (p, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   462
  ADD_HEADER (p, 3);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   463
  p1 = p->Copy ();
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   464
  REM_HEADER (p1, 3);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   465
  REM_HEADER (p1, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   466
  REM_HEADER (p1, 1);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   467
  CHECK_HISTORY (p1, 1, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   468
  CHECK_HISTORY (p, 4, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   469
                 3, 2, 1, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   470
  ADD_HEADER (p1, 1);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   471
  ADD_HEADER (p1, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   472
  CHECK_HISTORY (p1, 3, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   473
                 2, 1, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   474
  CHECK_HISTORY (p, 4, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   475
                 3, 2, 1, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   476
  ADD_HEADER (p, 3);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   477
  CHECK_HISTORY (p, 5, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   478
                 3, 3, 2, 1, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   479
  ADD_TRAILER (p, 4);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   480
  CHECK_HISTORY (p, 6, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   481
                 3, 3, 2, 1, 10, 4);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   482
  ADD_TRAILER (p, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   483
  CHECK_HISTORY (p, 7, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   484
                 3, 3, 2, 1, 10, 4, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   485
  REM_HEADER (p, 3);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   486
  CHECK_HISTORY (p, 6, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   487
                 3, 2, 1, 10, 4, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   488
  REM_TRAILER (p, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   489
  CHECK_HISTORY (p, 5, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   490
                 3, 2, 1, 10, 4);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   491
  p1 = p->Copy ();
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   492
  REM_TRAILER (p, 4);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   493
  CHECK_HISTORY (p, 4, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   494
                 3, 2, 1, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   495
  CHECK_HISTORY (p1, 5, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   496
                 3, 2, 1, 10, 4);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   497
  p1->RemoveAtStart (3);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   498
  CHECK_HISTORY (p1, 4, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   499
                 2, 1, 10, 4);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   500
  p1->RemoveAtStart (1);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   501
  CHECK_HISTORY (p1, 4, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   502
                 1, 1, 10, 4);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   503
  p1->RemoveAtStart (1);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   504
  CHECK_HISTORY (p1, 3, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   505
                 1, 10, 4);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   506
  p1->RemoveAtEnd (4);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   507
  CHECK_HISTORY (p1, 2, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   508
                 1, 10);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   509
  p1->RemoveAtStart (1);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   510
  CHECK_HISTORY (p1, 1, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   511
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   512
  p = Create<Packet> (10);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   513
  ADD_HEADER (p, 8);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   514
  ADD_TRAILER (p, 8);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   515
  ADD_TRAILER (p, 8);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   516
  p->RemoveAtStart (8+10+8);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   517
  CHECK_HISTORY (p, 1, 8);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   518
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   519
  p = Create<Packet> (10);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   520
  ADD_HEADER (p, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   521
  ADD_HEADER (p, 8);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   522
  ADD_TRAILER (p, 6);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   523
  ADD_TRAILER (p, 7);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   524
  ADD_TRAILER (p, 9);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   525
  p->RemoveAtStart (5);
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   526
  p->RemoveAtEnd (12);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   527
  CHECK_HISTORY (p, 5, 3, 10, 10, 6, 4);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   528
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   529
  p = Create<Packet> (10);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   530
  ADD_HEADER (p, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   531
  ADD_TRAILER (p, 6);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   532
  p->RemoveAtEnd (18);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   533
  ADD_TRAILER (p, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   534
  ADD_HEADER (p, 3);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   535
  CHECK_HISTORY (p, 3, 3, 8, 5);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   536
  p->RemoveAtStart (12);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   537
  CHECK_HISTORY (p, 1, 4);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   538
  p->RemoveAtEnd (2);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   539
  CHECK_HISTORY (p, 1, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   540
  ADD_HEADER (p, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   541
  CHECK_HISTORY (p, 2, 10, 2);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   542
  p->RemoveAtEnd (5);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   543
  CHECK_HISTORY (p, 1, 7);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   544
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   545
  Ptr<Packet> p2 = Create<Packet> (0);
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   546
  Ptr<Packet> p3 = Create<Packet> (0);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   547
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   548
  p = Create<Packet> (40);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   549
  ADD_HEADER (p, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   550
  ADD_HEADER (p, 8);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   551
  CHECK_HISTORY (p, 3, 8, 5, 40);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   552
  p1 = p->CreateFragment (0, 5);
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   553
  p2 = p->CreateFragment (5, 5);
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   554
  p3 = p->CreateFragment (10, 43);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   555
  CHECK_HISTORY (p1, 1, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   556
  CHECK_HISTORY (p2, 2, 3, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   557
  CHECK_HISTORY (p3, 2, 3, 40);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   558
  p1->AddAtEnd (p2);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   559
  CHECK_HISTORY (p1, 2, 8, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   560
  CHECK_HISTORY (p2, 2, 3, 2);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   561
  p1->AddAtEnd (p3);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   562
  CHECK_HISTORY (p1, 3, 8, 5, 40);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   563
  CHECK_HISTORY (p2, 2, 3, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   564
  CHECK_HISTORY (p3, 2, 3, 40);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   565
  p1 = p->CreateFragment (0, 5);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   566
  CHECK_HISTORY (p1, 1, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   567
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   568
  p3 = Create<Packet> (50);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   569
  ADD_HEADER (p3, 8);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   570
  CHECK_HISTORY (p3, 2, 8, 50);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   571
  CHECK_HISTORY (p1, 1, 5);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   572
  p1->AddAtEnd (p3);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   573
  CHECK_HISTORY (p1, 3, 5, 8, 50);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   574
  ADD_HEADER (p1, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   575
  CHECK_HISTORY (p1, 4, 5, 5, 8, 50);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   576
  ADD_TRAILER (p1, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   577
  CHECK_HISTORY (p1, 5, 5, 5, 8, 50, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   578
  REM_HEADER (p1, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   579
  CHECK_HISTORY (p1, 4, 5, 8, 50, 2);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   580
  p1->RemoveAtEnd (60);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   581
  CHECK_HISTORY (p1, 1, 5);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   582
  p1->AddAtEnd (p2);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   583
  CHECK_HISTORY (p1, 2, 8, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   584
  CHECK_HISTORY (p2, 2, 3, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   585
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   586
  p3 = Create<Packet> (40);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   587
  ADD_HEADER (p3, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   588
  ADD_HEADER (p3, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   589
  CHECK_HISTORY (p3, 3, 5, 5, 40);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   590
  p1 = p3->CreateFragment (0, 5);
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   591
  p2 = p3->CreateFragment (5, 5);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   592
  CHECK_HISTORY (p1, 1, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   593
  CHECK_HISTORY (p2, 1, 5);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   594
  p1->AddAtEnd (p2);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   595
  CHECK_HISTORY (p1, 2, 5, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   596
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   597
  p = Create<Packet> (0);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   598
  CHECK_HISTORY (p, 0);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   599
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   600
  p3 = Create<Packet> (0);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   601
  ADD_HEADER (p3, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   602
  ADD_HEADER (p3, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   603
  CHECK_HISTORY (p3, 2, 5, 5);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   604
  p1 = p3->CreateFragment (0, 4);
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   605
  p2 = p3->CreateFragment (9, 1);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   606
  CHECK_HISTORY (p1, 1, 4);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   607
  CHECK_HISTORY (p2, 1, 1);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   608
  p1->AddAtEnd (p2);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   609
  CHECK_HISTORY (p1, 2, 4, 1);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   610
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   611
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   612
  p = Create<Packet> (2000);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   613
  CHECK_HISTORY (p, 1, 2000);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   614
  
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   615
  p = Create<Packet> ();
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   616
  ADD_TRAILER (p, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   617
  ADD_HEADER (p, 5);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   618
  p1 = p->CreateFragment (0, 8);
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   619
  p2 = p->CreateFragment (8, 7);
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   620
  p1->AddAtEnd (p2);
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   621
  CHECK_HISTORY (p, 2, 5, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   622
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   623
  p = Create<Packet> ();
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   624
  ADD_TRAILER (p, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   625
  REM_TRAILER (p, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   626
  ADD_TRAILER (p, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   627
  CHECK_HISTORY (p, 1, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   628
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   629
  p = Create<Packet> ();
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   630
  ADD_HEADER (p, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   631
  REM_HEADER (p, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   632
  ADD_HEADER (p, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   633
  CHECK_HISTORY (p, 1, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   634
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   635
  p = Create<Packet> ();
1312
8bc3f26344b9 add failing test and fix for assignment to self
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1260
diff changeset
   636
  ADD_HEADER (p, 10);
8bc3f26344b9 add failing test and fix for assignment to self
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1260
diff changeset
   637
  p = DoAddHeader (p);
8bc3f26344b9 add failing test and fix for assignment to self
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1260
diff changeset
   638
  CHECK_HISTORY (p, 2, 10, 10);
8bc3f26344b9 add failing test and fix for assignment to self
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1260
diff changeset
   639
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   640
  p = Create<Packet> (10);
1482
367eb4599901 we handle gustavo's testcase now. Fix for bug 72
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1312
diff changeset
   641
  ADD_HEADER (p, 8);
367eb4599901 we handle gustavo's testcase now. Fix for bug 72
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1312
diff changeset
   642
  ADD_TRAILER (p, 8);
367eb4599901 we handle gustavo's testcase now. Fix for bug 72
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1312
diff changeset
   643
  ADD_TRAILER (p, 8);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1482
diff changeset
   644
  p->RemoveAtStart (8+10+8);
1482
367eb4599901 we handle gustavo's testcase now. Fix for bug 72
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1312
diff changeset
   645
  CHECK_HISTORY (p, 1, 8);
367eb4599901 we handle gustavo's testcase now. Fix for bug 72
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1312
diff changeset
   646
2657
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   647
  p = Create<Packet> (0);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   648
  ADD_HEADER (p, 8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   649
  REM_HEADER (p, 8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   650
  CHECK_HISTORY (p, 0);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   651
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   652
  p = Create<Packet> (0);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   653
  ADD_TRAILER (p, 8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   654
  REM_TRAILER (p, 8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   655
  CHECK_HISTORY (p, 0);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   656
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   657
  p = Create<Packet> (0);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   658
  ADD_HEADER (p, 8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   659
  p->RemoveAtStart (8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   660
  CHECK_HISTORY (p, 0);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   661
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   662
  p = Create<Packet> (0);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   663
  ADD_HEADER (p, 8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   664
  ADD_TRAILER (p, 8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   665
  REM_TRAILER (p, 8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   666
  REM_HEADER (p, 8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   667
  CHECK_HISTORY (p, 0);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   668
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   669
  p = Create<Packet> (0);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   670
  ADD_HEADER (p, 8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   671
  ADD_TRAILER (p, 8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   672
  REM_HEADER (p, 8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   673
  REM_TRAILER (p, 8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   674
  CHECK_HISTORY (p, 0);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   675
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   676
  p = Create<Packet> (0);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   677
  ADD_HEADER (p, 8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   678
  ADD_TRAILER (p, 8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   679
  REM_TRAILER (p, 8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   680
  p->RemoveAtStart (8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   681
  CHECK_HISTORY (p, 0);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   682
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   683
  p = Create<Packet> (0);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   684
  ADD_HEADER (p, 8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   685
  ADD_TRAILER (p, 8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   686
  REM_HEADER (p, 8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   687
  p->RemoveAtEnd (8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   688
  CHECK_HISTORY (p, 0);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   689
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   690
  p = Create<Packet> (0);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   691
  ADD_HEADER (p, 8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   692
  ADD_TRAILER (p, 8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   693
  REM_TRAILER (p, 8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   694
  p->RemoveAtEnd (8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   695
  CHECK_HISTORY (p, 0);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   696
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   697
  p = Create<Packet> (0);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   698
  ADD_HEADER (p, 8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   699
  ADD_TRAILER (p, 8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   700
  REM_HEADER (p, 8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   701
  p->RemoveAtStart (8);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   702
  CHECK_HISTORY (p, 0);
489c7086867a add failing tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   703
2876
ab1e9244ab41 testcase from bug 159
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2657
diff changeset
   704
  p = Create<Packet> (16383);
ab1e9244ab41 testcase from bug 159
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2657
diff changeset
   705
  p = Create<Packet> (16384);
ab1e9244ab41 testcase from bug 159
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2657
diff changeset
   706
3060
5a49ba9ad976 bug 179: Packet fragmentation bug
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3034
diff changeset
   707
5a49ba9ad976 bug 179: Packet fragmentation bug
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3034
diff changeset
   708
  // bug 179.
5a49ba9ad976 bug 179: Packet fragmentation bug
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3034
diff changeset
   709
  p = Create<Packet> (40);
5a49ba9ad976 bug 179: Packet fragmentation bug
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3034
diff changeset
   710
  p2 = p->CreateFragment (5, 5);
5a49ba9ad976 bug 179: Packet fragmentation bug
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3034
diff changeset
   711
  p3 = p->CreateFragment (10, 30);
5a49ba9ad976 bug 179: Packet fragmentation bug
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3034
diff changeset
   712
  ADD_HEADER (p2, 8);
5a49ba9ad976 bug 179: Packet fragmentation bug
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3034
diff changeset
   713
  ADD_HEADER (p3, 8);
5a49ba9ad976 bug 179: Packet fragmentation bug
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3034
diff changeset
   714
  REM_HEADER (p2, 8);
5a49ba9ad976 bug 179: Packet fragmentation bug
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3034
diff changeset
   715
  REM_HEADER (p3, 8);
5a49ba9ad976 bug 179: Packet fragmentation bug
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3034
diff changeset
   716
  p2->AddAtEnd (p3);
5a49ba9ad976 bug 179: Packet fragmentation bug
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3034
diff changeset
   717
3180
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   718
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   719
  p = Create<Packet> (1000);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   720
  ADD_HEADER (p, 10);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   721
  ADD_TRAILER (p, 5);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   722
  p1 = p->Copy ();
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   723
  ADD_HEADER (p1, 20);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   724
  REM_HEADER (p1, 20);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   725
  REM_TRAILER (p1, 5);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   726
  NS_TEST_ASSERT_EQUAL (p->GetSize (), 1015);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   727
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   728
  
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   729
  p = Create<Packet> (1510);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   730
  ADD_HEADER (p, 8);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   731
  ADD_HEADER (p, 25);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   732
  REM_HEADER (p, 25);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   733
  ADD_HEADER (p, 1);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   734
  p1 = p->CreateFragment (0, 1500);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   735
  p2 = p1->Copy ();
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   736
  ADD_HEADER (p2, 24);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   737
  NS_TEST_ASSERT_EQUAL (p->GetSize (), 1519);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   738
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   739
  p = Create<Packet> (1000);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   740
  ADD_HEADER (p, 2);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   741
  ADD_TRAILER (p, 3);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   742
  p1 = p->Copy ();
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   743
  CHECK_HISTORY (p1, 3, 2, 1000, 3);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   744
  REM_HEADER (p, 2);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   745
  ADD_HEADER (p, 1);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   746
  CHECK_HISTORY (p, 3, 1, 1000, 3);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   747
  CHECK_HISTORY (p1, 3, 2, 1000, 3);
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   748
3202
bb35abea1d2a a testcase for bug 197
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3180
diff changeset
   749
  p = Create<Packet> (200);
bb35abea1d2a a testcase for bug 197
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3180
diff changeset
   750
  ADD_HEADER (p, 24);
bb35abea1d2a a testcase for bug 197
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3180
diff changeset
   751
  p1 = p->CreateFragment(0, 100);
bb35abea1d2a a testcase for bug 197
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3180
diff changeset
   752
  p2 = p->CreateFragment(100, 100);	
bb35abea1d2a a testcase for bug 197
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3180
diff changeset
   753
  p1->AddAtEnd (p2);
3180
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   754
3296
0695f4b2a2bd testcase for changeset 133490cf0210
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3202
diff changeset
   755
  p = Create<Packet> ();
0695f4b2a2bd testcase for changeset 133490cf0210
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3202
diff changeset
   756
  ADD_HEADER (p, 10);
0695f4b2a2bd testcase for changeset 133490cf0210
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3202
diff changeset
   757
  p1 = Create<Packet> ();
0695f4b2a2bd testcase for changeset 133490cf0210
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3202
diff changeset
   758
  ADD_HEADER (p1, 11);
0695f4b2a2bd testcase for changeset 133490cf0210
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3202
diff changeset
   759
  REM_HEADER (p1, 11);
0695f4b2a2bd testcase for changeset 133490cf0210
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3202
diff changeset
   760
  p->AddAtEnd (p1);
0695f4b2a2bd testcase for changeset 133490cf0210
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3202
diff changeset
   761
3303
e367e86d7886 bug 217: another testcase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3296
diff changeset
   762
  p = Create<Packet> (500);
e367e86d7886 bug 217: another testcase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3296
diff changeset
   763
  CHECK_HISTORY (p, 1, 500);
e367e86d7886 bug 217: another testcase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3296
diff changeset
   764
  ADD_HEADER (p, 10);
e367e86d7886 bug 217: another testcase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3296
diff changeset
   765
  CHECK_HISTORY (p, 2, 10, 500);
e367e86d7886 bug 217: another testcase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3296
diff changeset
   766
  REM_HEADER (p, 10);
e367e86d7886 bug 217: another testcase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3296
diff changeset
   767
  CHECK_HISTORY (p, 1, 500);
e367e86d7886 bug 217: another testcase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3296
diff changeset
   768
  p->RemoveAtEnd (10);
e367e86d7886 bug 217: another testcase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3296
diff changeset
   769
  CHECK_HISTORY (p, 1, 490);
3306
3d8da3343514 testcase and fix, symmetric to changeset c861a47407a8
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3303
diff changeset
   770
3d8da3343514 testcase and fix, symmetric to changeset c861a47407a8
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3303
diff changeset
   771
  p = Create<Packet> (500);
3d8da3343514 testcase and fix, symmetric to changeset c861a47407a8
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3303
diff changeset
   772
  CHECK_HISTORY (p, 1, 500);
3d8da3343514 testcase and fix, symmetric to changeset c861a47407a8
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3303
diff changeset
   773
  ADD_TRAILER (p, 10);
3d8da3343514 testcase and fix, symmetric to changeset c861a47407a8
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3303
diff changeset
   774
  CHECK_HISTORY (p, 2, 500, 10);
3d8da3343514 testcase and fix, symmetric to changeset c861a47407a8
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3303
diff changeset
   775
  REM_TRAILER (p, 10);
3d8da3343514 testcase and fix, symmetric to changeset c861a47407a8
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3303
diff changeset
   776
  CHECK_HISTORY (p, 1, 500);
3d8da3343514 testcase and fix, symmetric to changeset c861a47407a8
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3303
diff changeset
   777
  p->RemoveAtStart (10);
3d8da3343514 testcase and fix, symmetric to changeset c861a47407a8
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3303
diff changeset
   778
  CHECK_HISTORY (p, 1, 490);
3303
e367e86d7886 bug 217: another testcase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3296
diff changeset
   779
  
e367e86d7886 bug 217: another testcase.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3296
diff changeset
   780
3180
b69d00a3d410 new Packet testcases, bug fix.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3171
diff changeset
   781
  return result;
1134
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   782
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   783
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   784
static PacketMetadataTest g_packetHistoryTest;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   785
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   786
}//namespace ns3
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   787
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   788
#endif /* RUN_SELF_TESTS */