diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
commit | ed5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch) | |
tree | 7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /sal/qa/osl/socket.cxx | |
parent | Initial commit. (diff) | |
download | libreoffice-upstream.tar.xz libreoffice-upstream.zip |
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sal/qa/osl/socket.cxx')
-rw-r--r-- | sal/qa/osl/socket.cxx | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/sal/qa/osl/socket.cxx b/sal/qa/osl/socket.cxx new file mode 100644 index 000000000..ed31c9ede --- /dev/null +++ b/sal/qa/osl/socket.cxx @@ -0,0 +1,58 @@ +/* -*- 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_createInetSocketAddr); + CPPUNIT_TEST(test_createInetBroadcastAddr); + CPPUNIT_TEST_SUITE_END(); + + void test_createInetSocketAddr() + { + OUString const in("123.4.56.78"); + auto const addr = osl_createInetSocketAddr(in.pData, 100); + CPPUNIT_ASSERT(addr != nullptr); + CPPUNIT_ASSERT_EQUAL(osl_Socket_FamilyInet, osl_getFamilyOfSocketAddr(addr)); + OUString out; + auto const res = osl_getDottedInetAddrOfSocketAddr(addr, &out.pData); + CPPUNIT_ASSERT_EQUAL(osl_Socket_Ok, res); + CPPUNIT_ASSERT_EQUAL(in, out); + CPPUNIT_ASSERT_EQUAL(sal_Int32(100), osl_getInetPortOfSocketAddr(addr)); + osl_destroySocketAddr(addr); + } + + void test_createInetBroadcastAddr() + { + OUString const in("123.4.56.78"); + auto const addr = osl_createInetBroadcastAddr(in.pData, 100); + CPPUNIT_ASSERT(addr != nullptr); + CPPUNIT_ASSERT_EQUAL(osl_Socket_FamilyInet, osl_getFamilyOfSocketAddr(addr)); + OUString out; + auto const res = osl_getDottedInetAddrOfSocketAddr(addr, &out.pData); + CPPUNIT_ASSERT_EQUAL(osl_Socket_Ok, res); + CPPUNIT_ASSERT_EQUAL(OUString("123.255.255.255"), out); + CPPUNIT_ASSERT_EQUAL(sal_Int32(100), osl_getInetPortOfSocketAddr(addr)); + osl_destroySocketAddr(addr); + } +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(SocketTest); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |