Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Added unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamsaka committed Jan 6, 2015
1 parent e030035 commit d1bd72b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/core/atomic.d
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,25 @@ version( unittest )
testType!(long)();
testType!(ulong)();
}

static if (has128BitCAS)
{
struct DoubleValue
{
long value1;
long value2;
}

shared DoubleValue a;
atomicStore(a, DoubleValue(1,2));
assert(a.value1 == 1 && a.value2 ==2);

while(!cas(&a, DoubleValue(1,2), DoubleValue(3,4))){}
assert(a.value1 == 3 && a.value2 ==4);

DoubleValue b = atomicLoad(a);
assert(b.value1 == 3 && b.value2 ==4);
}

shared(size_t) i;

Expand Down

0 comments on commit d1bd72b

Please sign in to comment.