2019-10-21 11:05:20 +00:00
|
|
|
// Copyright (c) 2019, 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.
|
|
|
|
//
|
2019-12-04 15:56:08 +00:00
|
|
|
// SharedObjects=ffi_test_functions
|
2019-10-21 11:05:20 +00:00
|
|
|
|
2019-12-04 15:56:08 +00:00
|
|
|
import 'dart:ffi';
|
2019-10-21 11:05:20 +00:00
|
|
|
|
2019-12-04 15:56:08 +00:00
|
|
|
import "package:expect/expect.dart";
|
2019-10-21 11:05:20 +00:00
|
|
|
|
2021-02-02 16:33:54 +00:00
|
|
|
import "coordinate.dart";
|
|
|
|
|
|
|
|
get is32Bit => 4 == sizeOf<IntPtr>();
|
|
|
|
get is64Bit => 8 == sizeOf<IntPtr>();
|
|
|
|
|
2019-12-04 15:56:08 +00:00
|
|
|
void main() async {
|
2021-02-02 16:33:54 +00:00
|
|
|
if (is32Bit) {
|
|
|
|
Expect.equals(4, sizeOf<Pointer>());
|
2021-02-03 10:21:08 +00:00
|
|
|
// Struct is 20 bytes on ia32 and arm32-iOS, but 24 bytes on arm32-Android
|
|
|
|
// and arm32-Linux due to alignment.
|
|
|
|
Expect.isTrue(20 == sizeOf<Coordinate>() || 24 == sizeOf<Coordinate>());
|
|
|
|
} else if (is64Bit) {
|
2021-02-02 16:33:54 +00:00
|
|
|
Expect.equals(8, sizeOf<Pointer>());
|
|
|
|
Expect.equals(24, sizeOf<Coordinate>());
|
|
|
|
}
|
|
|
|
Expect.throws(() => sizeOf<Void>());
|
2019-12-04 15:56:08 +00:00
|
|
|
}
|