Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
1
Task/Reverse-a-string/Dart/reverse-a-string-1.dart
Normal file
1
Task/Reverse-a-string/Dart/reverse-a-string-1.dart
Normal file
|
|
@ -0,0 +1 @@
|
|||
String reverse(String s) => new String.fromCharCodes(s.runes.toList().reversed);
|
||||
17
Task/Reverse-a-string/Dart/reverse-a-string-2.dart
Normal file
17
Task/Reverse-a-string/Dart/reverse-a-string-2.dart
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
String reverse(String s) => new String.fromCharCodes(s.runes.toList().reversed);
|
||||
|
||||
main() {
|
||||
group("Reverse a string -", () {
|
||||
test("Strings with ASCII characters are reversed correctly.", () {
|
||||
expect(reverse("hello, world"), equals("dlrow ,olleh"));
|
||||
});
|
||||
test("Strings with non-ASCII BMP characters are reversed correctly.", () {
|
||||
expect(reverse("\u4F60\u4EEC\u597D"), equals("\u597D\u4EEC\u4F60"));
|
||||
});
|
||||
test("Strings with non-BMP characters are reversed correctly.", () {
|
||||
expect(reverse("hello, \u{1F310}"), equals("\u{1F310} ,olleh"));
|
||||
});
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue