MCPcopy Create free account
hub / github.com/cogentcore/core / TestSetUniqueName

Function TestSetUniqueName

tree/node_test.go:344–363  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

342}
343
344func 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
365func TestTreeMod(t *testing.T) {
366 // TODO: clean up these commented out tree tests

Callers

nothing calls this directly

Calls 6

SetNameMethod · 0.95
NewNodeEmbedFunction · 0.92
SetParentFunction · 0.85
SetUniqueNameFunction · 0.85
EqualMethod · 0.80
NewNodeBaseFunction · 0.70

Tested by

no test coverage detected