Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
VirxEC committed May 28, 2024
1 parent 36651b1 commit 5c37c04
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 21 deletions.
42 changes: 21 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions pytest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from random import randrange
from time import time_ns

from rlbot_flatbuffers import *
Expand All @@ -8,6 +9,31 @@ def __add__(self, other):
return MyVector(self.x + other.x, self.y + other.y, self.z + other.z)


def random_string():
return "".join(chr(randrange(32, 127)) for _ in range(64))


def random_player_config():
return PlayerConfiguration(
variety=PlayerClass(Psyonix(1.)),
name=random_string(),
location=random_string(),
run_command=random_string(),
loadout=PlayerLoadout(
loadout_paint=LoadoutPaint(),
primary_color_lookup=Color(),
secondary_color_lookup=Color(),
)
)


def random_script_config():
return ScriptConfiguration(
location=random_string(),
run_command=random_string(),
)


if __name__ == "__main__":
vec1 = MyVector(1, 2, 3)
vec2 = Vector3(4, 5, 6)
Expand Down Expand Up @@ -71,6 +97,26 @@ def __add__(self, other):
except InvalidFlatbuffer as e:
print(e)

match_settings = MatchSettings(
game_path=random_string(),
game_map_upk=random_string(),
player_configurations=[random_player_config() for _ in range(128)],
script_configurations = [random_script_config() for _ in range(8)],
mutator_settings=MutatorSettings()
)

data = match_settings.pack()
print(f"MatchSettings size: {len(data)} bytes")

renderPolyLine = RenderMessage(RenderType(PolyLine3D(
[Vector3() for _ in range(2048)],
)))

data = renderPolyLine.pack()
print(f"RenderMessage size: {len(data)} bytes")

print()

print("Running quick benchmark...")

num_trials = 100_000
Expand Down

0 comments on commit 5c37c04

Please sign in to comment.