Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
flatbuffers
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
flatbuffers
Commits
d890ef9e
Commit
d890ef9e
authored
Oct 19, 2015
by
Wouter van Oortmerssen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #298 from evolutional/master
Ported some of the python fuzz tests to C#
parents
9f69d794
9d66af6e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
327 additions
and
38 deletions
+327
-38
Assert.cs
tests/FlatBuffers.Test/Assert.cs
+35
-0
ByteBufferTests.cs
tests/FlatBuffers.Test/ByteBufferTests.cs
+40
-9
FlatBuffers.Test.csproj
tests/FlatBuffers.Test/FlatBuffers.Test.csproj
+9
-3
FlatBuffersExampleTests.cs
tests/FlatBuffers.Test/FlatBuffersExampleTests.cs
+4
-0
FlatBuffersFuzzTests.cs
tests/FlatBuffers.Test/FlatBuffersFuzzTests.cs
+0
-0
FlatBuffersTestClassAttribute.cs
tests/FlatBuffers.Test/FlatBuffersTestClassAttribute.cs
+12
-0
FlatBuffersTestMethodAttribute.cs
tests/FlatBuffers.Test/FlatBuffersTestMethodAttribute.cs
+10
-0
FuzzTestData.cs
tests/FlatBuffers.Test/FuzzTestData.cs
+23
-0
Lcg.cs
tests/FlatBuffers.Test/Lcg.cs
+27
-0
Program.cs
tests/FlatBuffers.Test/Program.cs
+31
-26
TestTable.cs
tests/FlatBuffers.Test/TestTable.cs
+136
-0
No files found.
tests/FlatBuffers.Test/Assert.cs
View file @
d890ef9e
...
...
@@ -39,6 +39,25 @@ namespace FlatBuffers.Test
}
}
public
class
AssertArrayFailedException
:
Exception
{
private
readonly
int
_index
;
private
readonly
object
_expected
;
private
readonly
object
_actual
;
public
AssertArrayFailedException
(
int
index
,
object
expected
,
object
actual
)
{
_index
=
index
;
_expected
=
expected
;
_actual
=
actual
;
}
public
override
string
Message
{
get
{
return
string
.
Format
(
"Expected {0} at index {1} but saw {2}"
,
_expected
,
_index
,
_actual
);
}
}
}
public
class
AssertUnexpectedThrowException
:
Exception
{
private
readonly
object
_expected
;
...
...
@@ -64,6 +83,22 @@ namespace FlatBuffers.Test
}
}
public
static
void
ArrayEqual
<
T
>(
T
[]
expected
,
T
[]
actual
)
{
if
(
expected
.
Length
!=
actual
.
Length
)
{
throw
new
AssertFailedException
(
expected
,
actual
);
}
for
(
var
i
=
0
;
i
<
expected
.
Length
;
++
i
)
{
if
(!
expected
[
i
].
Equals
(
actual
[
i
]))
{
throw
new
AssertArrayFailedException
(
i
,
expected
,
actual
);
}
}
}
public
static
void
IsTrue
(
bool
value
)
{
if
(!
value
)
...
...
tests/FlatBuffers.Test/ByteBufferTests.cs
View file @
d890ef9e
...
...
@@ -18,9 +18,11 @@ using System;
namespace
FlatBuffers.Test
{
[
FlatBuffersTestClass
]
public
class
ByteBufferTests
{
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_Length_MatchesBufferLength
()
{
var
buffer
=
new
byte
[
1000
];
...
...
@@ -28,6 +30,7 @@ namespace FlatBuffers.Test
Assert
.
AreEqual
(
buffer
.
Length
,
uut
.
Length
);
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_PutBytePopulatesBufferAtZeroOffset
()
{
var
buffer
=
new
byte
[
1
];
...
...
@@ -37,6 +40,7 @@ namespace FlatBuffers.Test
Assert
.
AreEqual
((
byte
)
99
,
buffer
[
0
]);
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_PutByteCannotPutAtOffsetPastLength
()
{
var
buffer
=
new
byte
[
1
];
...
...
@@ -44,6 +48,7 @@ namespace FlatBuffers.Test
Assert
.
Throws
<
ArgumentOutOfRangeException
>(()
=>
uut
.
PutByte
(
1
,
99
));
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_PutShortPopulatesBufferCorrectly
()
{
var
buffer
=
new
byte
[
2
];
...
...
@@ -55,6 +60,7 @@ namespace FlatBuffers.Test
Assert
.
AreEqual
((
byte
)
0
,
buffer
[
1
]);
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_PutShortCannotPutAtOffsetPastLength
()
{
var
buffer
=
new
byte
[
2
];
...
...
@@ -62,6 +68,7 @@ namespace FlatBuffers.Test
Assert
.
Throws
<
ArgumentOutOfRangeException
>(()
=>
uut
.
PutShort
(
2
,
99
));
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_PutShortChecksLength
()
{
var
buffer
=
new
byte
[
1
];
...
...
@@ -69,6 +76,7 @@ namespace FlatBuffers.Test
Assert
.
Throws
<
ArgumentOutOfRangeException
>(()
=>
uut
.
PutShort
(
0
,
99
));
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_PutShortChecksLengthAndOffset
()
{
var
buffer
=
new
byte
[
2
];
...
...
@@ -76,6 +84,7 @@ namespace FlatBuffers.Test
Assert
.
Throws
<
ArgumentOutOfRangeException
>(()
=>
uut
.
PutShort
(
1
,
99
));
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_PutIntPopulatesBufferCorrectly
()
{
var
buffer
=
new
byte
[
4
];
...
...
@@ -89,6 +98,7 @@ namespace FlatBuffers.Test
Assert
.
AreEqual
(
0x0A
,
buffer
[
3
]);
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_PutIntCannotPutAtOffsetPastLength
()
{
var
buffer
=
new
byte
[
4
];
...
...
@@ -96,6 +106,7 @@ namespace FlatBuffers.Test
Assert
.
Throws
<
ArgumentOutOfRangeException
>(()
=>
uut
.
PutInt
(
2
,
0x0A0B0C0D
));
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_PutIntChecksLength
()
{
var
buffer
=
new
byte
[
1
];
...
...
@@ -103,6 +114,7 @@ namespace FlatBuffers.Test
Assert
.
Throws
<
ArgumentOutOfRangeException
>(()
=>
uut
.
PutInt
(
0
,
0x0A0B0C0D
));
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_PutIntChecksLengthAndOffset
()
{
var
buffer
=
new
byte
[
4
];
...
...
@@ -110,6 +122,7 @@ namespace FlatBuffers.Test
Assert
.
Throws
<
ArgumentOutOfRangeException
>(()
=>
uut
.
PutInt
(
2
,
0x0A0B0C0D
));
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_PutLongPopulatesBufferCorrectly
()
{
var
buffer
=
new
byte
[
8
];
...
...
@@ -127,6 +140,7 @@ namespace FlatBuffers.Test
Assert
.
AreEqual
(
0x01
,
buffer
[
7
]);
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_PutLongCannotPutAtOffsetPastLength
()
{
var
buffer
=
new
byte
[
8
];
...
...
@@ -134,6 +148,7 @@ namespace FlatBuffers.Test
Assert
.
Throws
<
ArgumentOutOfRangeException
>(()
=>
uut
.
PutLong
(
2
,
0x010203040A0B0C0D
));
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_PutLongChecksLength
()
{
var
buffer
=
new
byte
[
1
];
...
...
@@ -141,6 +156,7 @@ namespace FlatBuffers.Test
Assert
.
Throws
<
ArgumentOutOfRangeException
>(()
=>
uut
.
PutLong
(
0
,
0x010203040A0B0C0D
));
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_PutLongChecksLengthAndOffset
()
{
var
buffer
=
new
byte
[
8
];
...
...
@@ -148,6 +164,7 @@ namespace FlatBuffers.Test
Assert
.
Throws
<
ArgumentOutOfRangeException
>(()
=>
uut
.
PutLong
(
2
,
0x010203040A0B0C0D
));
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_GetByteReturnsCorrectData
()
{
var
buffer
=
new
byte
[
1
];
...
...
@@ -156,6 +173,7 @@ namespace FlatBuffers.Test
Assert
.
AreEqual
((
byte
)
99
,
uut
.
Get
(
0
));
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_GetByteChecksOffset
()
{
var
buffer
=
new
byte
[
1
];
...
...
@@ -163,6 +181,7 @@ namespace FlatBuffers.Test
Assert
.
Throws
<
ArgumentOutOfRangeException
>(()=>
uut
.
Get
(
1
));
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_GetShortReturnsCorrectData
()
{
var
buffer
=
new
byte
[
2
];
...
...
@@ -172,6 +191,7 @@ namespace FlatBuffers.Test
Assert
.
AreEqual
(
1
,
uut
.
GetShort
(
0
));
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_GetShortChecksOffset
()
{
var
buffer
=
new
byte
[
2
];
...
...
@@ -179,6 +199,7 @@ namespace FlatBuffers.Test
Assert
.
Throws
<
ArgumentOutOfRangeException
>(()
=>
uut
.
GetShort
(
2
));
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_GetShortChecksLength
()
{
var
buffer
=
new
byte
[
2
];
...
...
@@ -186,6 +207,7 @@ namespace FlatBuffers.Test
Assert
.
Throws
<
ArgumentOutOfRangeException
>(()
=>
uut
.
GetShort
(
1
));
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_GetIntReturnsCorrectData
()
{
var
buffer
=
new
byte
[
4
];
...
...
@@ -197,6 +219,7 @@ namespace FlatBuffers.Test
Assert
.
AreEqual
(
0x0A0B0C0D
,
uut
.
GetInt
(
0
));
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_GetIntChecksOffset
()
{
var
buffer
=
new
byte
[
4
];
...
...
@@ -204,6 +227,7 @@ namespace FlatBuffers.Test
Assert
.
Throws
<
ArgumentOutOfRangeException
>(()
=>
uut
.
GetInt
(
4
));
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_GetIntChecksLength
()
{
var
buffer
=
new
byte
[
2
];
...
...
@@ -211,6 +235,7 @@ namespace FlatBuffers.Test
Assert
.
Throws
<
ArgumentOutOfRangeException
>(()
=>
uut
.
GetInt
(
0
));
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_GetLongReturnsCorrectData
()
{
var
buffer
=
new
byte
[
8
];
...
...
@@ -226,6 +251,7 @@ namespace FlatBuffers.Test
Assert
.
AreEqual
(
0x010203040A0B0C0D
,
uut
.
GetLong
(
0
));
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_GetLongChecksOffset
()
{
var
buffer
=
new
byte
[
8
];
...
...
@@ -233,39 +259,44 @@ namespace FlatBuffers.Test
Assert
.
Throws
<
ArgumentOutOfRangeException
>(()
=>
uut
.
GetLong
(
8
));
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_GetLongChecksLength
()
{
var
buffer
=
new
byte
[
7
];
var
uut
=
new
ByteBuffer
(
buffer
);
Assert
.
Throws
<
ArgumentOutOfRangeException
>(()
=>
uut
.
GetLong
(
0
));
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_ReverseBytesUshort
()
{
ushort
original
=
(
ushort
)
0x1234U
;
ushort
reverse
=
ByteBuffer
.
ReverseBytes
(
original
);
const
ushort
original
=
(
ushort
)
0x1234U
;
var
reverse
=
ByteBuffer
.
ReverseBytes
(
original
);
Assert
.
AreEqual
(
0x3412U
,
reverse
);
ushort
rereverse
=
ByteBuffer
.
ReverseBytes
(
reverse
);
var
rereverse
=
ByteBuffer
.
ReverseBytes
(
reverse
);
Assert
.
AreEqual
(
original
,
rereverse
);
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_ReverseBytesUint
()
{
uint
original
=
0x12345678
;
uint
reverse
=
ByteBuffer
.
ReverseBytes
(
original
);
const
uint
original
=
0x12345678
;
var
reverse
=
ByteBuffer
.
ReverseBytes
(
original
);
Assert
.
AreEqual
(
0x78563412U
,
reverse
);
uint
rereverse
=
ByteBuffer
.
ReverseBytes
(
reverse
);
var
rereverse
=
ByteBuffer
.
ReverseBytes
(
reverse
);
Assert
.
AreEqual
(
original
,
rereverse
);
}
[
FlatBuffersTestMethod
]
public
void
ByteBuffer_ReverseBytesUlong
()
{
ulong
original
=
0x1234567890ABCDEFU
L
;
ulong
reverse
=
ByteBuffer
.
ReverseBytes
(
original
);
const
ulong
original
=
0x1234567890ABCDEFU
L
;
var
reverse
=
ByteBuffer
.
ReverseBytes
(
original
);
Assert
.
AreEqual
(
0xEFCDAB9078563412U
L
,
reverse
);
ulong
rereverse
=
ByteBuffer
.
ReverseBytes
(
reverse
);
var
rereverse
=
ByteBuffer
.
ReverseBytes
(
reverse
);
Assert
.
AreEqual
(
original
,
rereverse
);
}
}
...
...
tests/FlatBuffers.Test/FlatBuffers.Test.csproj
View file @
d890ef9e
...
...
@@ -41,9 +41,9 @@
<Compile
Include=
"..\..\net\FlatBuffers\ByteBuffer.cs"
>
<Link>
FlatBuffers\ByteBuffer.cs
</Link>
</Compile>
<Compile
Include=
"..\..\net\FlatBuffers\Offset.cs"
>
<Link>
FlatBuffers\Offset.cs
</Link>
</Compile>
<Compile
Include=
"..\..\net\FlatBuffers\Offset.cs"
>
<Link>
FlatBuffers\Offset.cs
</Link>
</Compile>
<Compile
Include=
"..\..\net\FlatBuffers\FlatBufferBuilder.cs"
>
<Link>
FlatBuffers\FlatBufferBuilder.cs
</Link>
</Compile>
...
...
@@ -79,9 +79,15 @@
</Compile>
<Compile
Include=
"Assert.cs"
/>
<Compile
Include=
"ByteBufferTests.cs"
/>
<Compile
Include=
"FlatBuffersFuzzTests.cs"
/>
<Compile
Include=
"FlatBuffersTestClassAttribute.cs"
/>
<Compile
Include=
"FlatBuffersTestMethodAttribute.cs"
/>
<Compile
Include=
"FuzzTestData.cs"
/>
<Compile
Include=
"Lcg.cs"
/>
<Compile
Include=
"Program.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"FlatBuffersExampleTests.cs"
/>
<Compile
Include=
"TestTable.cs"
/>
</ItemGroup>
<ItemGroup>
<Content
Include=
"..\monsterdata_test.mon"
>
...
...
tests/FlatBuffers.Test/FlatBuffersExampleTests.cs
View file @
d890ef9e
...
...
@@ -19,6 +19,7 @@ using MyGame.Example;
namespace
FlatBuffers.Test
{
[
FlatBuffersTestClass
]
public
class
FlatBuffersExampleTests
{
public
void
RunTests
()
...
...
@@ -28,6 +29,7 @@ namespace FlatBuffers.Test
TestEnums
();
}
[
FlatBuffersTestMethod
]
public
void
CanCreateNewFlatBufferFromScratch
()
{
// Second, let's create a FlatBuffer from scratch in C#, and test it also.
...
...
@@ -184,6 +186,7 @@ namespace FlatBuffers.Test
Assert
.
AreEqual
(
false
,
monster
.
Testbool
);
}
[
FlatBuffersTestMethod
]
public
void
CanReadCppGeneratedWireFile
()
{
var
data
=
File
.
ReadAllBytes
(
@"Resources/monsterdata_test.mon"
);
...
...
@@ -191,6 +194,7 @@ namespace FlatBuffers.Test
TestBuffer
(
bb
);
}
[
FlatBuffersTestMethod
]
public
void
TestEnums
()
{
Assert
.
AreEqual
(
"Red"
,
Color
.
Red
.
ToString
());
...
...
tests/FlatBuffers.Test/FlatBuffersFuzzTests.cs
0 → 100644
View file @
d890ef9e
This diff is collapsed.
Click to expand it.
tests/FlatBuffers.Test/FlatBuffersTestClassAttribute.cs
0 → 100644
View file @
d890ef9e
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
namespace
FlatBuffers.Test
{
[
AttributeUsage
(
AttributeTargets
.
Class
)]
public
class
FlatBuffersTestClassAttribute
:
Attribute
{
}
}
tests/FlatBuffers.Test/FlatBuffersTestMethodAttribute.cs
0 → 100644
View file @
d890ef9e
using
System
;
namespace
FlatBuffers.Test
{
[
AttributeUsage
(
AttributeTargets
.
Method
)]
public
class
FlatBuffersTestMethodAttribute
:
Attribute
{
}
}
\ No newline at end of file
tests/FlatBuffers.Test/FuzzTestData.cs
0 → 100644
View file @
d890ef9e
using
System
;
namespace
FlatBuffers.Test
{
internal
static
class
FuzzTestData
{
private
static
readonly
byte
[]
_overflowInt32
=
new
byte
[]
{
0x83
,
0x33
,
0x33
,
0x33
};
private
static
readonly
byte
[]
_overflowInt64
=
new
byte
[]
{
0x84
,
0x44
,
0x44
,
0x44
,
0x44
,
0x44
,
0x44
,
0x44
};
public
static
readonly
bool
BoolValue
=
true
;
public
static
readonly
sbyte
Int8Value
=
-
127
;
// 0x81
public
static
readonly
byte
UInt8Value
=
255
;
// 0xFF
public
static
readonly
short
Int16Value
=
-
32222
;
// 0x8222;
public
static
readonly
ushort
UInt16Value
=
65262
;
// 0xFEEE
public
static
readonly
int
Int32Value
=
BitConverter
.
ToInt32
(
_overflowInt32
,
0
);
public
static
readonly
uint
UInt32Value
=
0xFDDDDDDD
;
public
static
readonly
long
Int64Value
=
BitConverter
.
ToInt64
(
_overflowInt64
,
0
);
public
static
readonly
ulong
UInt64Value
=
0xFCCCCCCCCCCCCCCC
;
public
static
readonly
float
Float32Value
=
3.14159f
;
public
static
readonly
double
Float64Value
=
3.14159265359
;
}
}
\ No newline at end of file
tests/FlatBuffers.Test/Lcg.cs
0 → 100644
View file @
d890ef9e
namespace
FlatBuffers.Test
{
/// <summary>
/// Lcg Pseudo RNG
/// </summary>
internal
sealed
class
Lcg
{
private
const
uint
InitialValue
=
10000
;
private
uint
_state
;
public
Lcg
()
{
_state
=
InitialValue
;
}
public
uint
Next
()
{
return
(
_state
=
69069
*
_state
+
362437
);
}
public
void
Reset
()
{
_state
=
InitialValue
;
}
}
}
\ No newline at end of file
tests/FlatBuffers.Test/Program.cs
View file @
d890ef9e
...
...
@@ -15,6 +15,7 @@
*/
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Reflection
;
...
...
@@ -24,39 +25,43 @@ namespace FlatBuffers.Test
{
public
static
int
Main
(
string
[]
args
)
{
var
tests
=
new
FlatBuffersExampleTests
();
try
{
tests
.
RunTests
();
}
catch
(
Exception
ex
)
{
Console
.
WriteLine
(
"FlatBuffersExampleTests FAILED - {0}"
,
ex
.
GetBaseException
());
return
-
1
;
}
var
testResults
=
new
List
<
bool
>();
// Run ByteBuffers Tests
var
testClass
=
new
ByteBufferTests
(
);
var
testClasses
=
Assembly
.
GetExecutingAssembly
().
GetExportedTypes
()
.
Where
(
t
=>
t
.
IsClass
&&
t
.
GetCustomAttributes
(
typeof
(
FlatBuffersTestClassAttribute
),
false
).
Length
>
0
);
var
methods
=
testClass
.
GetType
().
GetMethods
(
BindingFlags
.
Public
|
BindingFlags
.
Instance
)
.
Where
(
m
=>
m
.
Name
.
StartsWith
(
"ByteBuffer_"
));
foreach
(
var
method
in
methods
)
foreach
(
var
testClass
in
testClasses
)
{
try
{
method
.
Invoke
(
testClass
,
new
object
[]
{
});
}
catch
(
Exception
ex
)
var
methods
=
testClass
.
GetMethods
(
BindingFlags
.
Public
|
BindingFlags
.
Instance
)
.
Where
(
m
=>
m
.
GetCustomAttributes
(
typeof
(
FlatBuffersTestMethodAttribute
),
false
).
Length
>
0
);
var
inst
=
Activator
.
CreateInstance
(
testClass
);
foreach
(
var
method
in
methods
)
{
Console
.
WriteLine
(
"ByteBufferTests FAILED when invoking {0} with error {1}"
,
method
.
Name
,
ex
.
GetBaseException
());
return
-
1
;
try
{
method
.
Invoke
(
inst
,
new
object
[]
{
});
testResults
.
Add
(
true
);
}
catch
(
Exception
ex
)
{
Console
.
WriteLine
(
"{0}: FAILED when invoking {1} with error {2}"
,
testClass
.
Name
,
method
.
Name
,
ex
.
GetBaseException
());
testResults
.
Add
(
false
);
}
}
}
Console
.
WriteLine
(
"FlatBuffers test: completed successfully"
);
var
failedCount
=
testResults
.
Count
(
i
=>
i
==
false
);
Console
.
WriteLine
(
"{0} tests run, {1} failed"
,
testResults
.
Count
,
failedCount
);
if
(
failedCount
>
0
)
{
return
-
1
;
}
return
0
;
}
}
...
...
tests/FlatBuffers.Test/TestTable.cs
0 → 100644
View file @
d890ef9e
namespace
FlatBuffers.Test
{
/// <summary>
/// A test Table object that gives easy access to the slot data
/// </summary>
internal
class
TestTable
:
Table
{
public
TestTable
(
ByteBuffer
bb
,
int
pos
)
{
base
.
bb
=
bb
;
base
.
bb_pos
=
pos
;
}
public
bool
GetSlot
(
int
slot
,
bool
def
)
{
var
off
=
base
.
__offset
(
slot
);
if
(
off
==
0
)
{
return
def
;
}
return
bb
.
GetSbyte
(
bb_pos
+
off
)
!=
0
;
}
public
sbyte
GetSlot
(
int
slot
,
sbyte
def
)
{
var
off
=
base
.
__offset
(
slot
);
if
(
off
==
0
)
{
return
def
;
}
return
bb
.
GetSbyte
(
bb_pos
+
off
);
}
public
byte
GetSlot
(
int
slot
,
byte
def
)
{
var
off
=
base
.
__offset
(
slot
);
if
(
off
==
0
)
{
return
def
;
}
return
bb
.
Get
(
bb_pos
+
off
);
}
public
short
GetSlot
(
int
slot
,
short
def
)
{
var
off
=
base
.
__offset
(
slot
);
if
(
off
==
0
)
{
return
def
;
}
return
bb
.
GetShort
(
bb_pos
+
off
);
}
public
ushort
GetSlot
(
int
slot
,
ushort
def
)
{
var
off
=
base
.
__offset
(
slot
);
if
(
off
==
0
)
{
return
def
;
}
return
bb
.
GetUshort
(
bb_pos
+
off
);
}
public
int
GetSlot
(
int
slot
,
int
def
)
{
var
off
=
base
.
__offset
(
slot
);
if
(
off
==
0
)
{
return
def
;
}
return
bb
.
GetInt
(
bb_pos
+
off
);
}
public
uint
GetSlot
(
int
slot
,
uint
def
)
{
var
off
=
base
.
__offset
(
slot
);
if
(
off
==
0
)
{
return
def
;
}
return
bb
.
GetUint
(
bb_pos
+
off
);
}
public
long
GetSlot
(
int
slot
,
long
def
)
{
var
off
=
base
.
__offset
(
slot
);
if
(
off
==
0
)
{
return
def
;
}
return
bb
.
GetLong
(
bb_pos
+
off
);
}
public
ulong
GetSlot
(
int
slot
,
ulong
def
)
{
var
off
=
base
.
__offset
(
slot
);
if
(
off
==
0
)
{
return
def
;
}
return
bb
.
GetUlong
(
bb_pos
+
off
);
}
public
float
GetSlot
(
int
slot
,
float
def
)
{
var
off
=
base
.
__offset
(
slot
);
if
(
off
==
0
)
{
return
def
;
}
return
bb
.
GetFloat
(
bb_pos
+
off
);
}
public
double
GetSlot
(
int
slot
,
double
def
)
{
var
off
=
base
.
__offset
(
slot
);
if
(
off
==
0
)
{
return
def
;
}
return
bb
.
GetDouble
(
bb_pos
+
off
);
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment