Skip to content

Commit

Permalink
Added test
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Oct 7, 2024
1 parent 508d04c commit 6bea811
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions test/test_Native_Registry.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include "unittest.hpp"
#include "embed_ruby.hpp"

#include <rice/rice.hpp>
#include <rice/stl.hpp>

using namespace Rice;

TESTSUITE(NativeRegistry);

SETUP(NativeRegistry)
{
embed_ruby();
}

TESTCASE(collisions)
{
std::array<Class, 100> classes;
int scale = 1000;

for (int i = 0; i < std::size(classes); i++)
{
Class cls(anonymous_class());

for (int j = 0; j < scale; j++)
{
cls.define_function("int" + std::to_string(j), []() { return 1; });
cls.define_function("long" + std::to_string(j), []() { return 1L; });
cls.define_function("double" + std::to_string(j), []() { return 1.0; });
cls.define_function("float" + std::to_string(j), []() { return 1.0f; });
cls.define_function("bool" + std::to_string(j), []() { return true; });
}

classes[i] = cls;
}

for (auto& cls : classes)
{
auto obj = cls.call("new");

for (int j = 0; j < scale; j++)
{
obj.call("int" + std::to_string(j));
obj.call("long" + std::to_string(j));
obj.call("double" + std::to_string(j));
obj.call("float" + std::to_string(j));
obj.call("bool" + std::to_string(j));
}
}
}

0 comments on commit 6bea811

Please sign in to comment.