Remove two duplicate unittests from std.bitmanip;

This commit is contained in:
Bernhard Seckinger 2019-10-08 17:38:21 +02:00
parent e318305e82
commit c268be460f

View file

@ -277,6 +277,7 @@ of the bitfields storage.
assert(obj.x == 2);
assert(obj.y == 0);
assert(obj.z == 2);
assert(obj.flag == false);
}
/**
@ -294,6 +295,12 @@ one bitfield with an empty name.
uint, "", 6));
}
A a;
assert(a.flag1 == 0);
a.flag1 = 1;
assert(a.flag1 == 1);
a.flag1 = 0;
assert(a.flag1 == 0);
}
/// enums can be used too
@ -309,51 +316,6 @@ one bitfield with an empty name.
}
}
/**
Creates a bitfield pack of eight bits, which fit in
one `ubyte`. The bitfields are allocated starting from the
least significant bit, i.e. x occupies the two least significant bits
of the bitfields storage.
*/
@safe unittest
{
struct A
{
int a;
mixin(bitfields!(
uint, "x", 2,
int, "y", 3,
uint, "z", 2,
bool, "flag", 1));
}
A obj;
obj.x = 2;
obj.z = obj.x;
assert(obj.x == 2);
assert(obj.y == 0);
assert(obj.z == 2);
assert(obj.flag == false);
}
/// Add empty fields for padding to have a total bit length of 8, 16, 32, or 64
@safe unittest
{
struct A
{
mixin(bitfields!(
bool, "flag1", 1,
bool, "flag2", 1,
uint, "", 6));
}
A a;
assert(a.flag1 == 0);
a.flag1 = 1;
assert(a.flag1 == 1);
a.flag1 = 0;
assert(a.flag1 == 0);
}
/**
This string mixin generator allows one to create tagged pointers inside $(D_PARAM struct)s and $(D_PARAM class)es.