src/common/packet-metadata-test.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Fri, 03 Aug 2007 17:52:21 +0200
changeset 1134 5f5d33e01eb9
child 1141 a75fc1741700
permissions -rw-r--r--
split test code out of the main PacketMetadata code
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
#include "packet-printer.h"
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    31
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
namespace ns3 {
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    35
class HistoryHeader : public Header
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    36
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    37
public:
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    38
  static std::string GetUid (void);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    39
  HistoryHeader ();
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    40
  bool IsOk (void) const;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    41
private:
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    42
  virtual std::string DoGetName (void) const;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    43
  virtual void PrintTo (std::ostream &os) const;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    44
  virtual uint32_t GetSerializedSize (void) const;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    45
  virtual void SerializeTo (Buffer::Iterator start) const;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    46
  virtual uint32_t DeserializeFrom (Buffer::Iterator start);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    47
  bool m_ok;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    48
};
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    49
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    50
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    51
std::string
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    52
HistoryHeader<N>::GetUid (void)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    53
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    54
  std::ostringstream oss;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    55
  oss << N << "HistoryHeader.ns3";
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    56
  return oss.str ();
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    57
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    58
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    59
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    60
HistoryHeader<N>::HistoryHeader ()
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    61
  : m_ok (false)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    62
{}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    63
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    64
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    65
bool 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    66
HistoryHeader<N>::IsOk (void) const
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    67
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    68
  return m_ok;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    69
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    70
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    71
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    72
std::string 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    73
HistoryHeader<N>::DoGetName (void) const
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
  std::ostringstream oss;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    76
  oss << N;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    77
  return oss.str ();
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    78
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    79
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    80
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    81
void 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    82
HistoryHeader<N>::PrintTo (std::ostream &os) const
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
  NS_ASSERT (false);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    85
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    86
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    87
uint32_t 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    88
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
    89
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    90
  return N;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    91
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    92
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    93
void 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    94
HistoryHeader<N>::SerializeTo (Buffer::Iterator start) const
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    95
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    96
  start.WriteU8 (N, N);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    97
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    98
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    99
uint32_t
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   100
HistoryHeader<N>::DeserializeFrom (Buffer::Iterator start)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   101
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   102
  m_ok = true;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   103
  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
   104
    {
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   105
      if (start.ReadU8 () != N)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   106
        {
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   107
          m_ok = false;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   108
        }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   109
    }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   110
  return N;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   111
}
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
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   114
class HistoryTrailer : public Trailer
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   115
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   116
public:
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   117
  static std::string GetUid (void);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   118
  HistoryTrailer ();
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   119
  bool IsOk (void) const;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   120
private:
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   121
  virtual std::string DoGetName (void) const;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   122
  virtual void PrintTo (std::ostream &os) const;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   123
  virtual uint32_t GetSerializedSize (void) const;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   124
  virtual void SerializeTo (Buffer::Iterator start) const;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   125
  virtual uint32_t DeserializeFrom (Buffer::Iterator start);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   126
  bool m_ok;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   127
};
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   128
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   129
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   130
std::string
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   131
HistoryTrailer<N>::GetUid (void)
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
  std::ostringstream oss;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   134
  oss << N << "HistoryTrailer.ns3";
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   135
  return oss.str ();
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
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   139
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   140
HistoryTrailer<N>::HistoryTrailer ()
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   141
  : m_ok (false)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   142
{}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   143
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   144
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   145
bool
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   146
HistoryTrailer<N>::IsOk (void) const
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   147
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   148
  return m_ok;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   149
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   150
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   151
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   152
std::string 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   153
HistoryTrailer<N>::DoGetName (void) const
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   154
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   155
  std::ostringstream oss;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   156
  oss << N;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   157
  return oss.str ();
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   158
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   159
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   160
void 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   161
HistoryTrailer<N>::PrintTo (std::ostream &os) const
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   162
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   163
  NS_ASSERT (false);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   164
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   165
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   166
uint32_t 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   167
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
   168
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   169
  return N;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   170
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   171
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   172
void 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   173
HistoryTrailer<N>::SerializeTo (Buffer::Iterator start) const
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   174
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   175
  start.Prev (N);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   176
  start.WriteU8 (N, N);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   177
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   178
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   179
uint32_t
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   180
HistoryTrailer<N>::DeserializeFrom (Buffer::Iterator start)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   181
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   182
  m_ok = true;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   183
  start.Prev (N);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   184
  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
   185
    {
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   186
      if (start.ReadU8 () != N)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   187
        {
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   188
          m_ok = false;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   189
        }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   190
    }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   191
  return N;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   192
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   193
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   194
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   195
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   196
class PacketMetadataTest : public Test {
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   197
public:
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   198
  PacketMetadataTest ();
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   199
  virtual ~PacketMetadataTest ();
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   200
  bool CheckHistory (Packet p, const char *file, int line, uint32_t n, ...);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   201
  virtual bool RunTests (void);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   202
private:
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   203
  template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   204
  void PrintHeader (std::ostream &os, uint32_t packetUid, uint32_t size, const HistoryHeader<N> *header);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   205
  template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   206
  void PrintTrailer (std::ostream &os, uint32_t packetUid, uint32_t size, const HistoryTrailer<N> *trailer);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   207
  void PrintFragment (std::ostream &os,uint32_t packetUid,
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   208
                      uint32_t size,std::string & name, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   209
                      struct PacketPrinter::FragmentInformation info);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   210
  void PrintDefault (std::ostream& os,uint32_t packetUid,
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   211
                     uint32_t size,std::string& name,
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   212
                     struct PacketPrinter::FragmentInformation info);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   213
  void PrintPayload (std::ostream &os,uint32_t packetUid,
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   214
                     uint32_t size,
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   215
                     struct PacketPrinter::FragmentInformation info);
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 RegisterHeader (void);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   218
  template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   219
  void RegisterTrailer (void);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   220
  void CleanupPrints (void);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   221
  bool Check (const char *file, int line, std::list<int> expected);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   222
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   223
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   224
  bool m_headerError;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   225
  bool m_trailerError;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   226
  std::list<int> m_prints;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   227
  PacketPrinter m_printer;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   228
};
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   229
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   230
PacketMetadataTest::PacketMetadataTest ()
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   231
  : Test ("PacketMetadata")
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   232
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   233
  m_printer.AddPayloadPrinter (MakeCallback (&PacketMetadataTest::PrintPayload, this));
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   234
  m_printer.AddDefaultPrinter (MakeCallback (&PacketMetadataTest::PrintDefault, this));
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   235
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   236
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   237
PacketMetadataTest::~PacketMetadataTest ()
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
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   240
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   241
void 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   242
PacketMetadataTest::RegisterHeader (void)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   243
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   244
  static bool registered = false;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   245
  if (!registered)
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
      m_printer.AddHeaderPrinter (MakeCallback (&PacketMetadataTest::PrintHeader<N>, this),
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   248
                                  MakeCallback (&PacketMetadataTest::PrintFragment, this));
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   249
      registered = true;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   250
    }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   251
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   252
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   253
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   254
void 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   255
PacketMetadataTest::RegisterTrailer (void)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   256
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   257
  static bool registered = false;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   258
  if (!registered)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   259
    {
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   260
      m_printer.AddTrailerPrinter (MakeCallback (&PacketMetadataTest::PrintTrailer<N>, this),
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   261
                                   MakeCallback (&PacketMetadataTest::PrintFragment, this));
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   262
      registered = true;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   263
    }
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
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   267
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   268
void 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   269
PacketMetadataTest::PrintHeader (std::ostream &os, uint32_t packetUid, uint32_t size, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   270
                                const HistoryHeader<N> *header)
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
  if (!header->IsOk ())
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   273
    {
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   274
      m_headerError = true;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   275
    }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   276
  m_prints.push_back (N);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   277
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   278
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   279
template <int N>
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   280
void 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   281
PacketMetadataTest::PrintTrailer (std::ostream &os, uint32_t packetUid, uint32_t size, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   282
                                 const HistoryTrailer<N> *trailer)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   283
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   284
  if (!trailer->IsOk ())
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   285
    {
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   286
      m_trailerError = true;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   287
    }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   288
  m_prints.push_back (N);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   289
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   290
void 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   291
PacketMetadataTest::PrintFragment (std::ostream &os,uint32_t packetUid,
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   292
                                  uint32_t size,std::string & name, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   293
                                  struct PacketPrinter::FragmentInformation info)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   294
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   295
  m_prints.push_back (size - (info.end + info.start));
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   296
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   297
void 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   298
PacketMetadataTest::PrintDefault (std::ostream& os,uint32_t packetUid,
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   299
                     uint32_t size,std::string& name,
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   300
                     struct PacketPrinter::FragmentInformation info)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   301
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   302
  NS_ASSERT (false);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   303
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   304
void 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   305
PacketMetadataTest::PrintPayload (std::ostream &os,uint32_t packetUid,
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   306
                                 uint32_t size,
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   307
                                 struct PacketPrinter::FragmentInformation info)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   308
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   309
  m_prints.push_back (size - (info.end + info.start));
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   310
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   311
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   312
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   313
void 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   314
PacketMetadataTest::CleanupPrints (void)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   315
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   316
  m_prints.clear ();
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   317
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   318
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   319
bool
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   320
PacketMetadataTest::Check (const char *file, int line, std::list<int> expected)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   321
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   322
  if (m_headerError)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   323
    {
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   324
      Failure () << "PacketMetadata header error. file=" << file 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   325
                << ", line=" << line << std::endl;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   326
      return false;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   327
    }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   328
  if (m_trailerError)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   329
    {
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   330
      Failure () << "PacketMetadata trailer error. file=" << file 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   331
                << ", line=" << line << std::endl;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   332
      return false;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   333
    }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   334
  if (expected.size () != m_prints.size ())
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   335
    {
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   336
      goto error;
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
  for (std::list<int>::iterator i = m_prints.begin (),
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   339
         j = expected.begin (); 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   340
       i != m_prints.end (); i++, j++)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   341
    {
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   342
      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
   343
      if (*j != *i)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   344
        {
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   345
          goto error;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   346
        }
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
  return true;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   349
 error:
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   350
  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
   351
            << ", line=" << line << ", got:\"";
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   352
  for (std::list<int>::iterator i = m_prints.begin (); 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   353
       i != m_prints.end (); i++)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   354
    {
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   355
      Failure () << *i << ", ";
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   356
    }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   357
  Failure () << "\", expected: \"";
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   358
  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
   359
       j != expected.end (); j++)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   360
    {
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   361
      Failure () << *j << ", ";
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   362
    }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   363
  Failure () << "\"" << std::endl;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   364
  return false;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   365
}
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
bool 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   368
PacketMetadataTest::CheckHistory (Packet p, const char *file, int line, uint32_t n, ...)
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
  m_headerError = false;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   371
  m_trailerError = false;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   372
  std::list<int> expected;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   373
  va_list ap;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   374
  va_start (ap, n);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   375
  for (uint32_t j = 0; j < n; j++)
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
      int v = va_arg (ap, int);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   378
      expected.push_back (v);
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
  va_end (ap);
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
  m_printer.PrintForward ();
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   383
  p.Print (Failure (), m_printer);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   384
  bool ok = Check (file, line, expected);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   385
  CleanupPrints ();
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   386
  if (!ok)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   387
    {
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   388
      return false;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   389
    }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   390
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   391
  m_printer.PrintBackward ();
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   392
  p.Print (Failure (), m_printer);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   393
  expected.reverse ();
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   394
  ok = Check (file, line, expected);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   395
  CleanupPrints ();
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   396
  return ok;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   397
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   398
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   399
#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
   400
  {                                             \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   401
    HistoryHeader<n> header;                    \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   402
    RegisterHeader<n> ();                       \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   403
    p.AddHeader (header);                       \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   404
  }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   405
