Skip to content

Commit 84dfc4f

Browse files
committed
for unittest
1 parent b148037 commit 84dfc4f

5 files changed

Lines changed: 21 additions & 20 deletions

File tree

test/Box2D.NET.Test/B2BodiesTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void Test_b2LimitVelocity()
3535
// Add a shape to the body
3636
B2Polygon box = b2MakeBox(1.0f, 1.0f);
3737
B2ShapeDef shapeDef = b2DefaultShapeDef();
38-
b2CreatePolygonShape(bodyId, ref shapeDef, ref box);
38+
b2CreatePolygonShape(bodyId, shapeDef, box);
3939

4040
// Get the body state
4141
B2Body body = b2GetBodyFullId(world, bodyId);

test/Box2D.NET.Test/B2ShapeTest.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class B2ShapeTest
2424
public void ShapeMassTest()
2525
{
2626
{
27-
B2MassData md = b2ComputeCircleMass(ref circle, 1.0f);
27+
B2MassData md = b2ComputeCircleMass(circle, 1.0f);
2828
Assert.That(md.mass - B2_PI, Is.LessThan(FLT_EPSILON));
2929
Assert.That(md.center.X, Is.EqualTo(1.0f));
3030
Assert.That(md.center.Y, Is.EqualTo(0.0f));
@@ -35,11 +35,11 @@ public void ShapeMassTest()
3535
float radius = capsule.radius;
3636
float length = b2Distance(capsule.center1, capsule.center2);
3737

38-
B2MassData md = b2ComputeCapsuleMass(ref capsule, 1.0f);
38+
B2MassData md = b2ComputeCapsuleMass(capsule, 1.0f);
3939

4040
// Box that full contains capsule
4141
B2Polygon r = b2MakeBox(radius, radius + 0.5f * length);
42-
B2MassData mdr = b2ComputePolygonMass(ref r, 1.0f);
42+
B2MassData mdr = b2ComputePolygonMass(r, 1.0f);
4343

4444
// Approximate capsule using convex hull
4545
B2Vec2[] points = new B2Vec2[2 * N];
@@ -81,23 +81,23 @@ public void ShapeMassTest()
8181
public void ShapeAABBTest()
8282
{
8383
{
84-
B2AABB b = b2ComputeCircleAABB(ref circle, b2Transform_identity);
84+
B2AABB b = b2ComputeCircleAABB(circle, b2Transform_identity);
8585
Assert.That(b.lowerBound.X, Is.LessThan(FLT_EPSILON));
8686
Assert.That(b.lowerBound.Y + 1.0f, Is.LessThan(FLT_EPSILON));
8787
Assert.That(b.upperBound.X - 2.0f, Is.LessThan(FLT_EPSILON));
8888
Assert.That(b.upperBound.Y - 1.0f, Is.LessThan(FLT_EPSILON));
8989
}
9090

9191
{
92-
B2AABB b = b2ComputePolygonAABB(ref box, b2Transform_identity);
92+
B2AABB b = b2ComputePolygonAABB(box, b2Transform_identity);
9393
Assert.That(b.lowerBound.X + 1.0f, Is.LessThan(FLT_EPSILON));
9494
Assert.That(b.lowerBound.Y + 1.0f, Is.LessThan(FLT_EPSILON));
9595
Assert.That(b.upperBound.X - 1.0f, Is.LessThan(FLT_EPSILON));
9696
Assert.That(b.upperBound.Y - 1.0f, Is.LessThan(FLT_EPSILON));
9797
}
9898

9999
{
100-
B2AABB b = b2ComputeSegmentAABB(ref segment, b2Transform_identity);
100+
B2AABB b = b2ComputeSegmentAABB(segment, b2Transform_identity);
101101
Assert.That(b.lowerBound.X, Is.LessThan(FLT_EPSILON));
102102
Assert.That(b.lowerBound.Y + 1.0f, Is.LessThan(FLT_EPSILON));
103103
Assert.That(b.upperBound.X, Is.LessThan(FLT_EPSILON));
@@ -113,9 +113,9 @@ public void PointInShapeTest()
113113

114114
{
115115
bool hit;
116-
hit = b2PointInCircle(ref circle, p1);
116+
hit = b2PointInCircle(circle, p1);
117117
Assert.That(hit, Is.EqualTo(true));
118-
hit = b2PointInCircle(ref circle, p2);
118+
hit = b2PointInCircle(circle, p2);
119119
Assert.That(hit, Is.EqualTo(false));
120120
}
121121

@@ -134,23 +134,23 @@ public void RayCastShapeTest()
134134
B2RayCastInput input = new B2RayCastInput(new B2Vec2(-4.0f, 0.0f), new B2Vec2(8.0f, 0.0f), 1.0f);
135135

136136
{
137-
B2CastOutput output = b2RayCastCircle(circle, ref input);
137+
B2CastOutput output = b2RayCastCircle(circle, input);
138138
Assert.That(output.hit);
139139
Assert.That(output.normal.X + 1.0f, Is.LessThan(FLT_EPSILON));
140140
Assert.That(output.normal.Y, Is.LessThan(FLT_EPSILON));
141141
Assert.That(output.fraction - 0.5f, Is.LessThan(FLT_EPSILON));
142142
}
143143

144144
{
145-
B2CastOutput output = b2RayCastPolygon(ref box, ref input);
145+
B2CastOutput output = b2RayCastPolygon(box, input);
146146
Assert.That(output.hit);
147147
Assert.That(output.normal.X + 1.0f, Is.LessThan(FLT_EPSILON));
148148
Assert.That(output.normal.Y, Is.LessThan(FLT_EPSILON));
149149
Assert.That(output.fraction - 3.0f / 8.0f, Is.LessThan(FLT_EPSILON));
150150
}
151151

152152
{
153-
B2CastOutput output = b2RayCastSegment(ref segment, ref input, true);
153+
B2CastOutput output = b2RayCastSegment(segment, input, true);
154154
Assert.That(output.hit);
155155
Assert.That(output.normal.X + 1.0f, Is.LessThan(FLT_EPSILON));
156156
Assert.That(output.normal.Y, Is.LessThan(FLT_EPSILON));

test/Box2D.NET.Test/B2WorldTest.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ public void HelloWorld()
4040
// Call the body factory which allocates memory for the ground body
4141
// from a pool and creates the ground box shape (also from a pool).
4242
// The body is also added to the world.
43-
B2BodyId groundId = b2CreateBody(worldId, ref groundBodyDef);
43+
B2BodyId groundId = b2CreateBody(worldId, groundBodyDef);
4444
Assert.That(b2Body_IsValid(groundId));
4545

4646
// Define the ground box shape. The extents are the half-widths of the box.
4747
B2Polygon groundBox = b2MakeBox(50.0f, 10.0f);
4848

4949
// Add the box shape to the ground body.
5050
B2ShapeDef groundShapeDef = b2DefaultShapeDef();
51-
b2CreatePolygonShape(groundId, ref groundShapeDef, ref groundBox);
51+
b2CreatePolygonShape(groundId, groundShapeDef, groundBox);
5252

5353
// Define the dynamic body. We set its position and call the body factory.
5454
B2BodyDef bodyDef = b2DefaultBodyDef();
@@ -70,7 +70,7 @@ public void HelloWorld()
7070
shapeDef.material.friction = 0.3f;
7171

7272
// Add the shape to the body.
73-
b2CreatePolygonShape(bodyId, ref shapeDef, ref dynamicBox);
73+
b2CreatePolygonShape(bodyId, shapeDef, dynamicBox);
7474

7575
// Prepare for simulation. Typically we use a time step of 1/60 of a
7676
// second (60Hz) and 4 sub-steps. This provides a high quality simulation
@@ -150,7 +150,7 @@ public void DestroyAllBodiesWorld()
150150
bodyIds[count] = b2CreateBody(worldId, bodyDef);
151151

152152
B2ShapeDef shapeDef = b2DefaultShapeDef();
153-
b2CreatePolygonShape(bodyIds[count], ref shapeDef, ref square);
153+
b2CreatePolygonShape(bodyIds[count], shapeDef, square);
154154
count += 1;
155155
}
156156
else
@@ -224,7 +224,7 @@ public void TestWorldRecycle()
224224
Assert.That(b2World_IsValid(worldIds[j]), Is.EqualTo(true), $"i({i}) j({j})");
225225

226226
B2BodyDef bodyDef = b2DefaultBodyDef();
227-
b2CreateBody(worldIds[j], ref bodyDef);
227+
b2CreateBody(worldIds[j], bodyDef);
228228
}
229229

230230
for (int j = 0; j < WORLD_COUNT; ++j)
@@ -343,7 +343,7 @@ public void TestSensor()
343343
B2Polygon box = b2MakeBox(0.5f, 10.0f);
344344
B2ShapeDef shapeDef = b2DefaultShapeDef();
345345
shapeDef.enableSensorEvents = true;
346-
b2CreatePolygonShape(wallId, ref shapeDef, ref box);
346+
b2CreatePolygonShape(wallId, shapeDef, box);
347347

348348
// Bullet fired towards the wall
349349
bodyDef = b2DefaultBodyDef();
@@ -357,7 +357,7 @@ public void TestSensor()
357357
shapeDef.isSensor = true;
358358
shapeDef.enableSensorEvents = true;
359359
B2Circle circle = new B2Circle(new B2Vec2(0.0f, 0.0f), 0.1f);
360-
b2CreateCircleShape(bulletId, ref shapeDef, ref circle);
360+
b2CreateCircleShape(bulletId, shapeDef, circle);
361361

362362
int beginCount = 0;
363363
int endCount = 0;

test/Box2D.NET.Test/Box2D.NET.Test.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
55
<IsPackable>false</IsPackable>
6+
<WarningsAsErrors>$(WarningsAsErrors);CS9191</WarningsAsErrors>
67
</PropertyGroup>
78

89
<PropertyGroup Condition="'$(Configuration)' == 'Release'">

test/Box2D.NET.Test/Helpers/B2TestHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static B2ShapeId Circle(B2WorldId worldId, B2Vec2 position, float radius,
2424
shapeDef.material.friction = 0.5f;
2525

2626
B2Circle circle = new B2Circle(new B2Vec2(0.0f, 0.0f), radius);
27-
B2ShapeId shapeId = b2CreateCircleShape(bodyId, ref shapeDef, ref circle);
27+
B2ShapeId shapeId = b2CreateCircleShape(bodyId, shapeDef, circle);
2828

2929
return shapeId;
3030
}

0 commit comments

Comments
 (0)