Skip to content

Commit

Permalink
std.bitmanip: Remove outdated debug info + redundant static
Browse files Browse the repository at this point in the history
  • Loading branch information
wilzbach committed Mar 25, 2018
1 parent 2d8c358 commit 837ce55
Showing 1 changed file with 41 additions and 95 deletions.
136 changes: 41 additions & 95 deletions std/bitmanip.d
Expand Up @@ -52,18 +52,10 @@ Distributed under the Boost Software License, Version 1.0.
*/
module std.bitmanip;

//debug = bitarray; // uncomment to turn on debugging printf's

import std.range.primitives;
public import std.system : Endian;
import std.traits;

version(unittest)
{
import std.stdio;
}


private string myToString(ulong n)
{
import core.internal.string : UnsignedStringBuf, unsignedToTempString;
Expand Down Expand Up @@ -856,8 +848,6 @@ public:

@system unittest
{
debug(bitarray) printf("BitArray.opIndex.unittest\n");

void Fun(const BitArray arr)
{
auto x = arr[0];
Expand Down Expand Up @@ -1090,16 +1080,12 @@ public:
BitArray b;
int i;

debug(bitarray) printf("BitArray.dup.unittest\n");

a.length = 3;
a[0] = 1; a[1] = 0; a[2] = 1;
b = a.dup;
assert(b.length == 3);
for (i = 0; i < 3; i++)
{ debug(bitarray) printf("b[%d] = %d\n", i, b[i]);
foreach (i; 0 .. 3)
assert(b[i] == (((i ^ 1) & 1) ? true : false));
}
}

/**********************************************
Expand Down Expand Up @@ -1168,9 +1154,7 @@ public:

@system unittest
{
debug(bitarray) printf("BitArray.opApply unittest\n");

static bool[] ba = [1,0,1];
bool[] ba = [1,0,1];

auto a = BitArray(ba);

Expand Down Expand Up @@ -1229,10 +1213,8 @@ public:

@system unittest
{
debug(bitarray) printf("BitArray.reverse.unittest\n");

BitArray b;
static bool[5] data = [1,0,1,1,0];
bool[5] data = [1,0,1,1,0];
int i;

b = BitArray(data);
Expand Down Expand Up @@ -1293,8 +1275,6 @@ public:

@system unittest
{
debug(bitarray) printf("BitArray.sort.unittest\n");

__gshared size_t x = 0b1100011000;
__gshared ba = BitArray(10, &x);
ba.sort;
Expand Down Expand Up @@ -1327,15 +1307,13 @@ public:

@system unittest
{
debug(bitarray) printf("BitArray.opEquals unittest\n");

static bool[] ba = [1,0,1,0,1];
static bool[] bb = [1,0,1];
static bool[] bc = [1,0,1,0,1,0,1];
static bool[] bd = [1,0,1,1,1];
static bool[] be = [1,0,1,0,1];
static bool[] bf = [1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
static bool[] bg = [1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1];
bool[] ba = [1,0,1,0,1];
bool[] bb = [1,0,1];
bool[] bc = [1,0,1,0,1,0,1];
bool[] bd = [1,0,1,1,1];
bool[] be = [1,0,1,0,1];
bool[] bf = [1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
bool[] bg = [1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1];

auto a = BitArray(ba);
auto b = BitArray(bb);
Expand Down Expand Up @@ -1393,15 +1371,13 @@ public:

@system unittest
{
debug(bitarray) printf("BitArray.opCmp unittest\n");

static bool[] ba = [1,0,1,0,1];
static bool[] bb = [1,0,1];
static bool[] bc = [1,0,1,0,1,0,1];
static bool[] bd = [1,0,1,1,1];
static bool[] be = [1,0,1,0,1];
static bool[] bf = [1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1];
static bool[] bg = [1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0];
bool[] ba = [1,0,1,0,1];
bool[] bb = [1,0,1];
bool[] bc = [1,0,1,0,1,0,1];
bool[] bd = [1,0,1,1,1];
bool[] be = [1,0,1,0,1];
bool[] bf = [1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1];
bool[] bg = [1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0];

auto a = BitArray(ba);
auto b = BitArray(bb);
Expand Down Expand Up @@ -1519,9 +1495,7 @@ public:

@system unittest
{
debug(bitarray) printf("BitArray.init unittest\n");

static bool[] ba = [1,0,1,0,1];
bool[] ba = [1,0,1,0,1];

auto a = BitArray(ba);
void[] v;
Expand Down Expand Up @@ -1559,9 +1533,7 @@ public:

@system unittest
{
debug(bitarray) printf("BitArray.opCast unittest\n");

static bool[] ba = [1,0,1,0,1];
bool[] ba = [1,0,1,0,1];

auto a = BitArray(ba);
void[] v = cast(void[]) a;
Expand Down Expand Up @@ -1591,9 +1563,7 @@ public:

@system unittest
{
debug(bitarray) printf("BitArray.opCom unittest\n");

static bool[] ba = [1,0,1,0,1];
bool[] ba = [1,0,1,0,1];

auto a = BitArray(ba);
BitArray b = ~a;
Expand Down Expand Up @@ -1637,8 +1607,6 @@ public:

@system unittest
{
debug(bitarray) printf("BitArray.opAnd unittest\n");

static bool[] ba = [1,0,1,0,1];
static bool[] bb = [1,0,1,1,0];

Expand All @@ -1656,10 +1624,8 @@ public:

@system unittest
{
debug(bitarray) printf("BitArray.opOr unittest\n");

static bool[] ba = [1,0,1,0,1];
static bool[] bb = [1,0,1,1,0];
bool[] ba = [1,0,1,0,1];
bool[] bb = [1,0,1,1,0];

auto a = BitArray(ba);
auto b = BitArray(bb);
Expand All @@ -1675,10 +1641,8 @@ public:

@system unittest
{
debug(bitarray) printf("BitArray.opXor unittest\n");

static bool[] ba = [1,0,1,0,1];
static bool[] bb = [1,0,1,1,0];
bool[] ba = [1,0,1,0,1];
bool[] bb = [1,0,1,1,0];

auto a = BitArray(ba);
auto b = BitArray(bb);
Expand All @@ -1694,10 +1658,8 @@ public:

@system unittest
{
debug(bitarray) printf("BitArray.opSub unittest\n");

static bool[] ba = [1,0,1,0,1];
static bool[] bb = [1,0,1,1,0];
bool[] ba = [1,0,1,0,1];
bool[] bb = [1,0,1,1,0];

auto a = BitArray(ba);
auto b = BitArray(bb);
Expand Down Expand Up @@ -1746,8 +1708,8 @@ public:

@system unittest
{
static bool[] ba = [1,0,1,0,1,1,0,1,0,1];
static bool[] bb = [1,0,1,1,0];
bool[] ba = [1,0,1,0,1,1,0,1,0,1];
bool[] bb = [1,0,1,1,0];
auto a = BitArray(ba);
auto b = BitArray(bb);
BitArray c = a;
Expand All @@ -1762,10 +1724,8 @@ public:

@system unittest
{
debug(bitarray) printf("BitArray.opAndAssign unittest\n");

static bool[] ba = [1,0,1,0,1];
static bool[] bb = [1,0,1,1,0];
bool[] ba = [1,0,1,0,1];
bool[] bb = [1,0,1,1,0];

auto a = BitArray(ba);
auto b = BitArray(bb);
Expand All @@ -1780,10 +1740,8 @@ public:

@system unittest
{
debug(bitarray) printf("BitArray.opOrAssign unittest\n");

static bool[] ba = [1,0,1,0,1];
static bool[] bb = [1,0,1,1,0];
bool[] ba = [1,0,1,0,1];
bool[] bb = [1,0,1,1,0];

auto a = BitArray(ba);
auto b = BitArray(bb);
Expand All @@ -1798,10 +1756,8 @@ public:

@system unittest
{
debug(bitarray) printf("BitArray.opXorAssign unittest\n");

static bool[] ba = [1,0,1,0,1];
static bool[] bb = [1,0,1,1,0];
bool[] ba = [1,0,1,0,1];
bool[] bb = [1,0,1,1,0];

auto a = BitArray(ba);
auto b = BitArray(bb);
Expand All @@ -1816,10 +1772,8 @@ public:

@system unittest
{
debug(bitarray) printf("BitArray.opSubAssign unittest\n");

static bool[] ba = [1,0,1,0,1];
static bool[] bb = [1,0,1,1,0];
bool[] ba = [1,0,1,0,1];
bool[] bb = [1,0,1,1,0];

auto a = BitArray(ba);
auto b = BitArray(bb);
Expand Down Expand Up @@ -1849,9 +1803,7 @@ public:

@system unittest
{
debug(bitarray) printf("BitArray.opCatAssign unittest\n");

static bool[] ba = [1,0,1,0,1];
bool[] ba = [1,0,1,0,1];

auto a = BitArray(ba);
BitArray b;
Expand Down Expand Up @@ -1882,10 +1834,8 @@ public:

@system unittest
{
debug(bitarray) printf("BitArray.opCatAssign unittest\n");

static bool[] ba = [1,0];
static bool[] bb = [0,1,0];
bool[] ba = [1,0];
bool[] bb = [0,1,0];

auto a = BitArray(ba);
auto b = BitArray(bb);
Expand Down Expand Up @@ -1939,10 +1889,8 @@ public:

@system unittest
{
debug(bitarray) printf("BitArray.opCat unittest\n");

static bool[] ba = [1,0];
static bool[] bb = [0,1,0];
bool[] ba = [1,0];
bool[] bb = [0,1,0];

auto a = BitArray(ba);
auto b = BitArray(bb);
Expand Down Expand Up @@ -2249,7 +2197,6 @@ public:
{
import std.format : format;

debug(bitarray) printf("BitArray.toString unittest\n");
auto b = BitArray([0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]);

auto s1 = format("%s", b);
Expand Down Expand Up @@ -2294,7 +2241,6 @@ public:
import std.algorithm.comparison : equal;
import std.range : iota;

debug(bitarray) printf("BitArray.bitsSet unittest\n");
BitArray b;
enum wordBits = size_t.sizeof * 8;
b = BitArray([size_t.max], 0);
Expand Down

0 comments on commit 837ce55

Please sign in to comment.