def test_computeArcCenterOffsets_zeroRadius(self):
        """Test the computeArcCenterOffsets method with a radius of zero."""
        mockLogger = mock.Mock()

        mockState = mock.Mock()
        mockState.position.X_AXIS.nativeToLogical.return_value = 0
        mockState.position.Y_AXIS.nativeToLogical.return_value = 0

        unit = GcodeHandlers(mockState, mockLogger)

        result = unit.computeArcCenterOffsets(10, 10, 0, True)

        self.assertEqual(result, (0, 0),
                         "No offset should be computed when the radius is 0")
    def test_computeArcCenterOffsets_counterClockwise_semicircle(self):
        """Test the computeArcCenterOffsets method with a CCW semicircular 100 unit arc."""
        arcRadius = 50

        mockLogger = mock.Mock()

        mockState = mock.Mock()
        mockState.position.X_AXIS.nativeToLogical.return_value = arcRadius
        mockState.position.Y_AXIS.nativeToLogical.return_value = 0

        unit = GcodeHandlers(mockState, mockLogger)

        result = unit.computeArcCenterOffsets(-arcRadius, 0, arcRadius, False)

        self.assertEqual(
            result, (-arcRadius, 0),
            "The computed center offset should be (%s, %s)" % (-arcRadius, 0))
    def test_computeArcCenterOffsets_circle(self):
        """Test the computeArcCenterOffsets method when the start and end points are identical."""
        arcRadius = 50
        mockLogger = mock.Mock()

        mockState = mock.Mock()
        mockState.position.X_AXIS.nativeToLogical.return_value = 0
        mockState.position.Y_AXIS.nativeToLogical.return_value = 0

        unit = GcodeHandlers(mockState, mockLogger)

        result = unit.computeArcCenterOffsets(0, 0, arcRadius, True)

        self.assertEqual(
            result, (0, 0),
            "No offset should be computed when the start and end points are the same"
        )
    def test_computeArcCenterOffsets_radiusTooSmall(self):
        """Test computeArcCenterOffsets when the radius is less than half the chord length."""
        mockLogger = mock.Mock()

        mockState = mock.Mock()
        mockState.position.X_AXIS.nativeToLogical.return_value = 0
        mockState.position.Y_AXIS.nativeToLogical.return_value = 0

        unit = GcodeHandlers(mockState, mockLogger)

        # Try chord length 10, radius 4
        result = unit.computeArcCenterOffsets(10, 0, 4, True)

        self.assertEqual(
            result, (0, 0),
            "No offset should be computed if the radius is less than half the chord length."
        )
    def test_computeArcCenterOffsets_negativeRadius(self):
        """Test computeArcCenterOffsets method with a negative radius value."""
        # Tests an arc with a chord length of 8 (half-width of 4) and a height (from chord to
        # center point on arc) of 3

        arcRadius = -(4.0 + 1.0 / 6.0)

        mockLogger = mock.Mock()

        mockState = mock.Mock()
        mockState.position.X_AXIS.nativeToLogical.return_value = 0
        mockState.position.Y_AXIS.nativeToLogical.return_value = 0

        unit = GcodeHandlers(mockState, mockLogger)

        result = unit.computeArcCenterOffsets(8, 0, arcRadius, True)

        self.assertEqual(
            result[0], 4,
            "The returned I value should match the expected value")
        self.assertAlmostEqual(
            result[1],
            arcRadius + 3,  # Note addition here when radius is negative
            msg="The returned J value should match the expected value")