Skip to content
Snippets Groups Projects
Commit f8f169db authored by Benjamin Cumming's avatar Benjamin Cumming Committed by Sam Yates
Browse files

Fix small compilation errors on OS X (#482)

* Use `sys/types.h` instead of `endian.h` for greater portability.
* Avoid use of constructor for `std::vector` in unit tests that is only available from C++14.
parent 1cf2df76
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,9 @@
#include <utility>
extern "C" {
#include <endian.h>
// The system header endian.h is not in /sys/include/ on Mac OS X.
// Include sys/types.h, which pulls in endian.h on all systems.
#include <sys/types.h>
}
#include <threading/threading.hpp>
......
......@@ -19,7 +19,7 @@ static bool is_aligned(void* p, std::size_t k) {
TEST(padded_vector, alignment) {
padded_allocator<double> pa(1024);
pvector<double> a(101, pa);
pvector<double> a(101, 0.0, pa);
EXPECT_EQ(1024u, a.get_allocator().alignment());
EXPECT_TRUE(is_aligned(a.data(), 1024));
......@@ -29,14 +29,14 @@ TEST(padded_vector, allocator_constraints) {
EXPECT_THROW(padded_allocator<char>(7), std::range_error);
padded_allocator<char> pa(2); // less than sizeof(void*)
std::vector<char, padded_allocator<char>> v(7, pa);
std::vector<char, padded_allocator<char>> v(7, 'a', pa);
EXPECT_TRUE(is_aligned(v.data(), sizeof(void*)));
}
TEST(padded_vector, allocator_propagation) {
padded_allocator<double> pa(1024);
pvector<double> a(101, pa);
pvector<double> a(101, 0, pa);
EXPECT_EQ(pa, a.get_allocator());
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment