senfscons: Much improved install implementation
[senf.git] / Utils / hexdump.test.cc
similarity index 64%
rename from Socket/Protocols/GenericSockAddr.cci
rename to Utils/hexdump.test.cc
index 3aa05af..ac64f5f 100644 (file)
@@ -1,4 +1,6 @@
-// Copyright (C) 2007
+// $Id$
+//
+// Copyright (C) 2007 
 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
 //     Stefan Bund <g0dil@berlios.de>
 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 /** \file
-    \brief GenericSockAddr inline non-template implementation */
-
-// Custom includes
+    \brief hexdump.test unit tests */
 
-#define prefix_ inline
-///////////////////////////////cci.p///////////////////////////////////////
+//#include "hexdump.test.hh"
+//#include "hexdump.test.ih"
 
-prefix_ senf::GenericSockAddr::GenericSockAddr()
-{}
+// Custom includes
+#include "hexdump.hh"
+#include <sstream>
 
-prefix_ struct sockaddr * senf::GenericSockAddr::sockaddr_p()
-{
-    return reinterpret_cast<sockaddr *>(&addr_);
-}
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/test/test_tools.hpp>
 
-prefix_ struct sockaddr const * senf::GenericSockAddr::sockaddr_p()
-    const
-{
-    return reinterpret_cast<sockaddr const *>(&addr_);
-}
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
 
-prefix_ unsigned senf::GenericSockAddr::sockaddr_len()
-    const
+BOOST_AUTO_UNIT_TEST(hExDuMp)
 {
-    return sizeof(addr_);
+    char data[] = { 0x18, 0x19, 0x20, 0x21, 0x7c, 0x7d, 0x7e, 0x7f };
+    std::stringstream s;
+    senf::hexdump(data, data+sizeof(data), s, 8);
+    BOOST_CHECK_EQUAL( s.str(), "  0000  18 19 20 21  7c 7d 7e 7f  .. ! |}..\n" );
 }
 
-///////////////////////////////cci.e///////////////////////////////////////
+///////////////////////////////cc.e////////////////////////////////////////
 #undef prefix_
 
 \f
 // Local Variables:
 // mode: c++
 // fill-column: 100
+// comment-column: 40
 // c-file-style: "senf"
 // indent-tabs-mode: nil
 // ispell-local-dictionary: "american"
 // compile-command: "scons -u test"
-// comment-column: 40
 // End: