diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2021-05-31 09:36:28 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2021-05-31 10:59:46 +0200 |
commit | 33bf4f0bcf941ee4609f558442035514f54cbc8a (patch) | |
tree | 77bfd61a5b7d3b236a94e97fa488f1c688b25587 /sal/qa | |
parent | c7f484eb774fc90cf8e1540a703c5c3856312ef2 (diff) |
Replace inet_ntoa with inet_ntop
...as inet_ntoa is potentially not thread-safe; and add a test
Change-Id: I9df945b006ba7194c3b1444c4886101c08339ad0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116425
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sal/qa')
-rw-r--r-- | sal/qa/osl/socket.cxx | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/sal/qa/osl/socket.cxx b/sal/qa/osl/socket.cxx new file mode 100644 index 000000000000..dab2621f2293 --- /dev/null +++ b/sal/qa/osl/socket.cxx @@ -0,0 +1,40 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <cppunit/TestAssert.h> +#include <cppunit/TestFixture.h> +#include <cppunit/extensions/HelperMacros.h> + +#include <osl/socket.h> +#include <rtl/ustring.hxx> + +namespace +{ +class SocketTest : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE(SocketTest); + CPPUNIT_TEST(test_getDottedInetAddrOfSocketAddr); + CPPUNIT_TEST_SUITE_END(); + + void test_getDottedInetAddrOfSocketAddr() + { + OUString const in("123.4.56.78"); + auto const addr = osl_createInetSocketAddr(in.pData, 0); + CPPUNIT_ASSERT(addr != nullptr); + OUString out; + auto const res = osl_getDottedInetAddrOfSocketAddr(addr, &out.pData); + CPPUNIT_ASSERT_EQUAL(osl_Socket_Ok, res); + CPPUNIT_ASSERT_EQUAL(in, out); + } +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(SocketTest); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |