Skip to content

Commit

Permalink
Add testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
shoo committed Oct 21, 2023
1 parent 9338877 commit 91a46e2
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions voile/sync.d
Original file line number Diff line number Diff line change
Expand Up @@ -1787,8 +1787,38 @@ ManagedShared!T managedShared(T, Args...)(Args args)
{
s.asUnshared.__ctor(args);
}
else static if (is(T == struct) && is(typeof(T(args))))
{
s.asUnshared = T(args);
}
return s;
}
@system unittest
{
static struct TestData
{
string test;
}
static struct TestData2
{
string test;
this(bool x)
{
test = x ? "test true" : "test false";
}
}
auto s1 = managedShared(TestData("test"));
s1.unlock();
assert(s1.locked.test == "test");

auto s2 = managedShared!TestData("test1");
s2.unlock();
assert(s2.locked.test == "test1");

auto s3 = managedShared!TestData2(true);
s3.unlock();
assert(s3.locked.test == "test true");
}

@system unittest
{
Expand Down

0 comments on commit 91a46e2

Please sign in to comment.