Skip to content

Commit

Permalink
Bring back bad_alloc test
Browse files Browse the repository at this point in the history
  • Loading branch information
Wentzell authored and Thoemi09 committed Jul 18, 2024
1 parent d0cab2a commit e35a2ea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 3 additions & 5 deletions test/c++/nda_asan_poison.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@

#if defined(__has_feature)
#if __has_feature(address_sanitizer)

#include <nda/nda.hpp>
#include <sanitizer/asan_interface.h>
#endif
#endif

TEST(NDA, ASANPoison) {
#if defined(__has_feature)
#if __has_feature(address_sanitizer)
long *p;
{
nda::array<long, 2> A(3, 3);
Expand All @@ -34,6 +31,7 @@ TEST(NDA, ASANPoison) {
}

EXPECT_EQ(__asan_address_is_poisoned(p), 1);
}

#endif
#endif
}
8 changes: 8 additions & 0 deletions test/c++/nda_basic_array_and_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -834,3 +834,11 @@ TEST_F(NDAArrayAndView, StrideOrderOfArrays) {
EXPECT_TRUE(v_c.indexmap().is_stride_order_C());
EXPECT_TRUE(v_f.indexmap().is_stride_order_C());
}

#if defined(__has_feature)
#if !__has_feature(address_sanitizer)
TEST_F(NDAArrayAndView, BadAlloc) {
EXPECT_THROW(nda::vector<int>(long(1e16)), std::bad_alloc);
}
#endif
#endif

0 comments on commit e35a2ea

Please sign in to comment.