aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChad Austin <chad@imvu.com>2013-04-10 23:10:26 -0700
committerJukka Jylänki <jujjyl@gmail.com>2013-04-18 20:08:08 +0300
commitbcf017994524b515274344dcf667dc03b8153448 (patch)
tree95bb8d70d6219ca703cc84a75a7bb39c5631ac60 /tests
parentebb2069d804f49b457f6a4349a3136703db60190 (diff)
verify non-ascii data can be passed through std::string
Diffstat (limited to 'tests')
-rwxr-xr-xtests/embind/embind.test.js8
-rw-r--r--tests/embind/embind_test.cpp10
2 files changed, 18 insertions, 0 deletions
diff --git a/tests/embind/embind.test.js b/tests/embind/embind.test.js
index 4a8665f4..07f093ea 100755
--- a/tests/embind/embind.test.js
+++ b/tests/embind/embind.test.js
@@ -388,6 +388,14 @@ module({
});
});
+ BaseFixture.extend("string", function() {
+ var expected = '';
+ for (var i = 0; i < 128; ++i) {
+ expected += String.fromCharCode(128 + i);
+ }
+ assert.equal(expected, cm.get_non_ascii_string());
+ });
+
BaseFixture.extend("embind", function() {
test("value creation", function() {
assert.equal(15, cm.emval_test_new_integer());
diff --git a/tests/embind/embind_test.cpp b/tests/embind/embind_test.cpp
index 39de3852..6a3d5dba 100644
--- a/tests/embind/embind_test.cpp
+++ b/tests/embind/embind_test.cpp
@@ -79,6 +79,15 @@ unsigned emval_test_sum(val v) {
return rv;
}
+std::string get_non_ascii_string() {
+ char c[128 + 1];
+ c[128] = 0;
+ for (int i = 0; i < 128; ++i) {
+ c[i] = 128 + i;
+ }
+ return c;
+}
+
std::string emval_test_take_and_return_const_char_star(const char* str) {
return str;
}
@@ -1493,6 +1502,7 @@ EMSCRIPTEN_BINDINGS(tests) {
function("const_ref_adder", &const_ref_adder);
function("emval_test_sum", &emval_test_sum);
+ function("get_non_ascii_string", &get_non_ascii_string);
//function("emval_test_take_and_return_const_char_star", &emval_test_take_and_return_const_char_star);
function("emval_test_take_and_return_std_string", &emval_test_take_and_return_std_string);
function("emval_test_take_and_return_std_string_const_ref", &emval_test_take_and_return_std_string_const_ref);