-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from kornilova-l/end-to-end-tests-for-unions
[WIP] End to end tests for unions
- Loading branch information
Showing
7 changed files
with
47 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "Union.h" | ||
#include <stdlib.h> | ||
|
||
void setIntValue(union values *v) { v->i = 10; } | ||
|
||
void setLongValue(union values *v) { v->l = 10000000000; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
union point { | ||
long a; | ||
int b; | ||
long long c; | ||
union values { | ||
long l; | ||
int i; | ||
long long ll; | ||
}; | ||
|
||
void setIntValue(union values *v); | ||
|
||
void setLongValue(union values *v); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
tests/samples/src/test/scala/org/scalanative/bindgen/samples/UnionTests.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.scalanative.bindgen.samples | ||
|
||
import utest._ | ||
import scala.scalanative.native._ | ||
import org.scalanative.bindgen.samples.UnionHelpers._ | ||
|
||
object UnionTests extends TestSuite { | ||
val tests = Tests { | ||
'getValues - { | ||
Zone {implicit zone => | ||
val structPtr = alloc[Union.union_values] | ||
Union.setIntValue(structPtr) | ||
assert(!structPtr.i == 10) | ||
Union.setLongValue(structPtr) | ||
assert(!structPtr.l == 10000000000L) | ||
} | ||
} | ||
} | ||
} |