Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 9 additions & 23 deletions dash/include/dash/GlobRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class GlobRef
explicit constexpr GlobRef(dart_gptr_t dart_gptr)
: _gptr(dart_gptr)
{ }

/**
* Constructor to convert \c GlobAsyncRef to GlobRef. Set to explicit to
* avoid unintendet conversion
Expand All @@ -131,7 +131,7 @@ class GlobRef
* of \c operator=(const self_t &).
*/
GlobRef(const self_t & other) = delete;

/**
* Unlike native reference types, global reference types are moveable.
*/
Expand Down Expand Up @@ -177,18 +177,6 @@ class GlobRef
return t;
}

template <class GlobRefT>
constexpr bool operator==(const GlobRefT & other) const noexcept
{
return _gptr == other._gptr;
}

template <class GlobRefT>
constexpr bool operator!=(const GlobRefT & other) const noexcept
{
return !(*this == other);
}

constexpr bool operator==(const_value_type & value) const
{
return static_cast<T>(*this) == value;
Expand Down Expand Up @@ -297,30 +285,28 @@ class GlobRef

self_t & operator++() {
nonconst_value_type val = operator nonconst_value_type();
++val;
operator=(val);
operator=(++val);
return *this;
}

nonconst_value_type operator++(int) {
nonconst_value_type val = operator nonconst_value_type();
nonconst_value_type result = val++;
nonconst_value_type res = val++;
operator=(val);
return result;
return res;
}

self_t & operator--() {
nonconst_value_type val = operator nonconst_value_type();
--val;
operator=(val);
operator=(--val);
return *this;
}

nonconst_value_type operator--(int) {
nonconst_value_type val = operator nonconst_value_type();
nonconst_value_type result = val--;
nonconst_value_type res = val--;
operator=(val);
return result;
return res;
}

self_t & operator*=(const_value_type& ref) {
Expand Down Expand Up @@ -396,7 +382,7 @@ class GlobRef
}

/**
* specialization which swappes the values of two global references
* specialization which swappes the values of two global references
*/
inline void swap(dash::GlobRef<T> & b){
T tmp = static_cast<T>(*this);
Expand Down
17 changes: 17 additions & 0 deletions dash/test/container/ArrayTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <dash/Array.h>

#include <dash/algorithm/ForEach.h>
#include <dash/algorithm/Fill.h>

#include <dash/pattern/BlockPattern1D.h>
#include <dash/pattern/TilePattern1D.h>
Expand Down Expand Up @@ -271,3 +272,19 @@ TEST_F(ArrayTest, MoveSemantics){
ASSERT_EQ_U(*(array_b.lbegin()), 1);
}
}


TEST_F(ArrayTest, ElementCompare){
using value_t = int;
using array_t = dash::Array<value_t>;

if(dash::size() < 2){
SKIP_TEST();
}

array_t arr(dash::size());

dash::fill(arr.begin(), arr.end(), 0);

ASSERT_EQ_U(arr[0], arr[1]);
}
34 changes: 15 additions & 19 deletions dash/test/types/GlobRefTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,34 @@ TEST_F(GlobRefTest, ArithmeticOps)
ASSERT_EQ_U(gref, 0);

// prefix increment
++gref;
ASSERT_EQ_U(++gref, 1);
ASSERT_EQ_U(gref, 1);

++(++gref);
ASSERT_EQ_U(++(++gref), 3);
ASSERT_EQ_U(gref, 3);

// prefix decrement
--(--gref);
ASSERT_EQ_U(gref, 1);
// postfix increment
ASSERT_EQ_U(gref++, 3);
ASSERT_EQ_U(gref, 4);

// unary operations
gref *= 2;
ASSERT_EQ_U(gref, 2);
// postfix decrement
ASSERT_EQ_U(gref--, 4);
ASSERT_EQ_U(gref, 3);

gref /= 2;
// prefix decrement
ASSERT_EQ_U(--(--gref), 1);
ASSERT_EQ_U(gref, 1);

gref += 1;
// unary operations
ASSERT_EQ_U(gref *= 2, 2);
ASSERT_EQ_U(gref, 2);

gref -= 1;
ASSERT_EQ_U(gref /= 2, 1);
ASSERT_EQ_U(gref, 1);

// postfix increment
value_t prev = gref++;
ASSERT_EQ_U(prev, 1);
ASSERT_EQ_U(gref += 1, 2);
ASSERT_EQ_U(gref, 2);


// postfix increment
prev = gref--;
ASSERT_EQ_U(prev, 2);
ASSERT_EQ_U(gref -= 1, 1);
ASSERT_EQ_U(gref, 1);

}