Beispiel #1
0
                public void SwapsExpectedBits()
                {
                    var array = new BooleanArray.Builder()
                                .Resize(8)
                                .Set(0, true)
                                .Swap(0, 7)
                                .Build();

                    Assert.False(array.GetBoolean(0));
                    Assert.True(array.GetBoolean(7));
                }
Beispiel #2
0
                public void SwapsExpectedBits()
                {
                    var array = new BooleanArray.Builder()
                                .Resize(8)
                                .Set(0, true)
                                .Swap(0, 7)
                                .Build();

                    Assert.False(array.GetValue(0).Value);
                    Assert.True(array.GetValue(7).Value);
                    #pragma warning disable CS0618
                    Assert.False(array.GetBoolean(0));
                    Assert.True(array.GetBoolean(7));
                    #pragma warning restore CS0618
                }
Beispiel #3
0
                public void SwapsExpectedBits()
                {
                    var array = new BooleanArray.Builder()
                                .AppendRange(Enumerable.Repeat(false, 8))
                                .Set(0, true)
                                .Swap(0, 7)
                                .Build();

                    Assert.True(array.GetValue(0).HasValue);
                    Assert.False(array.GetValue(0).Value);
                    Assert.True(array.GetValue(7).HasValue);
                    Assert.True(array.GetValue(7).Value);
                    #pragma warning disable CS0618
                    Assert.False(array.GetBoolean(0));
                    Assert.True(array.GetBoolean(7));
                    #pragma warning restore CS0618
                }
Beispiel #4
0
                public void SetsExpectedBitsToFalse(int length, int index)
                {
                    var array = new BooleanArray.Builder()
                                .Resize(length)
                                .Set(index, false)
                                .Build();

                    Assert.False(array.GetBoolean(index));
                }
Beispiel #5
0
                public void TogglesExpectedBitToTreu(int length, int index)
                {
                    var array = new BooleanArray.Builder()
                                .Resize(length)
                                .Set(index, false)
                                .Toggle(index)
                                .Build();

                    Assert.True(array.GetBoolean(index));
                }
Beispiel #6
0
                public void SetsAllBitsToDefault()
                {
                    var array = new BooleanArray.Builder()
                                .Resize(8)
                                .Set(0, true)
                                .Set(7, true)
                                .Clear()
                                .Build();

                    for (var i = 0; i < array.Length; i++)
                    {
                        Assert.False(array.GetBoolean(i));
                    }
                }
Beispiel #7
0
                public void AppendsExpectedBit()
                {
                    var array1 = new BooleanArray.Builder()
                                 .Append(false)
                                 .Build();

                    Assert.False(array1.GetBoolean(0));

                    var array2 = new BooleanArray.Builder()
                                 .Append(true)
                                 .Build();

                    Assert.True(array2.GetBoolean(0));
                }
Beispiel #8
0
                public void UnsetBitsAreUnchanged(int index)
                {
                    var array = new BooleanArray.Builder()
                                .Resize(8)
                                .Set(index, true)
                                .Build();

                    for (var i = 0; i < 8; i++)
                    {
                        if (i != index)
                        {
                            Assert.False(array.GetBoolean(i));
                        }
                    }
                }
Beispiel #9
0
                public void UnsetBitsAreUnchanged(int index)
                {
                    var array = new BooleanArray.Builder()
                                .Resize(8)
                                .Set(index, true)
                                .Build();

                    for (var i = 0; i < 8; i++)
                    {
                        if (i != index)
                        {
                            Assert.False(array.GetValue(i).Value);
                            #pragma warning disable CS0618
                            Assert.False(array.GetBoolean(i));
                            #pragma warning restore CS0618
                        }
                    }
                }
Beispiel #10
0
                public void UnsetBitsAreUnchanged(int index)
                {
                    var array = new BooleanArray.Builder()
                                .AppendRange(Enumerable.Repeat(false, 8))
                                .Set(index, true)
                                .Build();

                    for (var i = 0; i < 8; i++)
                    {
                        if (i != index)
                        {
                            Assert.True(array.GetValue(i).HasValue);
                            Assert.False(array.GetValue(i).Value);
                            #pragma warning disable CS0618
                            Assert.False(array.GetBoolean(i));
                            #pragma warning restore CS0618
                        }
                    }
                }