(t *testing.T)
| 342 | } |
| 343 | |
| 344 | func TestSetUniqueName(t *testing.T) { |
| 345 | root := NewNodeBase() |
| 346 | assert.Equal(t, "node-base", root.Name) |
| 347 | child := NewNodeBase(root) |
| 348 | assert.Equal(t, "node-base-0", child.Name) |
| 349 | child.SetName("my-name") |
| 350 | assert.Equal(t, "my-name", child.Name) |
| 351 | |
| 352 | // does not change with SetParent when there is already a name |
| 353 | SetParent(child, root) |
| 354 | assert.Equal(t, "my-name", child.Name) |
| 355 | |
| 356 | // but does change with SetUniqueName when there is already a name |
| 357 | SetUniqueName(child) |
| 358 | assert.Equal(t, "my-name-2", child.Name) |
| 359 | |
| 360 | // ensure SetUniqueName works with different types |
| 361 | newChild := testdata.NewNodeEmbed(root) |
| 362 | assert.Equal(t, "node-embed-3", newChild.Name) |
| 363 | } |
| 364 | |
| 365 | func TestTreeMod(t *testing.T) { |
| 366 | // TODO: clean up these commented out tree tests |
nothing calls this directly
no test coverage detected