#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
   406
  {                                             \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   407
    HistoryTrailer<n> trailer;                  \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   408
    RegisterTrailer<n> ();                      \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   409
    p.AddTrailer (trailer);                     \
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
#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
   412
  {                                             \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   413
    HistoryHeader<n> header;                    \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   414
    RegisterHeader<n> ();                       \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   415
    p.RemoveHeader (header);                    \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   416
  }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   417
#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
   418
  {                                             \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   419
    HistoryTrailer<n> trailer;                  \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   420
    RegisterTrailer<n> ();                      \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   421
    p.RemoveTrailer (trailer);                  \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   422
  }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   423
#define CHECK_HISTORY(p, ...)                   \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   424
  {                                             \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   425
    if (!CheckHistory (p, __FILE__,             \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   426
                      __LINE__, __VA_ARGS__))   \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   427
      {                                         \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   428
        ok = false;                             \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   429
      }                                         \
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   430
  }
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   431
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   432
bool
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   433
PacketMetadataTest::RunTests (void)
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   434
{
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   435
  bool ok = true;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   436
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   437
  PacketMetadata::Enable ();
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   438
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   439
  Packet p = Packet (0);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   440
  Packet p1 = Packet (0);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   441
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   442
  p = Packet (10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   443
  ADD_TRAILER (p, 100);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   444
  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
   445
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   446
  p = Packet (10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   447
  ADD_HEADER (p, 1);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   448
  ADD_HEADER (p, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   449
  ADD_HEADER (p, 3);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   450
  CHECK_HISTORY (p, 4, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   451
                 3, 2, 1, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   452
  ADD_HEADER (p, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   453
  CHECK_HISTORY (p, 5, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   454
                 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
   455
  ADD_HEADER (p, 6);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   456
  CHECK_HISTORY (p, 6, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   457
                 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
   458
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   459
  p = Packet (10);
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);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   463
  REM_HEADER (p, 3);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   464
  CHECK_HISTORY (p, 3, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   465
                 2, 1, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   466
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   467
  p = Packet (10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   468
  ADD_HEADER (p, 1);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   469
  ADD_HEADER (p, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   470
  ADD_HEADER (p, 3);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   471
  REM_HEADER (p, 3);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   472
  REM_HEADER (p, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   473
  CHECK_HISTORY (p, 2, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   474
                 1, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   475
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   476
  p = Packet (10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   477
  ADD_HEADER (p, 1);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   478
  ADD_HEADER (p, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   479
  ADD_HEADER (p, 3);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   480
  REM_HEADER (p, 3);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   481
  REM_HEADER (p, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   482
  REM_HEADER (p, 1);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   483
  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
   484
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   485
  p = Packet (10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   486
  ADD_HEADER (p, 1);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   487
  ADD_HEADER (p, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   488
  ADD_HEADER (p, 3);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   489
  p1 = p;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   490
  REM_HEADER (p1, 3);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   491
  REM_HEADER (p1, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   492
  REM_HEADER (p1, 1);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   493
  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
   494
  CHECK_HISTORY (p, 4, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   495
                 3, 2, 1, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   496
  ADD_HEADER (p1, 1);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   497
  ADD_HEADER (p1, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   498
  CHECK_HISTORY (p1, 3, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   499
                 2, 1, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   500
  CHECK_HISTORY (p, 4, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   501
                 3, 2, 1, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   502
  ADD_HEADER (p, 3);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   503
  CHECK_HISTORY (p, 5, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   504
                 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
   505
  ADD_TRAILER (p, 4);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   506
  CHECK_HISTORY (p, 6, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   507
                 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
   508
  ADD_TRAILER (p, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   509
  CHECK_HISTORY (p, 7, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   510
                 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
   511
  REM_HEADER (p, 3);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   512
  CHECK_HISTORY (p, 6, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   513
                 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
   514
  REM_TRAILER (p, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   515
  CHECK_HISTORY (p, 5, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   516
                 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
   517
  p1 = p;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   518
  REM_TRAILER (p, 4);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   519
  CHECK_HISTORY (p, 4, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   520
                 3, 2, 1, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   521
  CHECK_HISTORY (p1, 5, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   522
                 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
   523
  p1.RemoveAtStart (3);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   524
  CHECK_HISTORY (p1, 4, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   525
                 2, 1, 10, 4);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   526
  p1.RemoveAtStart (1);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   527
  CHECK_HISTORY (p1, 4, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   528
                 1, 1, 10, 4);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   529
  p1.RemoveAtStart (1);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   530
  CHECK_HISTORY (p1, 3, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   531
                 1, 10, 4);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   532
  p1.RemoveAtEnd (4);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   533
  CHECK_HISTORY (p1, 2, 
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   534
                 1, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   535
  p1.RemoveAtStart (1);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   536
  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
   537
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   538
  p = Packet (10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   539
  ADD_HEADER (p, 8);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   540
  ADD_TRAILER (p, 8);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   541
  ADD_TRAILER (p, 8);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   542
  p.RemoveAtStart (8+10+8);
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, 8);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   544
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   545
  p = Packet (10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   546
  ADD_HEADER (p, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   547
  ADD_HEADER (p, 8);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   548
  ADD_TRAILER (p, 6);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   549
  ADD_TRAILER (p, 7);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   550
  ADD_TRAILER (p, 9);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   551
  p.RemoveAtStart (5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   552
  p.RemoveAtEnd (12);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   553
  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
   554
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   555
  p = Packet (10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   556
  ADD_HEADER (p, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   557
  ADD_TRAILER (p, 6);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   558
  p.RemoveAtEnd (18);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   559
  ADD_TRAILER (p, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   560
  ADD_HEADER (p, 3);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   561
  CHECK_HISTORY (p, 3, 3, 8, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   562
  p.RemoveAtStart (12);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   563
  CHECK_HISTORY (p, 1, 4);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   564
  p.RemoveAtEnd (2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   565
  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
   566
  ADD_HEADER (p, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   567
  CHECK_HISTORY (p, 2, 10, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   568
  p.RemoveAtEnd (5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   569
  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
   570
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   571
  Packet p2 = Packet (0);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   572
  Packet p3 = Packet (0);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   573
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   574
  p = Packet (40);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   575
  ADD_HEADER (p, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   576
  ADD_HEADER (p, 8);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   577
  CHECK_HISTORY (p, 3, 8, 5, 40);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   578
  p1 = p.CreateFragment (0, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   579
  p2 = p.CreateFragment (5, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   580
  p3 = p.CreateFragment (10, 43);
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);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   582
  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
   583
  CHECK_HISTORY (p3, 2, 3, 40);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   584
  p1.AddAtEnd (p2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   585
  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
   586
  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
   587
  p1.AddAtEnd (p3);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   588
  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
   589
  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
   590
  CHECK_HISTORY (p3, 2, 3, 40);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   591
  p1 = p.CreateFragment (0, 5);
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
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   594
  p3 = Packet (50);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   595
  ADD_HEADER (p3, 8);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   596
  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
   597
  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
   598
  p1.AddAtEnd (p3);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   599
  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
   600
  ADD_HEADER (p1, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   601
  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
   602
  ADD_TRAILER (p1, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   603
  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
   604
  REM_HEADER (p1, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   605
  CHECK_HISTORY (p1, 4, 5, 8, 50, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   606
  p1.RemoveAtEnd (60);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   607
  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
   608
  p1.AddAtEnd (p2);
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, 8, 2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   610
  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
   611
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   612
  p3 = Packet (40);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   613
  ADD_HEADER (p3, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   614
  ADD_HEADER (p3, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   615
  CHECK_HISTORY (p3, 3, 5, 5, 40);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   616
  p1 = p3.CreateFragment (0, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   617
  p2 = p3.CreateFragment (5, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   618
  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
   619
  CHECK_HISTORY (p2, 1, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   620
  p1.AddAtEnd (p2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   621
  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
   622
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   623
  p = Packet (0);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   624
  CHECK_HISTORY (p, 0);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   625
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   626
  p3 = Packet (0);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   627
  ADD_HEADER (p3, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   628
  ADD_HEADER (p3, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   629
  CHECK_HISTORY (p3, 2, 5, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   630
  p1 = p3.CreateFragment (0, 4);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   631
  p2 = p3.CreateFragment (9, 1);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   632
  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
   633
  CHECK_HISTORY (p2, 1, 1);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   634
  p1.AddAtEnd (p2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   635
  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
   636
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   637
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   638
  p = Packet (2000);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   639
  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
   640
  
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   641
  p = Packet ();
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   642
  ADD_TRAILER (p, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   643
  ADD_HEADER (p, 5);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   644
  p1 = p.CreateFragment (0, 8);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   645
  p2 = p.CreateFragment (8, 7);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   646
  p1.AddAtEnd (p2);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   647
  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
   648
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   649
  p = Packet ();
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   650
  ADD_TRAILER (p, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   651
  REM_TRAILER (p, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   652
  ADD_TRAILER (p, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   653
  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
   654
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   655
  p = Packet ();
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   656
  ADD_HEADER (p, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   657
  REM_HEADER (p, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   658
  ADD_HEADER (p, 10);
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   659
  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
   660
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   661
  return ok;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   662
}
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   663
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   664
static PacketMetadataTest g_packetHistoryTest;
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   665
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   666
}//namespace ns3
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   667
5f5d33e01eb9 split test code out of the main PacketMetadata code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   668
#endif /* RUN_SELF_TESTS */