From: <ne...@us...> - 2012-07-30 18:22:01
|
Revision: 13465 http://swig.svn.sourceforge.net/swig/?rev=13465&view=rev Author: neha1 Date: 2012-07-30 18:21:52 +0000 (Mon, 30 Jul 2012) Log Message: ----------- Added test for char-binary. From: Oliver Buchtala <oli...@go...> Modified Paths: -------------- branches/gsoc2012-javascript/Examples/test-suite/javascript/Makefile.in Added Paths: ----------- branches/gsoc2012-javascript/Examples/test-suite/javascript/char_binary_runme.js Modified: branches/gsoc2012-javascript/Examples/test-suite/javascript/Makefile.in =================================================================== --- branches/gsoc2012-javascript/Examples/test-suite/javascript/Makefile.in 2012-07-30 18:21:13 UTC (rev 13464) +++ branches/gsoc2012-javascript/Examples/test-suite/javascript/Makefile.in 2012-07-30 18:21:52 UTC (rev 13465) @@ -21,6 +21,7 @@ abstract_typedef2 \ abstract_virtual \ array_member \ + char_binary \ class_ignore \ class_scope_weird \ cpp_enum \ Added: branches/gsoc2012-javascript/Examples/test-suite/javascript/char_binary_runme.js =================================================================== --- branches/gsoc2012-javascript/Examples/test-suite/javascript/char_binary_runme.js (rev 0) +++ branches/gsoc2012-javascript/Examples/test-suite/javascript/char_binary_runme.js 2012-07-30 18:21:52 UTC (rev 13465) @@ -0,0 +1,36 @@ +var t = new char_binary.Test(); +if (t.strlen('hile') != 4) { + print(t.strlen('hile')); + throw("bad multi-arg typemap 1"); +} + +if (t.strlen('hil\0') != 4) { + throw("bad multi-arg typemap 2"); +} + +/* + * creating a raw char* + */ +var pc = char_binary.new_pchar(5); +char_binary.pchar_setitem(pc, 0, 'h'); +char_binary.pchar_setitem(pc, 1, 'o'); +char_binary.pchar_setitem(pc, 2, 'l'); +char_binary.pchar_setitem(pc, 3, 'a'); +char_binary.pchar_setitem(pc, 4, 0); + + +if (t.strlen(pc) != 4) { + throw("bad multi-arg typemap (3)"); +} + +char_binary.var_pchar = pc; +if (char_binary.var_pchar != "hola") { + print(char_binary.var_pchar); + throw("bad pointer case (1)"); +} + +char_binary.var_namet = pc; +if (char_binary.var_namet != "hola") { + throw("bad pointer case (2)"); +} +char_binary.delete_pchar(pc); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |