Correcting bug with content object serialization
diff --git a/model/ndn-content-object.cc b/model/ndn-content-object.cc
index 30a19de..e03387c 100644
--- a/model/ndn-content-object.cc
+++ b/model/ndn-content-object.cc
@@ -67,10 +67,36 @@
   return m_name;
 }
 
+
+void
+ContentObjectHeader::SetTimestamp (const Time &timestamp)
+{
+  m_timestamp = timestamp;
+}
+
+Time
+ContentObjectHeader::GetTimestamp () const
+{
+  return m_timestamp;
+}
+    
+void
+ContentObjectHeader::SetFreshness (const Time &freshness)
+{
+  m_freshness = freshness;
+}
+
+Time
+ContentObjectHeader::GetFreshness () const
+{
+  return m_freshness;
+}
+
+
 uint32_t
 ContentObjectHeader::GetSerializedSize () const
 {
-  uint32_t size = 2 + ((2 + 1) + (m_name->GetSerializedSize ()) + (2 + 2 + 4 + 2 + 2 + (2 + 0)));
+  uint32_t size = 2 + ((2 + 2) + (m_name->GetSerializedSize ()) + (2 + 2 + 4 + 2 + 2 + (2 + 0)));
   NS_LOG_INFO ("Serialize size = " << size);
   return size;
 }
@@ -86,6 +112,7 @@
 
   // name
   uint32_t offset = m_name->Serialize (start);
+  NS_LOG_DEBUG ("Offset: " << offset);
   start.Next (offset);
 
   // content
@@ -136,7 +163,7 @@
   if (i.ReadU16 () != 0) // Length (ContentInfoOptions)
     throw new ContentObjectHeaderException ();
 
-  NS_ASSERT_MSG (i.GetDistanceFrom (start) != GetSerializedSize (),
+  NS_ASSERT_MSG (i.GetDistanceFrom (start) == GetSerializedSize (),
                  "Something wrong with ContentObjectHeader::Deserialize");
   
   return i.GetDistanceFrom (start);
diff --git a/test/ndnSIM-serialization.cc b/test/ndnSIM-serialization.cc
index bb4a573..1ce7130 100644
--- a/test/ndnSIM-serialization.cc
+++ b/test/ndnSIM-serialization.cc
@@ -71,8 +71,28 @@
 void
 ContentObjectSerializationTest::DoRun ()
 {
-  // NS_TEST_ASSERT_MSG_EQ (true, false, "test not implemented yet");
+  ContentObjectHeader source;
+  
+  source.SetName (Create<NameComponents> (boost::lexical_cast<NameComponents> ("/test/test2/1")));
+  NS_TEST_ASSERT_MSG_EQ (source.GetName (), boost::lexical_cast<NameComponents> ("/test/test2/1"), "set/get name failed");
+  
+  source.SetFreshness (Seconds (10));
+  NS_TEST_ASSERT_MSG_EQ (source.GetFreshness (), Seconds (10), "set/get freshness failed");
+
+  source.SetTimestamp (Seconds (100));
+  NS_TEST_ASSERT_MSG_EQ (source.GetTimestamp (), Seconds (100), "set/get timestamp failed");
+
+  Packet packet (0);
+  //serialization
+  packet.AddHeader (source);
+	
+  //deserialization
+  ContentObjectHeader target;
+  packet.RemoveHeader (target);
+  
+  NS_TEST_ASSERT_MSG_EQ (source.GetName ()     , target.GetName ()     , "source/target name failed");
+  NS_TEST_ASSERT_MSG_EQ (source.GetFreshness (), target.GetFreshness (), "source/target freshness failed");
+  NS_TEST_ASSERT_MSG_EQ (source.GetTimestamp (), target.GetTimestamp (), "source/target timestamp failed");
 }
 
 }
-