File tree Expand file tree Collapse file tree 8 files changed +58
-0
lines changed
src/test/scala/org/scalanative/bindgen/samples Expand file tree Collapse file tree 8 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 1+ #include "Enum.h"
2+
3+ enum days get_WEDNESDAY () { return WEDNESDAY ; }
4+
5+ char * check_BIG_NEG_A (enum bigNegativeValues big_neg_a ) {
6+ if (big_neg_a == BIG_NEG_A ) {
7+ return "OK" ;
8+ }
9+ return "FAIL" ;
10+ }
Original file line number Diff line number Diff line change @@ -21,3 +21,7 @@ enum { // anonymous enum
2121enum negativeValues { NEG_A = -1 , NEG_B = -2 };
2222
2323enum bigNegativeValues { BIG_NEG_A = -10000000000 , BIG_NEG_B = -1 };
24+
25+ enum days get_WEDNESDAY ();
26+
27+ char * check_BIG_NEG_A (enum bigNegativeValues big_neg_a );
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ object Enum {
1010 type enum_bigValues = native.CUnsignedLong
1111 type enum_negativeValues = native.CInt
1212 type enum_bigNegativeValues = native.CLong
13+ def get_WEDNESDAY (): enum_days = native.extern
14+ def check_BIG_NEG_A (big_neg_a : enum_bigNegativeValues): native.CString = native.extern
1315}
1416
1517import Enum ._
Original file line number Diff line number Diff line change 1+ #include "Struct.h"
2+ #include <stdlib.h>
3+
4+ point_s getPoint () {
5+ point_s point = malloc (sizeof (struct point ));
6+ point -> x = 10 ;
7+ point -> y = 20 ;
8+ return point ;
9+ }
Original file line number Diff line number Diff line change @@ -4,3 +4,5 @@ struct point {
44};
55
66typedef struct point * point_s ;
7+
8+ point_s getPoint ();
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import scala.scalanative.native._
88object Struct {
99 type point_s = native.Ptr [struct_point]
1010 type struct_point = native.CStruct2 [native.CInt , native.CInt ]
11+ def getPoint (): native.Ptr [struct_point] = native.extern
1112}
1213
1314import Struct ._
Original file line number Diff line number Diff line change 1+ package org .scalanative .bindgen .samples
2+
3+ import utest ._
4+ import scalanative .native ._
5+
6+ object EnumTests extends TestSuite {
7+ val tests = Tests {
8+ ' get_WEDNESDAY - {
9+ assert(Enum .get_WEDNESDAY() == EnumEnums .enum_days_WEDNESDAY)
10+ }
11+
12+ ' check_BIG_NEG_A - {
13+ assert(Enum .check_BIG_NEG_A(EnumEnums .enum_bigNegativeValues_BIG_NEG_A) == c " OK " )
14+ }
15+ }
16+ }
Original file line number Diff line number Diff line change 1+ package org .scalanative .bindgen .samples
2+
3+ import utest ._
4+ import org .scalanative .bindgen .samples .StructHelpers ._
5+
6+ object StructTests extends TestSuite {
7+ val tests = Tests {
8+ ' getPoint - {
9+ val point = Struct .getPoint()
10+ assert(point.x == 10 )
11+ assert(point.y == 20 )
12+ }
13+ }
14+ }
You can’t perform that action at this time.
0 commit comments