-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sergey G. Grekhov
committed
Feb 8, 2021
1 parent
8187b21
commit 96137d0
Showing
6 changed files
with
87 additions
and
3 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,34 @@ | ||
/* | ||
* Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file | ||
* for details. All rights reserved. Use of this source code is governed by a | ||
* BSD-style license that can be found in the LICENSE file. | ||
*/ | ||
/** | ||
* @assertion int sizeOf <T extends NativeType>() | ||
* Number of bytes used by native type T. | ||
* | ||
* Includes padding and alignment of structs. | ||
* | ||
* @description Checks that this function returns Number of bytes used by native | ||
* type T | ||
* @author sgrekhov@unipro.ru | ||
*/ | ||
import "dart:ffi"; | ||
import '../../../Utils/expect.dart'; | ||
|
||
void main() { | ||
Expect.equals(1, sizeOf<Int8>()); | ||
Expect.equals(2, sizeOf<Int16>()); | ||
Expect.equals(4, sizeOf<Int32>()); | ||
Expect.equals(8, sizeOf<Int64>()); | ||
Expect.equals(8, sizeOf<Double>()); | ||
Expect.equals(4, sizeOf<Float>()); | ||
Expect.equals(1, sizeOf<Uint8>()); | ||
Expect.equals(2, sizeOf<Uint16>()); | ||
Expect.equals(4, sizeOf<Uint32>()); | ||
Expect.equals(8, sizeOf<Uint64>()); | ||
|
||
Expect.equals(8, sizeOf<IntPtr>()); | ||
Expect.equals(8, sizeOf<Pointer>()); | ||
Expect.equals(0, sizeOf<Struct>()); | ||
} |
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,28 @@ | ||
/* | ||
* Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file | ||
* for details. All rights reserved. Use of this source code is governed by a | ||
* BSD-style license that can be found in the LICENSE file. | ||
*/ | ||
/** | ||
* @assertion int sizeOf <T extends NativeType>() | ||
* Number of bytes used by native type T. | ||
* | ||
* Includes padding and alignment of structs. | ||
* | ||
* @description Checks that this function throws an exception if T is unsized | ||
* @author sgrekhov@unipro.ru | ||
*/ | ||
import "dart:ffi"; | ||
import '../../../Utils/expect.dart'; | ||
|
||
void main() { | ||
Expect.throws(() { | ||
sizeOf<Void>(); | ||
}); | ||
Expect.throws(() { | ||
sizeOf<NativeType>(); | ||
}); | ||
Expect.throws(() { | ||
sizeOf<NativeFunction>(); | ||
}); | ||
} |
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,22 @@ | ||
/* | ||
* Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file | ||
* for details. All rights reserved. Use of this source code is governed by a | ||
* BSD-style license that can be found in the LICENSE file. | ||
*/ | ||
/** | ||
* @assertion int sizeOf <T extends NativeType>() | ||
* Number of bytes used by native type T. | ||
* | ||
* Includes padding and alignment of structs. | ||
* | ||
* @description Checks that this function throws an exception if T is unsized | ||
* @author sgrekhov@unipro.ru | ||
*/ | ||
import "dart:ffi"; | ||
import '../../../Utils/expect.dart'; | ||
|
||
void main() { | ||
// TODO Support of non-constant type arguments of 'sizeOf' will be removed. | ||
// TODO Rewrite this test to expect a failure | ||
sizeOf<Handle>(); | ||
} |