GetSlot() публичный Метод

public GetSlot ( int slot, bool def ) : bool
slot int
def bool
Результат bool
Пример #1
0
        private void CheckObjects(int fieldCount, int objectCount)
        {
            _lcg.Reset();

            const int testValuesMax = 11;

            var builder = new FlatBufferBuilder(1);

            var objects = new int[objectCount];

            for (var i = 0; i < objectCount; ++i)
            {
                builder.StartObject(fieldCount);

                for (var j = 0; j < fieldCount; ++j)
                {
                    var fieldType = _lcg.Next() % testValuesMax;

                    switch (fieldType)
                    {
                    case 0:
                    {
                        builder.AddBool(j, FuzzTestData.BoolValue, false);
                        break;
                    }

                    case 1:
                    {
                        builder.AddSbyte(j, FuzzTestData.Int8Value, 0);
                        break;
                    }

                    case 2:
                    {
                        builder.AddByte(j, FuzzTestData.UInt8Value, 0);
                        break;
                    }

                    case 3:
                    {
                        builder.AddShort(j, FuzzTestData.Int16Value, 0);
                        break;
                    }

                    case 4:
                    {
                        builder.AddUshort(j, FuzzTestData.UInt16Value, 0);
                        break;
                    }

                    case 5:
                    {
                        builder.AddInt(j, FuzzTestData.Int32Value, 0);
                        break;
                    }

                    case 6:
                    {
                        builder.AddUint(j, FuzzTestData.UInt32Value, 0);
                        break;
                    }

                    case 7:
                    {
                        builder.AddLong(j, FuzzTestData.Int64Value, 0);
                        break;
                    }

                    case 8:
                    {
                        builder.AddUlong(j, FuzzTestData.UInt64Value, 0);
                        break;
                    }

                    case 9:
                    {
                        builder.AddFloat(j, FuzzTestData.Float32Value, 0);
                        break;
                    }

                    case 10:
                    {
                        builder.AddDouble(j, FuzzTestData.Float64Value, 0);
                        break;
                    }

                    default:
                        throw new Exception("Unreachable");
                    }
                }

                var offset = builder.EndObject();

                // Store the object offset
                objects[i] = offset;
            }

            _lcg.Reset();

            // Test all objects are readable and return expected values...
            for (var i = 0; i < objectCount; ++i)
            {
                var table = new TestTable(builder.DataBuffer, builder.DataBuffer.Length - objects[i]);

                for (var j = 0; j < fieldCount; ++j)
                {
                    var fieldType = _lcg.Next() % testValuesMax;
                    var fc        = 2 + j; // 2 == VtableMetadataFields
                    var f         = fc * 2;

                    switch (fieldType)
                    {
                    case 0:
                    {
                        Assert.AreEqual(FuzzTestData.BoolValue, table.GetSlot(f, false));
                        break;
                    }

                    case 1:
                    {
                        Assert.AreEqual(FuzzTestData.Int8Value, table.GetSlot(f, (sbyte)0));
                        break;
                    }

                    case 2:
                    {
                        Assert.AreEqual(FuzzTestData.UInt8Value, table.GetSlot(f, (byte)0));
                        break;
                    }

                    case 3:
                    {
                        Assert.AreEqual(FuzzTestData.Int16Value, table.GetSlot(f, (short)0));
                        break;
                    }

                    case 4:
                    {
                        Assert.AreEqual(FuzzTestData.UInt16Value, table.GetSlot(f, (ushort)0));
                        break;
                    }

                    case 5:
                    {
                        Assert.AreEqual(FuzzTestData.Int32Value, table.GetSlot(f, (int)0));
                        break;
                    }

                    case 6:
                    {
                        Assert.AreEqual(FuzzTestData.UInt32Value, table.GetSlot(f, (uint)0));
                        break;
                    }

                    case 7:
                    {
                        Assert.AreEqual(FuzzTestData.Int64Value, table.GetSlot(f, (long)0));
                        break;
                    }

                    case 8:
                    {
                        Assert.AreEqual(FuzzTestData.UInt64Value, table.GetSlot(f, (ulong)0));
                        break;
                    }

                    case 9:
                    {
                        Assert.AreEqual(FuzzTestData.Float32Value, table.GetSlot(f, (float)0));
                        break;
                    }

                    case 10:
                    {
                        Assert.AreEqual(FuzzTestData.Float64Value, table.GetSlot(f, (double)0));
                        break;
                    }

                    default:
                        throw new Exception("Unreachable");
                    }
                }
            }
        }
