Skip to content

Commit

Permalink
Added DuckPointer Template Mixin unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
ColdenCullen committed Aug 3, 2014
1 parent b680929 commit cd79239
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions source/quack/pointer.d
Expand Up @@ -118,6 +118,37 @@ unittest
assert( ptr1.getX() == 42 );
}
///
@name( "DuckPointer Template Mixin" )
unittest
{
struct MyMixinImpl
{
mixin MyMixin!();
}
alias MixinPtr = DuckPointer!MyMixinImpl;

struct Struct1
{
mixin MyMixin!();
}

Struct1 s1;
s1.x = 42;
MixinPtr ptr1 = MixinPtr( &s1 );
assert( ptr1.x == 42 );
assert( ptr1.getX() == 42 );
++ptr1.x;
assert( ptr1.x == 43 );
assert( ptr1.getX() == 43 );
assert( s1.x == 43 );
}
version( unittest )
private mixin template MyMixin()
{
int x;
int getX() { return x; }
}
///
@name( "DuckPointer String Mixin" )
unittest
{
Expand Down

0 comments on commit cd79239

Please sign in to comment.