Skip to content

Commit

Permalink
Port C++ modified tag pair tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BeanCheeseBurrito committed Nov 15, 2024
1 parent daa1220 commit aba2783
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Flecs.NET.Tests/Cpp/DocTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private void SetUuid()

Assert.True(e.Has<EcsDocDescription>(Ecs.Doc.Uuid));

Assert.Equal(e.DocUuid(), "81f50b40-09ff-4ce0-a388-4a52a14052c7");
Assert.Equal("81f50b40-09ff-4ce0-a388-4a52a14052c7", e.DocUuid());
}

[Fact]
Expand Down
53 changes: 53 additions & 0 deletions src/Flecs.NET.Tests/Cpp/PairTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1114,4 +1114,57 @@ private void SymmetricWithChildOf()

Assert.True(bob.Has<Likes>(alice));
}

[Fact]
private void ModifiedTagSecond()
{
using World world = World.Create();

int count = 0;
world.Observer<Position>()
.TermAt(0).Second<Tag>()
.Event(Ecs.OnSet)
.Each((ref Position p) =>
{
Assert.Equal(10, p.X);
Assert.Equal(20, p.Y);
count++;
});

Entity e = world.Entity();

ref Position p = ref e.EnsureFirst<Position, Tag>();
p.X = 10;
p.Y = 20;
e.Modified<Position, Tag>();

Assert.Equal(1, count);
}

[Fact]
private void ModifiedTagFirst()
{
using World world = World.Create();

int count = 0;
world.Observer()
.With<Tag, Position>()
.Event(Ecs.OnSet)
.Each((Iter it, int row) =>
{
ref Position p = ref it.FieldAt<Position>(0, row);
Assert.Equal(10, p.X);
Assert.Equal(20, p.Y);
count++;
});

Entity e = world.Entity();

ref Position p = ref e.EnsureSecond<Tag, Position>();
p.X = 10;
p.Y = 20;
e.Modified<Tag, Position>();

Assert.Equal(1, count);
}
}

0 comments on commit aba2783

Please sign in to comment.