Skip to content

WorkspaceObject::setString allows setting invalid names for ModelObjects #4205

@macumber

Description

@macumber

Issue overview

WorkspaceObject::setString allows setting invalid names for ModelObjects

Current Behavior

WorkspaceObject::setString assumes name index is always 0, for ModelObjects name index is 1. This allows user to set invalid names using WorkspaceObject::setString.

Expected Behavior

The following test should pass:

  Model model;
  Space space1(model);
  Space space2(model);
  unsigned nameIndex = 1;

  EXPECT_TRUE(space1.setString(nameIndex, "Space 1"));
  ASSERT_TRUE(space1.getString(nameIndex));
  EXPECT_EQ("Space 1", space1.getString(nameIndex).get());

  EXPECT_FALSE(space2.setString(nameIndex, "Space 1"));
  ASSERT_TRUE(space2.getString(nameIndex));
  EXPECT_NE("Space 1", space2.getString(nameIndex).get());

  EXPECT_FALSE(space2.setString(nameIndex, ""));
  ASSERT_TRUE(space2.getString(nameIndex));
  EXPECT_NE("", space2.getString(nameIndex).get());

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions