aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/tests
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@broadpark.no>2019-02-06 14:09:57 +0100
committerTor Egge <Tor.Egge@broadpark.no>2019-02-06 14:09:57 +0100
commitd93960e181aa7010f4de80b5b3c5ac21c602ed41 (patch)
treef349126505986e84c0af787b7f69c3c4d396227d /vespalib/src/tests
parent7e93d5dac4c722f1efa0e85e511a90084264a99f (diff)
Eliminate clang warning in vespalib
Diffstat (limited to 'vespalib/src/tests')
-rw-r--r--vespalib/src/tests/alignedmemory/.cvsignore3
-rw-r--r--vespalib/src/tests/alignedmemory/.gitignore4
-rw-r--r--vespalib/src/tests/alignedmemory/CMakeLists.txt8
-rw-r--r--vespalib/src/tests/alignedmemory/DESC1
-rw-r--r--vespalib/src/tests/alignedmemory/FILES1
-rw-r--r--vespalib/src/tests/alignedmemory/alignedmemory_test.cpp68
-rw-r--r--vespalib/src/tests/net/send_fd/send_fd_test.cpp4
-rw-r--r--vespalib/src/tests/stllike/string_test.cpp19
8 files changed, 19 insertions, 89 deletions
diff --git a/vespalib/src/tests/alignedmemory/.cvsignore b/vespalib/src/tests/alignedmemory/.cvsignore
deleted file mode 100644
index 0cc06a2789a..00000000000
--- a/vespalib/src/tests/alignedmemory/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
-.depend
-Makefile
-alignedmemory_test
diff --git a/vespalib/src/tests/alignedmemory/.gitignore b/vespalib/src/tests/alignedmemory/.gitignore
deleted file mode 100644
index 8777f6e4632..00000000000
--- a/vespalib/src/tests/alignedmemory/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-.depend
-Makefile
-alignedmemory_test
-vespalib_alignedmemory_test_app
diff --git a/vespalib/src/tests/alignedmemory/CMakeLists.txt b/vespalib/src/tests/alignedmemory/CMakeLists.txt
deleted file mode 100644
index 332e941f935..00000000000
--- a/vespalib/src/tests/alignedmemory/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-vespa_add_executable(vespalib_alignedmemory_test_app TEST
- SOURCES
- alignedmemory_test.cpp
- DEPENDS
- vespalib
-)
-vespa_add_test(NAME vespalib_alignedmemory_test_app COMMAND vespalib_alignedmemory_test_app)
diff --git a/vespalib/src/tests/alignedmemory/DESC b/vespalib/src/tests/alignedmemory/DESC
deleted file mode 100644
index 4f3b4f32604..00000000000
--- a/vespalib/src/tests/alignedmemory/DESC
+++ /dev/null
@@ -1 +0,0 @@
-alignedmemory test. Take a look at alignedmemory.cpp for details.
diff --git a/vespalib/src/tests/alignedmemory/FILES b/vespalib/src/tests/alignedmemory/FILES
deleted file mode 100644
index d0363c78367..00000000000
--- a/vespalib/src/tests/alignedmemory/FILES
+++ /dev/null
@@ -1 +0,0 @@
-alignedmemory.cpp
diff --git a/vespalib/src/tests/alignedmemory/alignedmemory_test.cpp b/vespalib/src/tests/alignedmemory/alignedmemory_test.cpp
deleted file mode 100644
index d53e8f212c0..00000000000
--- a/vespalib/src/tests/alignedmemory/alignedmemory_test.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/log/log.h>
-LOG_SETUP("alignedmemory_test");
-#include <vespa/vespalib/testkit/testapp.h>
-#include <vespa/vespalib/util/alignedmemory.h>
-
-using namespace vespalib;
-
-TEST_SETUP(Test);
-
-int
-Test::Main()
-{
- TEST_INIT("alignedmemory_test");
- { // aligned alloc
- AlignedMemory mem8(32, 8);
- AlignedMemory mem16(32, 16);
- AlignedMemory mem512(32, 512);
- AlignedMemory mem7(32, 7);
-
- EXPECT_EQUAL(0u, ((uintptr_t)mem8.get()) % 8);
- EXPECT_EQUAL(0u, ((uintptr_t)mem16.get()) % 16);
- EXPECT_EQUAL(0u, ((uintptr_t)mem512.get()) % 512);
- EXPECT_EQUAL(0u, ((uintptr_t)mem7.get()) % 7);
- }
- { // swap
- AlignedMemory a(32, 8);
- AlignedMemory b(32, 8);
- char *pa = a.get();
- char *pb = b.get();
-
- EXPECT_EQUAL(pa, a.get());
- EXPECT_EQUAL(pb, b.get());
- a.swap(b);
- EXPECT_EQUAL(pb, a.get());
- EXPECT_EQUAL(pa, b.get());
- b.swap(a);
- EXPECT_EQUAL(pa, a.get());
- EXPECT_EQUAL(pb, b.get());
- }
- { // std::swap
- AlignedMemory a(32, 8);
- AlignedMemory b(32, 8);
- char *pa = a.get();
- char *pb = b.get();
-
- EXPECT_EQUAL(pa, a.get());
- EXPECT_EQUAL(pb, b.get());
- std::swap(a, b);
- EXPECT_EQUAL(pb, a.get());
- EXPECT_EQUAL(pa, b.get());
- std::swap(a, b);
- EXPECT_EQUAL(pa, a.get());
- EXPECT_EQUAL(pb, b.get());
- }
- { // construct with zero size
- AlignedMemory null(0, 0);
- char *expect = 0;
- EXPECT_EQUAL(expect, null.get());
- }
- { // const get()
- const AlignedMemory null(0, 0);
- const char *expect = 0;
- const char *got = null.get();
- EXPECT_EQUAL(expect, got);
- }
- TEST_DONE();
-}
diff --git a/vespalib/src/tests/net/send_fd/send_fd_test.cpp b/vespalib/src/tests/net/send_fd/send_fd_test.cpp
index ce7e7f20b30..e9921f75207 100644
--- a/vespalib/src/tests/net/send_fd/send_fd_test.cpp
+++ b/vespalib/src/tests/net/send_fd/send_fd_test.cpp
@@ -74,7 +74,7 @@ void send_fd(SocketHandle &socket, SocketHandle fd) {
hdr->cmsg_level = SOL_SOCKET;
hdr->cmsg_type = SCM_RIGHTS;
hdr->cmsg_len = CMSG_LEN(sizeof(int));
- int *fd_dst = (int *) CMSG_DATA(hdr);
+ int *fd_dst = (int *) (void *) CMSG_DATA(hdr);
fd_dst[0] = fd.get();
ssize_t res = sendmsg(socket.get(), &msg, 0);
ASSERT_EQUAL(res, 1);
@@ -97,7 +97,7 @@ SocketHandle recv_fd(SocketHandle &socket) {
bool type_ok = ((hdr->cmsg_level == SOL_SOCKET) &&
(hdr->cmsg_type == SCM_RIGHTS));
ASSERT_TRUE(type_ok);
- int *fd_src = (int *) CMSG_DATA(hdr);
+ int *fd_src = (int *) (void *) CMSG_DATA(hdr);
fprintf(stderr, "got fd: %d\n", fd_src[0]);
return SocketHandle(fd_src[0]);
}
diff --git a/vespalib/src/tests/stllike/string_test.cpp b/vespalib/src/tests/stllike/string_test.cpp
index 96c095667ee..885c13172b1 100644
--- a/vespalib/src/tests/stllike/string_test.cpp
+++ b/vespalib/src/tests/stllike/string_test.cpp
@@ -27,12 +27,27 @@ TEST("test iterator assignment") {
EXPECT_TRUE(strstr(s.c_str(), "mumbo jumbo.") == nullptr);
}
+namespace {
+
+template <typename S>
+void assign(S &lhs, const S &rhs) __attribute__((noinline));
+
+template <typename S>
+void
+assign(S &lhs, const S &rhs)
+{
+ lhs = rhs;
+}
+
+}
+
+
TEST("test self assignment of small string") {
const char * text = "abc";
string s(text);
const char * addr(reinterpret_cast<const char *>(&s));
EXPECT_TRUE((addr < s.c_str()) && (s.c_str() < addr + sizeof(s)));
- s = s;
+ assign(s, s);
EXPECT_EQUAL(text, s);
}
@@ -41,7 +56,7 @@ TEST("test self assignment of big string") {
string s(text);
const char * addr(reinterpret_cast<const char *>(&s));
EXPECT_TRUE((addr > s.c_str()) || (s.c_str() > addr + sizeof(s)));
- s = s;
+ assign(s, s);
EXPECT_EQUAL(text, s);
}