Skip to content

Commit

Permalink
#993. Update tests description for Struct and Union tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov committed Jun 2, 2021
1 parent 096a068 commit 5edc943
Show file tree
Hide file tree
Showing 28 changed files with 105 additions and 48 deletions.
6 changes: 4 additions & 2 deletions LibTest/ffi/Struct/Struct_A01_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

/// @assertion All field declarations in a Struct subclass declaration must
/// either have type int or double and be annotated with a NativeType
/// representing the native type, or must be of type Pointer or subtype of Struct.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that it is a compile error if any of the field in Struct
/// subclass is not 'int', 'double' or 'Pointer' or subtype of 'Struct'
/// subclass is not 'int', 'double' or 'Pointer' or subtype of 'Struct' or
/// 'Union'
/// @author sgrekhov@unipro.ru
import "dart:ffi";
Expand Down
6 changes: 4 additions & 2 deletions LibTest/ffi/Struct/Struct_A01_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

/// @assertion All field declarations in a Struct subclass declaration must
/// either have type int or double and be annotated with a NativeType
/// representing the native type, or must be of type Pointer or subtype of Struct.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that it is a compile error if any of the field in Struct
/// subclass is not 'int', 'double' or 'Pointer' or subtype of 'Struct'
/// subclass is not 'int', 'double' or 'Pointer' or subtype of 'Struct' or
/// 'Union'
/// @author sgrekhov@unipro.ru
import "dart:ffi";
Expand Down
6 changes: 4 additions & 2 deletions LibTest/ffi/Struct/Struct_A01_t03.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

/// @assertion All field declarations in a Struct subclass declaration must
/// either have type int or double and be annotated with a NativeType
/// representing the native type, or must be of type Pointer or subtype of Struct.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that it is a compile error if any of the field in Struct
/// subclass is not 'int', 'double' or 'Pointer' or subtype of 'Struct'
/// subclass is not 'int', 'double' or 'Pointer' or subtype of 'Struct' or
/// 'Union'
/// @author sgrekhov@unipro.ru
/// @issue 44986
Expand Down
6 changes: 4 additions & 2 deletions LibTest/ffi/Struct/Struct_A01_t04.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

/// @assertion All field declarations in a Struct subclass declaration must
/// either have type int or double and be annotated with a NativeType
/// representing the native type, or must be of type Pointer or subtype of Struct.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that it is a compile error if any of the field in Struct
/// subclass is not 'int', 'double' or 'Pointer' or subtype of 'Struct'
/// subclass is not 'int', 'double' or 'Pointer' or subtype of 'Struct' or
/// 'Union'
/// @author sgrekhov@unipro.ru
import "dart:ffi";
Expand Down
6 changes: 4 additions & 2 deletions LibTest/ffi/Struct/Struct_A01_t05.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

/// @assertion All field declarations in a Struct subclass declaration must
/// either have type int or double and be annotated with a NativeType
/// representing the native type, or must be of type Pointer or subtype of Struct.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that it is a compile error if any of the field in Struct
/// subclass is not 'int', 'double' or 'Pointer' or subtype of 'Struct'
/// subclass is not 'int', 'double' or 'Pointer' or subtype of 'Struct' or
/// 'Union'
/// @author sgrekhov@unipro.ru
/// @issue 44985
Expand Down
25 changes: 19 additions & 6 deletions LibTest/ffi/Struct/Struct_A01_t06.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@

/// @assertion All field declarations in a Struct subclass declaration must
/// either have type int or double and be annotated with a NativeType
/// representing the native type, or must be of type Pointer or subtype of Struct.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that it is a compile error if any of the field in Struct
/// subclass is not 'int', 'double' or 'Pointer' or subtype of 'Struct'. Test
/// field of 'Union' and 'Struct' subclass type
/// @description Checks that it is not an error if all of the field in Struct
/// subclass are 'int', 'double', 'Pointer' or subtype of 'Struct' or 'Union'
/// @author sgrekhov@unipro.ru
/// @issue 46194
import "dart:ffi";
import "package:ffi/ffi.dart";
import "../../../Utils/expect.dart";

