-
Notifications
You must be signed in to change notification settings - Fork 56
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
1 parent
8eb98a5
commit b145c8f
Showing
9 changed files
with
98 additions
and
9 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
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,53 @@ | ||
// Copyright (c) 2024, 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. | ||
|
||
// Objective C support is only available on mac. | ||
@TestOn('mac-os') | ||
|
||
import 'dart:io'; | ||
|
||
import 'package:ffigen/src/code_generator/objc_built_in_functions.dart'; | ||
import 'package:test/test.dart'; | ||
import 'package:yaml/yaml.dart'; | ||
|
||
void main() { | ||
group('Verify interface lists', () { | ||
late List<String> yamlInterfaces; | ||
setUpAll(() { | ||
final yaml = loadYaml(File('ffigen_objc.yaml').readAsStringSync()); | ||
yamlInterfaces = yaml['objc-interfaces']['include'] | ||
.map<String>((dynamic i) => i as String) | ||
.toList() as List<String> | ||
..sort(); | ||
}); | ||
|
||
test('ObjCBuiltInFunctions.builtInInterfaces', () { | ||
expect(ObjCBuiltInFunctions.builtInInterfaces, yamlInterfaces); | ||
}); | ||
|
||
test('package:objective_c exports all the interfaces', () { | ||
final exportFile = File('lib/objective_c.dart').readAsStringSync(); | ||
for (final intf in yamlInterfaces) { | ||
expect(exportFile, contains(intf)); | ||
} | ||
}); | ||
|
||
test('All code genned interfaces are included in the list', () { | ||
final classNameRegExp = RegExp(r'^class (\w+) '); | ||
final allClassNames = <String>[]; | ||
for (final line in File('lib/src/objective_c_bindings_generated.dart') | ||
.readAsLinesSync()) { | ||
final match = classNameRegExp.firstMatch(line); | ||
if (match != null) { | ||
final className = match[1]!; | ||
if (!className.startsWith('ObjCBlock')) { | ||
allClassNames.add(className); | ||
} | ||
} | ||
} | ||
allClassNames.sort(); | ||
expect(allClassNames, yamlInterfaces); | ||
}); | ||
}); | ||
} |
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,27 @@ | ||
// Copyright (c) 2024, 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. | ||
|
||
// Objective C support is only available on mac. | ||
@TestOn('mac-os') | ||
|
||
import 'package:objective_c/objective_c.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group('NSString', () { | ||
for (final s in ['Hello', '🇵🇬', 'Embedded\u0000Null']) { | ||
test('NSString to/from Dart string [$s]', () { | ||
final ns1 = NSString(s); | ||
expect(ns1.length, s.length); | ||
expect(ns1.toString().length, s.length); | ||
expect(ns1.toString(), s); | ||
|
||
final ns2 = s.toNSString(); | ||
expect(ns2.length, s.length); | ||
expect(ns2.toString().length, s.length); | ||
expect(ns2.toString(), s); | ||
}); | ||
} | ||
}); | ||
} |
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