-
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
Mar 4, 2021
1 parent
84cad35
commit 7978676
Showing
2 changed files
with
78 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* 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 bool operator == (Object other) | ||
* override | ||
* Equality for Pointers only depends on their address. | ||
* | ||
* @description Checks that equality for Pointers only depends on their address. | ||
* @author sgrekhov@unipro.ru | ||
*/ | ||
import "dart:ffi"; | ||
import '../ffi_utils.dart'; | ||
import '../../../Utils/expect.dart'; | ||
|
||
void main() { | ||
Pointer<Int8> p1 = calloc<Int8>(); | ||
Pointer<Int8> p2 = calloc<Int8>(); | ||
try { | ||
Expect.isFalse(p1 == p2); | ||
Expect.isTrue(p1 != p2); | ||
Pointer<Int8> p3 = new Pointer.fromAddress(p1.address); | ||
Expect.isTrue(p1 == p3); | ||
} finally { | ||
calloc.free(p1); | ||
calloc.free(p2); | ||
} | ||
} |
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,48 @@ | ||
/* | ||
* 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 bool operator == (Object other) | ||
* override | ||
* Equality for Pointers only depends on their address. | ||
* | ||
* @description Checks that equality for Pointers only depends on their address. | ||
* @author sgrekhov@unipro.ru | ||
*/ | ||
import "dart:ffi"; | ||
import '../ffi_utils.dart'; | ||
import '../../../Utils/expect.dart'; | ||
|
||
main() { | ||
Pointer<Int8> p1 = calloc(); | ||
try { | ||
Pointer<Int16> p2 = new Pointer.fromAddress(p1.address); | ||
Expect.isTrue(p1 == p2); | ||
Pointer<Int32> p3 = new Pointer.fromAddress(p1.address); | ||
Expect.isTrue(p1 == p3); | ||
Pointer<Int64> p4 = new Pointer.fromAddress(p1.address); | ||
Expect.isTrue(p1 == p4); | ||
Pointer<Uint8> p5 = new Pointer.fromAddress(p1.address); | ||
Expect.isTrue(p1 == p5); | ||
Pointer<Uint16> p6 = new Pointer.fromAddress(p1.address); | ||
Expect.isTrue(p1 == p6); | ||
Pointer<Uint32> p7 = new Pointer.fromAddress(p1.address); | ||
Expect.isTrue(p1 == p7); | ||
Pointer<Uint64> p8 = new Pointer.fromAddress(p1.address); | ||
Expect.isTrue(p1 == p8); | ||
Pointer<Float> p9 = new Pointer.fromAddress(p1.address); | ||
Expect.isTrue(p1 == p9); | ||
Pointer<Double> p10 = new Pointer.fromAddress(p1.address); | ||
Expect.isTrue(p1 == p10); | ||
Pointer<IntPtr> p11 = new Pointer.fromAddress(p1.address); | ||
Expect.isTrue(p1 == p11); | ||
Pointer<Pointer<Int32>> p12 = new Pointer.fromAddress(p1.address); | ||
Expect.isTrue(p1 == p12); | ||
Pointer<Array<Int32>> p13 = new Pointer.fromAddress(p1.address); | ||
Expect.isTrue(p1 == p13); | ||
} finally { | ||
calloc.free(p1); | ||
} | ||
} |