Пример #2
0
        private void CheckObjects(int fieldCount, int objectCount)
        {
            _lcg.Reset();

            const int testValuesMax = 11;

            var builder = new FlatBufferBuilder(1);

            var objects = new int[objectCount];

            for (var i = 0; i < objectCount; ++i)
            {
                builder.StartObject(fieldCount);

                for (var j = 0; j < fieldCount; ++j)
                {
                    var fieldType = _lcg.Next()%testValuesMax;

                    switch (fieldType)
                    {
                        case 0:
                        {
                            builder.AddBool(j, FuzzTestData.BoolValue, false);
                            break;
                        }
                        case 1:
                        {
                            builder.AddSbyte(j, FuzzTestData.Int8Value, 0);
                            break;
                        }
                        case 2:
                        {
                            builder.AddByte(j, FuzzTestData.UInt8Value, 0);
                            break;
                        }
                        case 3:
                        {
                            builder.AddShort(j, FuzzTestData.Int16Value, 0);
                            break;
                        }
                        case 4:
                        {
                            builder.AddUshort(j, FuzzTestData.UInt16Value, 0);
                            break;
                        }
                        case 5:
                        {
                            builder.AddInt(j, FuzzTestData.Int32Value, 0);
                            break;
                        }
                        case 6:
                        {
                            builder.AddUint(j, FuzzTestData.UInt32Value, 0);
                            break;
                        }
                        case 7:
                        {
                            builder.AddLong(j, FuzzTestData.Int64Value, 0);
                            break;
                        }
                        case 8:
                        {
                            builder.AddUlong(j, FuzzTestData.UInt64Value, 0);
                            break;
                        }
                        case 9:
                        {
                            builder.AddFloat(j, FuzzTestData.Float32Value, 0);
                            break;
                        }
                        case 10:
                        {
                            builder.AddDouble(j, FuzzTestData.Float64Value, 0);
                            break;
                        }
                        default:
                            throw new Exception("Unreachable");
                    }

                }

                var offset = builder.EndObject();

                // Store the object offset
                objects[i] = offset;
            }

            _lcg.Reset();

            // Test all objects are readable and return expected values...
            for (var i = 0; i < objectCount; ++i)
            {
                var table = new TestTable(builder.DataBuffer, builder.DataBuffer.Length - objects[i]);

                for (var j = 0; j < fieldCount; ++j)
                {
                    var fieldType = _lcg.Next() % testValuesMax;
                    var fc = 2 + j; // 2 == VtableMetadataFields
                    var f = fc * 2;

                    switch (fieldType)
                    {
                        case 0:
                        {
                            Assert.AreEqual(FuzzTestData.BoolValue, table.GetSlot(f, false));
                            break;
                        }
                        case 1:
                        {
                            Assert.AreEqual(FuzzTestData.Int8Value, table.GetSlot(f, (sbyte)0));
                            break;
                        }
                        case 2:
                        {
                            Assert.AreEqual(FuzzTestData.UInt8Value, table.GetSlot(f, (byte)0));
                            break;
                        }
                        case 3:
                        {
                            Assert.AreEqual(FuzzTestData.Int16Value, table.GetSlot(f, (short)0));
                            break;
                        }
                        case 4:
                        {
                            Assert.AreEqual(FuzzTestData.UInt16Value, table.GetSlot(f, (ushort)0));
                            break;
                        }
                        case 5:
                        {
                            Assert.AreEqual(FuzzTestData.Int32Value, table.GetSlot(f, (int)0));
                            break;
                        }
                        case 6:
                        {
                            Assert.AreEqual(FuzzTestData.UInt32Value, table.GetSlot(f, (uint)0));
                            break;
                        }
                        case 7:
                        {
                            Assert.AreEqual(FuzzTestData.Int64Value, table.GetSlot(f, (long)0));
                            break;
                        }
                        case 8:
                        {
                            Assert.AreEqual(FuzzTestData.UInt64Value, table.GetSlot(f, (ulong)0));
                            break;
                        }
                        case 9:
                        {
                            Assert.AreEqual(FuzzTestData.Float32Value, table.GetSlot(f, (float)0));
                            break;
                        }
                        case 10:
                        {
                            Assert.AreEqual(FuzzTestData.Float64Value, table.GetSlot(f, (double)0));
                            break;
                        }
                        default:
                            throw new Exception("Unreachable");
                    }

                }

            }
        }