Simple C string test
Was added for Javascript, but was not being used in full test-suite. Rename from javascript_unicode to simple_string and provide for all languages. Rewrite to use portable C
This commit is contained in:
parent
f105590c0a
commit
1010fbaa8f
5 changed files with 24 additions and 19 deletions
|
|
@ -613,6 +613,7 @@ C_TEST_CASES += \
|
|||
simple_array \
|
||||
sizeof_pointer \
|
||||
sneaky1 \
|
||||
string_simple \
|
||||
struct_rename \
|
||||
struct_initialization \
|
||||
typedef_struct \
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
var javascript_unicode = require("./javascript_unicode");
|
||||
|
||||
var str = "olé";
|
||||
|
||||
var copy = javascript_unicode.copy_string(str);
|
||||
|
||||
if (str !== copy) {
|
||||
print("Error: copy is not equal: original="+str+", copy="+copy);
|
||||
}
|
||||
10
Examples/test-suite/javascript/string_simple_runme.js
Normal file
10
Examples/test-suite/javascript/string_simple_runme.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
var string_simple = require("./string_simple");
|
||||
|
||||
// Test unicode string
|
||||
var str = "olé";
|
||||
|
||||
var copy = string_simple.copy_string(str);
|
||||
|
||||
if (str !== copy) {
|
||||
throw "Error: copy is not equal: original="+str+", copy="+copy;
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
%module javascript_unicode
|
||||
|
||||
%newobject copy_string;
|
||||
|
||||
%inline %{
|
||||
#include <string.h>
|
||||
const char* copy_string(const char* str) {
|
||||
return strdup(str);
|
||||
}
|
||||
%}
|
||||
13
Examples/test-suite/string_simple.i
Normal file
13
Examples/test-suite/string_simple.i
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
%module string_simple
|
||||
|
||||
%newobject copy_string;
|
||||
|
||||
%inline %{
|
||||
#include <string.h>
|
||||
const char* copy_string(const char* str) {
|
||||
size_t len = strlen(str);
|
||||
char* newstring = malloc(len + 1);
|
||||
strcpy(newstring, str);
|
||||
return newstring;
|
||||
}
|
||||
%}
|
||||
Loading…
Add table
Add a link
Reference in a new issue