Coverage for tests \ test_circle_calculator.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-27 03:59 -0400

1# SPDX-FileCopyrightText: 2026-present Pavel M. Penev <pavpen@gmail.com> 

2# 

3# SPDX-License-Identifier: MIT 

4 

5import math 

6 

7import pytest 

8 

9from pavpen.geometry_calculator.circle_calculator import CircleCalculator 

10from pavpen.geometry_calculator.vector_field_implementations.tuple_float_vector_field_operations import ( 

11 TupleFloatVectorFieldOperations, 

12) 

13 

14 

15class TestCircleCalculator: 

16 def test_point_at_angle_rad_returns_a_point(self): 

17 # Setup 

18 vector_field_operations = TupleFloatVectorFieldOperations.for_2d() 

19 calculator = CircleCalculator( 

20 vector_field_operations=vector_field_operations, 

21 center=(0, 0), 

22 radius=1, 

23 x_hat=(1, 0), 

24 y_hat=(0, 1), 

25 ) 

26 

27 # Act 

28 result = calculator.point_at_angle_rad(0) 

29 

30 # Verify 

31 assert result == pytest.approx((1, 0)) 

32 

33 def test_point_at_angle_rad_accepts_a_negative_angle(self): 

34 # Setup 

35 vector_field_operations = TupleFloatVectorFieldOperations.for_3d() 

36 calculator = CircleCalculator( 

37 vector_field_operations=vector_field_operations, 

38 center=(1, 0, 0), 

39 radius=1, 

40 x_hat=(0, 1, 0), 

41 y_hat=(0, 0, 1), 

42 ) 

43 

44 # Act 

45 result = calculator.point_at_angle_rad(-math.pi / 4) 

46 

47 # Verify 

48 assert result == pytest.approx((1, 1.0 / math.sqrt(2.0), -1.0 / math.sqrt(2.0)))