From f45c4ffa7e54846c73826f837a847e1347467df7 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Tue, 28 Mar 2023 23:25:55 +0800 Subject: [PATCH] collect some simluate function --- libs/pyglet_rs/src/test/vector.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/libs/pyglet_rs/src/test/vector.py b/libs/pyglet_rs/src/test/vector.py index 7ede6ce..3168d07 100644 --- a/libs/pyglet_rs/src/test/vector.py +++ b/libs/pyglet_rs/src/test/vector.py @@ -7,6 +7,8 @@ import random import unittest +from typing import Tuple + from libs.pyglet_rs import Vector2_rs, Vector3_rs, Vector4_rs @@ -20,12 +22,18 @@ def print_test_info(func): return wrapper +def gen_random_vector() -> Tuple[Vector2_rs, Vector3_rs, Vector4_rs]: + vec2 = Vector2_rs(random.randint(1, 100), random.randint(1, 100)) + vec3 = Vector3_rs(random.randint(1, 100), random.randint(1, 100), random.randint(1, 100)) + vec4 = Vector4_rs(random.randint(1, 100), random.randint(1, 100), random.randint(1, 100), random.randint(1, 100)) + return vec2, vec3, vec4 + + class TestVector(unittest.TestCase): + @print_test_info def test1_create_print_vector(self): - vec2 = Vector2_rs(1, 2) - vec3 = Vector3_rs(1, 2, 3) - vec4 = Vector4_rs(1, 2, 3, 4) + vec2, vec3, vec4 = gen_random_vector() print(f"{vec2=}") print(f"{vec3=}") @@ -33,13 +41,8 @@ class TestVector(unittest.TestCase): @print_test_info def test2_calculate_vector(self): - vec2 = Vector2_rs(random.randint(1, 100), random.randint(1, 100)) - vec3 = Vector3_rs(random.randint(1, 100), random.randint(1, 100), random.randint(1, 100)) - vec4 = Vector4_rs(random.randint(1, 100), random.randint(1, 100), random.randint(1, 100), random.randint(1, 100)) - - vec2_1 = Vector2_rs(random.randint(1, 100), random.randint(1, 100)) - vec3_1 = Vector3_rs(random.randint(1, 100), random.randint(1, 100), random.randint(1, 100)) - vec4_1 = Vector4_rs(random.randint(1, 100), random.randint(1, 100), random.randint(1, 100), random.randint(1, 100)) + vec2, vec3, vec4 = gen_random_vector() + vec2_1, vec3_1, vec4_1 = gen_random_vector() print(f"{vec2=} {vec2_1=}") print(f"{vec3=} {vec3_1=}")