参考所有分组:补 NURBS source 覆盖,测试通过

This commit is contained in:
cnc
2026-06-03 09:22:26 +08:00
parent fa4296d730
commit 611e6417b4
15 changed files with 98 additions and 0 deletions

View File

@@ -964,6 +964,35 @@ for case in "${binary_operation_error_cases[@]}"; do
fi
grep -Fq "$expected" "$output_dir/cnc_sim_linuxcnc_$fixture.err"
done
# Source basis: LinuxCNC src/emc/rs274ngc/interp_convert.cc
# convert_nurbs() validates G5.2/G5.3/G6.2 control point, weight, order,
# knot, mode, and feed requirements before issuing NURBS canon output.
nurbs_error_cases=(
"linuxcnc_g52_missing_y_control_point_error|You must specify both X and Y coordinates for Control Points"
"linuxcnc_g52_p_without_xy_after_start_error|Can specify P without X and Y only for the first control point"
"linuxcnc_g52_nonpositive_p_error|Must specify positive weight P for every Control Point"
"linuxcnc_g52_zero_feed_error|Cannot make a NURBS with 0 feedrate"
"linuxcnc_g53_without_g52_error|Cannot use G5.3 without G5.2 first"
"linuxcnc_g53_short_control_points_error|You must specify a number of control points at least equal to the order L = 3"
"linuxcnc_g62_missing_p_order_error|Program the nurbs order P in the first block of instruction"
"linuxcnc_g62_p_non_integer_error|nurbs order P number is not an integer"
"linuxcnc_g62_missing_q_mode_error|Program the nurbs Q value (1,2,3) in the first block of nurbs instruction"
"linuxcnc_g62_q_out_of_range_error|nurbs Q value not in range 1 to 3"
"linuxcnc_g62_q_non_integer_error|nurbs Q number is not an integer"
"linuxcnc_g62_k_non_integer_error|nurbs K number is not an integer"
"linuxcnc_g62_zero_feed_error|Cannot make a nurbs with 0 feedrate"
)
for case in "${nurbs_error_cases[@]}"; do
fixture=${case%%|*}
expected=${case#*|}
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_dump" "tests/gcode/$fixture.ngc" \
>"$output_dir/cnc_sim_linuxcnc_$fixture.json" 2>"$output_dir/cnc_sim_linuxcnc_$fixture.err"; then
echo "expected $fixture.ngc to fail" >&2
exit 1
fi
grep -Fq "$expected" "$output_dir/cnc_sim_linuxcnc_$fixture.err"
done
cp "$base_var_file" "$var_file"
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_coordinate_offsets.ngc >"$output_dir/cnc_sim_linuxcnc_coordinate_offsets.json"
cp "$base_var_file" "$var_file"

View File

@@ -1456,6 +1456,35 @@ if ! grep -q "one plane must be selected for nurbs: XY, YZ, ZX" "$output_dir/cnc
cat "$output_dir/cnc_sim_linuxcnc_source_g62_extended_plane_error.err" >&2
exit 1
fi
# Source basis: LinuxCNC src/emc/rs274ngc/interp_convert.cc
# convert_nurbs() validates G5.2/G5.3/G6.2 control point, weight, order,
# knot, mode, and feed requirements before issuing NURBS canon output.
nurbs_error_cases=(
"linuxcnc_g52_missing_y_control_point_error|You must specify both X and Y coordinates for Control Points"
"linuxcnc_g52_p_without_xy_after_start_error|Can specify P without X and Y only for the first control point"
"linuxcnc_g52_nonpositive_p_error|Must specify positive weight P for every Control Point"
"linuxcnc_g52_zero_feed_error|Cannot make a NURBS with 0 feedrate"
"linuxcnc_g53_without_g52_error|Cannot use G5.3 without G5.2 first"
"linuxcnc_g53_short_control_points_error|You must specify a number of control points at least equal to the order L = 3"
"linuxcnc_g62_missing_p_order_error|Program the nurbs order P in the first block of instruction"
"linuxcnc_g62_p_non_integer_error|nurbs order P number is not an integer"
"linuxcnc_g62_missing_q_mode_error|Program the nurbs Q value (1,2,3) in the first block of nurbs instruction"
"linuxcnc_g62_q_out_of_range_error|nurbs Q value not in range 1 to 3"
"linuxcnc_g62_q_non_integer_error|nurbs Q number is not an integer"
"linuxcnc_g62_k_non_integer_error|nurbs K number is not an integer"
"linuxcnc_g62_zero_feed_error|Cannot make a nurbs with 0 feedrate"
)
for case in "${nurbs_error_cases[@]}"; do
fixture=${case%%|*}
expected=${case#*|}
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" "tests/gcode/$fixture.ngc" \
>"$output_dir/cnc_sim_linuxcnc_source_$fixture.json" 2>"$output_dir/cnc_sim_linuxcnc_source_$fixture.err"; then
echo "expected $fixture.ngc to fail" >&2
exit 1
fi
grep -Fq "$expected" "$output_dir/cnc_sim_linuxcnc_source_$fixture.err"
done
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_g76only.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_g76only.json"

View File

@@ -0,0 +1,3 @@
G21 G90 G17
F100
G5.2 X1 P1

View File

@@ -0,0 +1,4 @@
G21 G90 G17
F100
G5.2 X1 Y1 P1
G5.2 X2 Y2 P0

View File

@@ -0,0 +1,4 @@
G21 G90 G17
F100
G5.2 X1 Y1 P1
G5.2 P1

View File

@@ -0,0 +1,2 @@
G21 G90 G17
G5.2 X1 Y1 P1

View File

@@ -0,0 +1,4 @@
G21 G90 G17
F100
G5.2 X1 Y1 P1
G5.3

View File

@@ -0,0 +1,3 @@
G21 G90 G17
F100
G5.3

View File

@@ -0,0 +1,3 @@
G21 G90 G17
F100
G6.2 X1 Y1 R1 K0.5 P3 Q1

View File

@@ -0,0 +1,3 @@
G21 G90 G17
F100
G6.2 X1 Y1 R1 K0 Q1

View File

@@ -0,0 +1,3 @@
G21 G90 G17
F100
G6.2 X1 Y1 R1 K0 P3

View File

@@ -0,0 +1,3 @@
G21 G90 G17
F100
G6.2 X1 Y1 R1 K0 P3.5 Q1

View File

@@ -0,0 +1,3 @@
G21 G90 G17
F100
G6.2 X1 Y1 R1 K0 P3 Q1.5

View File

@@ -0,0 +1,3 @@
G21 G90 G17
F100
G6.2 X1 Y1 R1 K0 P3 Q4

View File

@@ -0,0 +1,2 @@
G21 G90 G17
G6.2 X1 Y1 R1 K0 P3 Q1