Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 64 bit signed and unsigned integer type support to UserData #479

Merged
merged 1 commit into from
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/ignition/rendering/Node.hh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace ignition
/// "empty variant" should be returned for keys that don't exist)
using Variant =
std::variant<std::monostate, int, float, double, std::string, bool,
unsigned int>;
unsigned int, int64_t, uint64_t>;

/// \class Node Node.hh ignition/rendering/Node.hh
/// \brief Represents a single posable node in the scene graph
Expand Down
18 changes: 18 additions & 0 deletions src/Visual_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,24 @@ void VisualTest::UserData(const std::string &_renderEngine)
value = visual->UserData(unsignedIntKey);
EXPECT_EQ(unsignedIntValue, std::get<unsigned int>(value));

// int64_t
std::string int64Key = "int64_t";
int64_t int64Value = -math::MAX_I64;
EXPECT_FALSE(visual->HasUserData(int64Key));
visual->SetUserData(int64Key, int64Value);
EXPECT_TRUE(visual->HasUserData(int64Key));
value = visual->UserData(int64Key);
EXPECT_EQ(int64Value, std::get<int64_t>(value));

// uint64_t
std::string uint64Key = "uint64_t";
uint64_t uint64Value = math::MAX_UI64;
EXPECT_FALSE(visual->HasUserData(uint64Key));
visual->SetUserData(uint64Key, uint64Value);
EXPECT_TRUE(visual->HasUserData(uint64Key));
value = visual->UserData(uint64Key);
EXPECT_EQ(uint64Value, std::get<uint64_t>(value));

// test a key that does not exist (should return no data)
value = visual->UserData("invalidKey");
EXPECT_FALSE(std::holds_alternative<int>(value));
Expand Down