class U extends Union {
@Int32()
Expand All @@ -29,6 +30,11 @@ class S1 extends Struct {
@Int8()
external int i;

@Float()
external double d;

external Pointer<Int16> p;

external S s;

external U u;
Expand All @@ -38,7 +44,14 @@ void main() {
Pointer<S1> p = calloc<S1>();
S1 s1 = p.ref;
s1.u.x = 42;
print(s1.u.x);
Expect.equals(42, s1.u.x);
s1.s.y = -42;
print(s1.s.y);
Expect.equals(-42, s1.s.y);
s1.i = 1;
Expect.equals(1, s1.i);
s1.d = 3.14;
Expect.approxEquals(3.14, s1.d);
s1.p = calloc<Int16>();
s1.p.value = 13;
Expect.equals(13, s1.p.value);
}
3 changes: 2 additions & 1 deletion LibTest/ffi/Struct/Struct_A05_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/// @assertion All field declarations in a Struct subclass declaration must
/// either have type int or double and be annotated with a NativeType
/// representing the native type, or must be of type Pointer or subtype of Struct.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that 'Struct' subtype value depends on annotation
/// @author sgrekhov@unipro.ru
Expand Down
3 changes: 2 additions & 1 deletion LibTest/ffi/Struct/Struct_A05_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/// @assertion All field declarations in a Struct subclass declaration must
/// either have type int or double and be annotated with a NativeType
/// representing the native type, or must be of type Pointer or subtype of Struct.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that 'Struct' subtype value depends on annotation
/// @author sgrekhov@unipro.ru
Expand Down
3 changes: 2 additions & 1 deletion LibTest/ffi/Struct/Struct_A05_t03.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/// @assertion All field declarations in a Struct subclass declaration must
/// either have type int or double and be annotated with a NativeType
/// representing the native type, or must be of type Pointer or subtype of Struct.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that 'Struct' subtype value depends on annotation
/// @author sgrekhov@unipro.ru
Expand Down
3 changes: 2 additions & 1 deletion LibTest/ffi/Struct/Struct_A05_t04.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/// @assertion All field declarations in a Struct subclass declaration must
/// either have type int or double and be annotated with a NativeType
/// representing the native type, or must be of type Pointer or subtype of Struct.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that 'Struct' subtype value depends on annotation
/// @author sgrekhov@unipro.ru
Expand Down
3 changes: 2 additions & 1 deletion LibTest/ffi/Struct/Struct_A05_t05.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/// @assertion All field declarations in a Struct subclass declaration must
/// either have type int or double and be annotated with a NativeType
/// representing the native type, or must be of type Pointer or subtype of Struct.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that 'Struct' subtype value depends on annotation
/// @author sgrekhov@unipro.ru
Expand Down
3 changes: 2 additions & 1 deletion LibTest/ffi/Struct/Struct_A05_t06.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/// @assertion All field declarations in a Struct subclass declaration must
/// either have type int or double and be annotated with a NativeType
/// representing the native type, or must be of type Pointer or subtype of Struct.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that 'Struct' subtype value depends on annotation
/// @author sgrekhov@unipro.ru
Expand Down
3 changes: 2 additions & 1 deletion LibTest/ffi/Struct/Struct_A05_t07.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/// @assertion All field declarations in a Struct subclass declaration must
/// either have type int or double and be annotated with a NativeType
/// representing the native type, or must be of type Pointer or subtype of Struct.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that 'Struct' subtype value depends on annotation
/// @author sgrekhov@unipro.ru
Expand Down
3 changes: 2 additions & 1 deletion LibTest/ffi/Struct/Struct_A05_t08.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/// @assertion All field declarations in a Struct subclass declaration must
/// either have type int or double and be annotated with a NativeType
/// representing the native type, or must be of type Pointer or subtype of Struct.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that 'Struct' subtype value depends on annotation
/// @author sgrekhov@unipro.ru
Expand Down
5 changes: 3 additions & 2 deletions LibTest/ffi/Union/Union_A01_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

/// @assertion All field declarations in a Union subclass declaration must
/// either have type int or float and be annotated with a NativeType
/// representing the native type, or must be of type Pointer.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that it is a compile error if any of the field in Union
/// subclass is not 'int', 'double' or 'Pointer'
/// subclass is not 'int', 'double', 'Pointer' or subtype of Struct or Union
/// @author sgrekhov@unipro.ru
import "dart:ffi";
Expand Down
5 changes: 3 additions & 2 deletions LibTest/ffi/Union/Union_A01_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

/// @assertion All field declarations in a Union subclass declaration must
/// either have type int or float and be annotated with a NativeType
/// representing the native type, or must be of type Pointer.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that it is a compile error if any of the field in Union
/// subclass is not 'int', 'double' or 'Pointer'
/// subclass is not 'int', 'double', 'Pointer' or subtype of Struct or Union
/// @author sgrekhov@unipro.ru
import "dart:ffi";
Expand Down
5 changes: 3 additions & 2 deletions LibTest/ffi/Union/Union_A01_t03.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

/// @assertion All field declarations in a Union subclass declaration must
/// either have type int or float and be annotated with a NativeType
/// representing the native type, or must be of type Pointer.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that it is a compile error if any of the field in Union
/// subclass is not 'int', 'double' or 'Pointer'
/// subclass is not 'int', 'double', 'Pointer' or subtype of Struct or Union
/// @author sgrekhov@unipro.ru
import "dart:ffi";
Expand Down
5 changes: 3 additions & 2 deletions LibTest/ffi/Union/Union_A01_t04.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

/// @assertion All field declarations in a Union subclass declaration must
/// either have type int or float and be annotated with a NativeType
/// representing the native type, or must be of type Pointer.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that it is a compile error if any of the field in Union
/// subclass is not 'int', 'double' or 'Pointer'
/// subclass is not 'int', 'double', 'Pointer' or subtype of Struct or Union
/// @author sgrekhov@unipro.ru
import "dart:ffi";
Expand Down
5 changes: 3 additions & 2 deletions LibTest/ffi/Union/Union_A01_t05.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

/// @assertion All field declarations in a Union subclass declaration must
/// either have type int or float and be annotated with a NativeType
/// representing the native type, or must be of type Pointer.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that it is a compile error if any of the field in Union
/// subclass is not 'int', 'double' or 'Pointer'
/// subclass is not 'int', 'double', 'Pointer' or subtype of Struct or Union
/// @author sgrekhov@unipro.ru
import "dart:ffi";
Expand Down
25 changes: 19 additions & 6 deletions LibTest/ffi/Union/Union_A01_t06.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@

/// @assertion All field declarations in a Union subclass declaration must
/// either have type int or float and be annotated with a NativeType
/// representing the native type, or must be of type Pointer.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that it is a compile error if any of the field in Struct
/// subclass is not 'int', 'double' or 'Pointer'. Test
/// field of 'Union' and 'Struct' subclass type
/// @description Checks that it is not an error if all of the field in Union
/// subclass are 'int', 'double', 'Pointer' or subtype of Struct or Union
/// @author sgrekhov@unipro.ru
/// @issue 46194
import "dart:ffi";
import "package:ffi/ffi.dart";
import "../../../Utils/expect.dart";

class U extends Union {
@Int32()
Expand All @@ -29,6 +30,11 @@ class U1 extends Union {
@Int8()
external int i;

@Float()
external double d;

external Pointer<Int16> p;

external S s;

external U u;
Expand All @@ -38,7 +44,14 @@ void main() {
Pointer<U1> p = calloc<U1>();
U1 u1 = p.ref;
u1.u.x = 42;
print(u1.u.x);
Expect.equals(42, u1.u.x);
u1.s.y = -42;
print(u1.s.y);
Expect.equals(-42, u1.s.y);
u1.i = 1;
Expect.equals(1, u1.i);
u1.d = 3.14;
Expect.approxEquals(3.14, u1.d);
u1.p = calloc<Int16>();
u1.p.value = 13;
Expect.equals(13, u1.p.value);
}
3 changes: 2 additions & 1 deletion LibTest/ffi/Union/Union_A05_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/// @assertion All field declarations in a Union subclass declaration must
/// either have type int or float and be annotated with a NativeType
/// representing the native type, or must be of type Pointer.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that 'Union' subtype value depends on annotation
/// @author sgrekhov@unipro.ru
Expand Down
3 changes: 2 additions & 1 deletion LibTest/ffi/Union/Union_A05_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/// @assertion All field declarations in a Union subclass declaration must
/// either have type int or float and be annotated with a NativeType
/// representing the native type, or must be of type Pointer.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that 'Union' subtype value depends on annotation
/// @author sgrekhov@unipro.ru
Expand Down
3 changes: 2 additions & 1 deletion LibTest/ffi/Union/Union_A05_t03.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/// @assertion All field declarations in a Union subclass declaration must
/// either have type int or float and be annotated with a NativeType
/// representing the native type, or must be of type Pointer.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that 'Union' subtype value depends on annotation
/// @author sgrekhov@unipro.ru
Expand Down
3 changes: 2 additions & 1 deletion LibTest/ffi/Union/Union_A05_t04.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/// @assertion All field declarations in a Union subclass declaration must
/// either have type int or float and be annotated with a NativeType
/// representing the native type, or must be of type Pointer.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that 'Union' subtype value depends on annotation
/// @author sgrekhov@unipro.ru
Expand Down
3 changes: 2 additions & 1 deletion LibTest/ffi/Union/Union_A05_t05.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/// @assertion All field declarations in a Union subclass declaration must
/// either have type int or float and be annotated with a NativeType
/// representing the native type, or must be of type Pointer.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that 'Union' subtype value depends on annotation
/// @author sgrekhov@unipro.ru
Expand Down
3 changes: 2 additions & 1 deletion LibTest/ffi/Union/Union_A05_t06.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/// @assertion All field declarations in a Union subclass declaration must
/// either have type int or float and be annotated with a NativeType
/// representing the native type, or must be of type Pointer.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that 'Union' subtype value depends on annotation
/// @author sgrekhov@unipro.ru
Expand Down
3 changes: 2 additions & 1 deletion LibTest/ffi/Union/Union_A05_t07.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/// @assertion All field declarations in a Union subclass declaration must
/// either have type int or float and be annotated with a NativeType
/// representing the native type, or must be of type Pointer.
/// representing the native type, or must be of type Pointer or subtype of
/// Struct or Union.
///
/// @description Checks that 'Union' subtype value depends on annotation
/// @author sgrekhov@unipro.ru
Expand Down

0 comments on commit 5edc943

Please sign in to comment.