X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FProtocols%2FUN%2FUNAddressing.test.cc;h=d3a7fc6174a18b9b4cc7091e2a0cd6067e32aa05;hb=731a143df4de38d4c8b0a81121990951971cd858;hp=7bd8e7fdabf281a215c33a30164511d9a5026c0f;hpb=d6abda313f70c8a849c5e3f3bbfc12ce301789f1;p=senf.git diff --git a/Socket/Protocols/UN/UNAddressing.test.cc b/Socket/Protocols/UN/UNAddressing.test.cc index 7bd8e7f..d3a7fc6 100644 --- a/Socket/Protocols/UN/UNAddressing.test.cc +++ b/Socket/Protocols/UN/UNAddressing.test.cc @@ -1,7 +1,9 @@ -// Copyright (C) 2007 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum NETwork research (NET) -// David Wagner +// $Id$ +// +// Copyright (C) 2009 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Thorsten Horstmann // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -19,32 +21,41 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief UNAddressing.test unit tests */ + \brief UNAddressing unit tests */ //#include "UNAddressing.test.hh" //#include "UNAddressing.test.ih" // Custom includes #include "UNAddressing.hh" +#include "../AddressExceptions.hh" +#include #include "../../../Utils/auto_unit_test.hh" #include -#include -#include - #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// -BOOST_AUTO_UNIT_TEST(unSocketAddress) +BOOST_AUTO_UNIT_TEST(UNSocketAddress) { - std::string testS = "/tmp/senfTestSocket"; - senf::UNSocketAddress addr (testS) ; - int mySock = socket(AF_UNIX, SOCK_DGRAM, 0); - if (bind(mySock, addr.sockaddr_p(), addr.sockaddr_len())) { - std::cout << "Error while binding name to unix socket" << std::endl; - } - + senf::UNSocketAddress addr; + BOOST_CHECK( ! addr); + + std::string path ("/tmp/SENF_TEST"); + addr.path( path); + + BOOST_CHECK( addr); + BOOST_CHECK_EQUAL( addr.path(), path); + BOOST_CHECK_EQUAL( addr, senf::UNSocketAddress(path)); + BOOST_CHECK_EQUAL( addr, senf::UNSocketAddress(addr)); + + std::stringstream str; + str << addr; + BOOST_CHECK_EQUAL( str.str(), path ); + + // UNSocketAddress path too long + BOOST_CHECK_THROW( senf::UNSocketAddress(std::string(1024, 'x')), senf::AddressSyntaxException ); } ///////////////////////////////cc.e////////////////////////////////////////