@@ -169,28 +169,31 @@ TEST_CASE("[NodePath] Empty path") {
169
169
}
170
170
171
171
TEST_CASE (" [NodePath] Slice" ) {
172
- const NodePath node_path_relative = NodePath (" Parent/Child:prop" );
172
+ const NodePath node_path_relative = NodePath (" Parent/Child:prop:subprop " );
173
173
const NodePath node_path_absolute = NodePath (" /root/Parent/Child:prop" );
174
174
CHECK_MESSAGE (
175
175
node_path_relative.slice (0 , 2 ) == NodePath (" Parent/Child" ),
176
176
" The slice lower bound should be inclusive and the slice upper bound should be exclusive." );
177
177
CHECK_MESSAGE (
178
- node_path_relative.slice (3 ) == NodePath (" :prop" ),
179
- " Slicing on the length of the path should return the last entry." );
178
+ node_path_relative.slice (3 ) == NodePath (" :subprop" ),
179
+ " Slicing on the last index (length - 1) should return the last entry." );
180
+ CHECK_MESSAGE (
181
+ node_path_relative.slice (1 ) == NodePath (" Child:prop:subprop" ),
182
+ " Slicing without upper bound should return remaining entries after index." );
180
183
CHECK_MESSAGE (
181
184
node_path_relative.slice (1 , 3 ) == NodePath (" Child:prop" ),
182
185
" Slicing should include names and subnames." );
183
186
CHECK_MESSAGE (
184
- node_path_relative.slice (-1 ) == NodePath (" :prop " ),
187
+ node_path_relative.slice (-1 ) == NodePath (" :subprop " ),
185
188
" Slicing on -1 should return the last entry." );
186
189
CHECK_MESSAGE (
187
- node_path_relative.slice (0 , -1 ) == NodePath (" Parent/Child" ),
190
+ node_path_relative.slice (0 , -1 ) == NodePath (" Parent/Child:prop " ),
188
191
" Slicing up to -1 should include the second-to-last entry." );
189
192
CHECK_MESSAGE (
190
- node_path_relative.slice (-2 , -1 ) == NodePath (" Child " ),
193
+ node_path_relative.slice (-2 , -1 ) == NodePath (" :prop " ),
191
194
" Slicing from negative to negative should treat lower bound as inclusive and upper bound as exclusive." );
192
195
CHECK_MESSAGE (
193
- node_path_relative.slice (0 , 10 ) == NodePath (" Parent/Child:prop" ),
196
+ node_path_relative.slice (0 , 10 ) == NodePath (" Parent/Child:prop:subprop " ),
194
197
" Slicing past the length of the path should work like slicing up to the last entry." );
195
198
CHECK_MESSAGE (
196
199
node_path_relative.slice (-10 , 2 ) == NodePath (" Parent/Child" ),
0 commit comments