Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test types that use native.CArray #90

Merged
merged 5 commits into from
Jul 2, 2018
Merged

Test types that use native.CArray #90

merged 5 commits into from
Jul 2, 2018

Conversation

kornilova203
Copy link
Member

Closes #89

@@ -10,5 +11,9 @@ object StructTests extends TestSuite {
assert(point.x == 10)
assert(point.y == 20)
}

'bigStructSize - {
assert(Struct.getBigStructSize() == sizeof[Struct.struct_bigStruct])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -13,6 +13,8 @@ object UnionTests extends TestSuite {
assert(!structPtr.i == 10)
Union.setLongValue(structPtr)
assert(!structPtr.l == 10000000000L)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed that the name could be better: unionPtr

@@ -13,6 +13,8 @@ object UnionTests extends TestSuite {
assert(!structPtr.i == 10)
Union.setLongValue(structPtr)
assert(!structPtr.l == 10000000000L)

assert(Union.getUnionSize() == sizeof[Union.union_values])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put it in a separate test case.

@@ -8,7 +8,9 @@ import scala.scalanative.native._
object Struct {
type struct_point = native.CStruct2[native.CInt, native.CInt]
type point_s = native.Ptr[struct_point]
type struct_bigStruct = native.CArray[Byte, native.Nat.Digit[native.Nat._1, native.Nat.Digit[native.Nat._1, native.Nat._2]]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, so this doesn't the helper with getters and setters. We should probably create a ticket for that.

@kornilova203
Copy link
Member Author

Found this issue #91
So to check inner anonymous struct I used Scala Native api for setting fields:

// ...
!anonymousStruct._1 = 'a'
val array = anonymousStruct.cast[Ptr[CArray[Byte, Nat._8]]]
!structWithAnonymousStruct._2 = !array

@kornilova203 kornilova203 changed the title [WIP] Test types that use native.CArray Test types that use native.CArray Jul 2, 2018
@kornilova203 kornilova203 merged commit 8c4f985 into master Jul 2, 2018
@kornilova203 kornilova203 deleted the size-in-bytes branch July 2, 2018 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants