From 1d782338c9904b3173d330686d8751b37f7c08c0 Mon Sep 17 00:00:00 2001 From: Alek Mosingiewicz Date: Thu, 10 May 2018 18:23:39 +0200 Subject: [PATCH] Cover skipping BOM with test. --- unittests/compiled_tests.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/unittests/compiled_tests.cpp b/unittests/compiled_tests.cpp index a39c3f8d..dc4a1f24 100644 --- a/unittests/compiled_tests.cpp +++ b/unittests/compiled_tests.cpp @@ -352,6 +352,18 @@ TEST_CASE("Functor cast") CHECK(d == 3 * 6); } +TEST_CASE("BOM at beginning of string") +{ + chaiscript::ChaiScript_Basic chai(create_chaiscript_stdlib(),create_chaiscript_parser()); + + chai.add(chaiscript::fun(&functor_cast_test_call), "test_call"); + + chai.eval("def func() { return \"Hello World\"; };"); + + std::string result = chai.eval("\xef\xbb\xbf(func())"); + + CHECK(result.compare(std::string("Hello World")) == 0); +} int set_state_test_myfun()