summaryrefslogtreecommitdiff
path: root/tests/stdlib_test.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2013-02-04 13:18:00 -0800
committerElliott Hughes <enh@google.com>2013-02-04 13:18:00 -0800
commitb16b72248bd109b6073df6a45aeffaa69e38cfc6 (patch)
treee30f6d4ea4a010c2888773e68861955b636a0230 /tests/stdlib_test.cpp
parenta1821f015306e221e6a51e5acc27176ae2d72f6b (diff)
Add basic tests for posix_memalign.
Change-Id: Ie34fcc87aa9e8bfc715e25161752024b11e2032a
Diffstat (limited to 'tests/stdlib_test.cpp')
-rw-r--r--tests/stdlib_test.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/stdlib_test.cpp b/tests/stdlib_test.cpp
index a9c62d40a..8735100d4 100644
--- a/tests/stdlib_test.cpp
+++ b/tests/stdlib_test.cpp
@@ -16,6 +16,8 @@
#include <gtest/gtest.h>
+#include <errno.h>
+#include <stdint.h>
#include <stdlib.h>
TEST(stdlib, drand48) {
@@ -57,3 +59,14 @@ TEST(stdlib, mrand48) {
EXPECT_EQ(1804534249, mrand48());
EXPECT_EQ(264732262, mrand48());
}
+
+TEST(stdlib, posix_memalign) {
+ void* p;
+
+ ASSERT_EQ(0, posix_memalign(&p, 512, 128));
+ ASSERT_EQ(0U, reinterpret_cast<uintptr_t>(p) % 512);
+ free(p);
+
+ // Can't align to a non-power of 2.
+ ASSERT_EQ(EINVAL, posix_memalign(&p, 81, 128));
+}