8000 Add failing test for vector of enum values · ChaiScript/ChaiScript@d748935 · GitHub
[go: up one dir, main page]

Skip to content

Commit d748935

Browse files
committed
Add failing test for vector of enum values
1 parent 316ba45 commit d748935

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

unittests/compiled_tests.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// caught in other cpp files if chaiscript causes them
33

44
#include <chaiscript/utility/utility.hpp>
5+
#include <chaiscript/dispatchkit/bootstrap_stl.hpp>
56

67
#ifdef CHAISCRIPT_MSVC
78
#pragma warning(push)
@@ -517,14 +518,19 @@ TEST_CASE("Utility_Test utility class wrapper")
517518

518519
}
519520

521+
520522
enum Utility_Test_Numbers
521523
{
522-
ONE,
524+
ONE,
523525
TWO,
524526
THREE
525527
};
526528

527-
TEST_CASE("Utility_Test utility class wrapper")
529+
void do_something_with_enum_vector(const std::vector<Utility_Test_Numbers> &)
530+
{
531+
}
532+
533+
TEST_CASE("Utility_Test utility class wrapper for enum")
528534
{
529535

530536
chaiscript::ModulePtr m = chaiscript::ModulePtr(new chaiscript::Module());
@@ -538,7 +544,7 @@ TEST_CASE("Utility_Test utility class wrapper")
538544
{ { const_var(ONE), "ONE" },
539545
{ const_var(TWO), "TWO" },
540546
{ const_var(THREE), "THREE" }
541-
547+
542548
}
543549
);
544550

@@ -550,6 +556,12 @@ TEST_CASE("Utility_Test utility class wrapper")
550556
CHECK(chai.eval<Utility_Test_Numbers>("TWO ") == 1);
551557
CHECK(chai.eval<Utility_Test_Numbers>("THREE ") == 2);
552558

559+
chai.add(chaiscript::fun(&do_something_with_enum_vector), "do_something_with_enum_vector");
560+
chai.add(chaiscript::vector_conversion<std::vector<Utility_Test_Numbers>>());
561+
CHECK_NOTHROW(chai.eval("var a = [ONE, TWO, THREE]"));
562+
CHECK_NOTHROW(chai.eval("do_something_with_enum_vector([ONE])"));
563+
CHECK_NOTHROW(chai.eval("[ONE]"));
564+
553565
}
554566

555567

0 commit comments

Comments
 (0)
0