diff options
Diffstat (limited to 'intern/atomic/tests/atomic_test.cc')
-rw-r--r-- | intern/atomic/tests/atomic_test.cc | 189 |
1 files changed, 189 insertions, 0 deletions
diff --git a/intern/atomic/tests/atomic_test.cc b/intern/atomic/tests/atomic_test.cc index d79374416ec..37a66cf0e9c 100644 --- a/intern/atomic/tests/atomic_test.cc +++ b/intern/atomic/tests/atomic_test.cc @@ -143,6 +143,40 @@ TEST(atomic, atomic_cas_uint64) } } +TEST(atomic, atomic_load_uint64) +{ + /* Make sure alias is implemented. */ + { + uint64_t value = 2; + EXPECT_EQ(atomic_load_uint64(&value), 2); + } + + /* Make sure alias is using proper bitness. */ + { + const uint64_t uint64_t_max = std::numeric_limits<uint64_t>::max(); + uint64_t value = uint64_t_max; + EXPECT_EQ(atomic_load_uint64(&value), uint64_t_max); + } +} + +TEST(atomic, atomic_store_uint64) +{ + /* Make sure alias is implemented. */ + { + uint64_t value = 0; + atomic_store_uint64(&value, 2); + EXPECT_EQ(value, 2); + } + + /* Make sure alias is using proper bitness. */ + { + const uint64_t uint64_t_max = std::numeric_limits<uint64_t>::max(); + uint64_t value = 0; + atomic_store_uint64(&value, uint64_t_max); + EXPECT_EQ(value, uint64_t_max); + } +} + /** \} */ /* -------------------------------------------------------------------- */ @@ -277,6 +311,40 @@ TEST(atomic, atomic_cas_int64) } } +TEST(atomic, atomic_load_int64) +{ + /* Make sure alias is implemented. */ + { + int64_t value = 2; + EXPECT_EQ(atomic_load_int64(&value), 2); + } + + /* Make sure alias is using proper bitness. */ + { + const int64_t int64_t_max = std::numeric_limits<int64_t>::max(); + int64_t value = int64_t_max; + EXPECT_EQ(atomic_load_int64(&value), int64_t_max); + } +} + +TEST(atomic, atomic_store_int64) +{ + /* Make sure alias is implemented. */ + { + int64_t value = 0; + atomic_store_int64(&value, 2); + EXPECT_EQ(value, 2); + } + + /* Make sure alias is using proper bitness. */ + { + const int64_t int64_t_max = std::numeric_limits<int64_t>::max(); + int64_t value = 0; + atomic_store_int64(&value, int64_t_max); + EXPECT_EQ(value, int64_t_max); + } +} + /** \} */ /* -------------------------------------------------------------------- */ @@ -358,6 +426,40 @@ TEST(atomic, atomic_cas_uint32) } } +TEST(atomic, atomic_load_uint32) +{ + /* Make sure alias is implemented. */ + { + uint32_t value = 2; + EXPECT_EQ(atomic_load_uint32(&value), 2); + } + + /* Make sure alias is using proper bitness. */ + { + const uint32_t uint32_t_max = std::numeric_limits<uint32_t>::max(); + uint32_t value = uint32_t_max; + EXPECT_EQ(atomic_load_uint32(&value), uint32_t_max); + } +} + +TEST(atomic, atomic_store_uint32) +{ + /* Make sure alias is implemented. */ + { + uint32_t value = 0; + atomic_store_uint32(&value, 2); + EXPECT_EQ(value, 2); + } + + /* Make sure alias is using proper bitness. */ + { + const uint32_t uint32_t_max = std::numeric_limits<uint32_t>::max(); + uint32_t value = 0; + atomic_store_uint32(&value, uint32_t_max); + EXPECT_EQ(value, uint32_t_max); + } +} + TEST(atomic, atomic_fetch_and_add_uint32) { { @@ -505,6 +607,40 @@ TEST(atomic, atomic_cas_int32) } } +TEST(atomic, atomic_load_int32) +{ + /* Make sure alias is implemented. */ + { + int32_t value = 2; + EXPECT_EQ(atomic_load_int32(&value), 2); + } + + /* Make sure alias is using proper bitness. */ + { + const int32_t int32_t_max = std::numeric_limits<int32_t>::max(); + int32_t value = int32_t_max; + EXPECT_EQ(atomic_load_int32(&value), int32_t_max); + } +} + +TEST(atomic, atomic_store_int32) +{ + /* Make sure alias is implemented. */ + { + int32_t value = 0; + atomic_store_int32(&value, 2); + EXPECT_EQ(value, 2); + } + + /* Make sure alias is using proper bitness. */ + { + const int32_t int32_t_max = std::numeric_limits<int32_t>::max(); + int32_t value = 0; + atomic_store_int32(&value, int32_t_max); + EXPECT_EQ(value, int32_t_max); + } +} + TEST(atomic, atomic_fetch_and_add_int32) { { @@ -761,6 +897,40 @@ TEST(atomic, atomic_cas_z) } } +TEST(atomic, atomic_load_z) +{ + /* Make sure alias is implemented. */ + { + size_t value = 2; + EXPECT_EQ(atomic_load_z(&value), 2); + } + + /* Make sure alias is using proper bitness. */ + { + const size_t size_t_max = std::numeric_limits<size_t>::max(); + size_t value = size_t_max; + EXPECT_EQ(atomic_load_z(&value), size_t_max); + } +} + +TEST(atomic, atomic_store_z) +{ + /* Make sure alias is implemented. */ + { + size_t value = 0; + atomic_store_z(&value, 2); + EXPECT_EQ(value, 2); + } + + /* Make sure alias is using proper bitness. */ + { + const size_t size_t_max = std::numeric_limits<size_t>::max(); + size_t value = 0; + atomic_store_z(&value, size_t_max); + EXPECT_EQ(value, size_t_max); + } +} + TEST(atomic, atomic_fetch_and_update_max_z) { const size_t size_t_max = std::numeric_limits<size_t>::max(); @@ -890,6 +1060,25 @@ TEST(atomic, atomic_cas_ptr) } } +TEST(atomic, atomic_load_ptr) +{ + { + void *value = INT_AS_PTR(0x7f); + void *dest = atomic_load_ptr(&value); + EXPECT_EQ(dest, INT_AS_PTR(0x7f)); + } +} + +TEST(atomic, atomic_store_ptr) +{ + { + void *value = INT_AS_PTR(0x7f); + void *dest = nullptr; + atomic_store_ptr(&dest, value); + EXPECT_EQ(dest, INT_AS_PTR(0x7f)); + } +} + #undef INT_AS_PTR /** \} */ |