8000 Added unittest to cover utility::add_class<Enum> registration. · ChaiScript/ChaiScript@316ba45 · GitHub
[go: up one dir, main page]

Skip to content

Commit 316ba45

Browse files
committed
Added unittest to cover utility::add_class<Enum> registration.
1 parent f0796b5 commit 316ba45

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

unittests/compiled_tests.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,41 @@ TEST_CASE("Utility_Test utility class wrapper")
517517

518518
}
519519

520+
enum Utility_Test_Numbers
521+
{
522+
ONE,
523+
TWO,
524+
THREE
525+
};
526+
527+
TEST_CASE("Utility_Test utility class wrapper")
528+
{
529+
530+
chaiscript::ModulePtr m = chaiscript::ModulePtr(new chaiscript::Module());
531+
532+
using namespace chaiscript;
533+
534+
chaiscript::utility::add_class<Utility_Test_Numbers>(*m,
535+
"Utility_Test_Numbers",
536+
{
537+
},
538+
{ { const_var(ONE), "ONE" },
539+
{ const_var(TWO), "TWO" },
540+
{ const_var(THREE), "THREE" }
541+
542+
}
543+
);
544+
545+
546+
chaiscript::ChaiScript chai;
547+
chai.add(m);
548+
549+
CHECK(chai.eval<Utility_Test_Numbers>("ONE ") == 0);
550+
CHECK(chai.eval<Utility_Test_Numbers>("TWO ") == 1);
551+
CHECK(chai.eval<Utility_Test_Numbers>("THREE ") == 2);
552+
553+
}
554+
520555

521556
////// Object copy count test
522557

0 commit comments

Comments
 (0)
0