Skip to content

Commit 7861005

Browse files
committed
Add some tests
1 parent 76a9600 commit 7861005

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

ScalaBindgen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@ bool TreeVisitor::VisitRecordDecl(clang::RecordDecl *record){
110110
std::string fields = "";
111111

112112
for(const clang::FieldDecl* field : record->fields()){
113-
fields += typeTranslator.Translate(field->getType(), &name) + ",";
113+
fields += typeTranslator.Translate(field->getType(), &name) + ", ";
114114
counter++;
115115
}
116116

117117
//remove last ,
118118
if(fields != ""){
119-
fields = fields.substr(0, fields.size()-1);
119+
fields = fields.substr(0, fields.size()-2);
120120
}
121121

122122
if(counter < SCALA_NATIVE_MAX_STRUCT_FIELDS){

SimpleTypeTests.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,11 @@ TEST_CASE("native types function pointer", "[Type]"){
5757
REQUIRE(answ == Translate(code));
5858
}
5959

60+
TEST_CASE("struct pointer", "[Type]"){
61+
std::string code = "struct asd { int x, y; };"
62+
"typedef struct asd* ptre;";
63+
std::string answ = "\ttype struct_asd = native.CStruct2[native.CInt, native.CInt]\n"
64+
"\ttype ptre = native.Ptr[struct_asd]\n";
65+
REQUIRE(answ == Translate(code));
66+
}
67+

0 commit comments

Comments
 (0)