Skip to content

Commit

Permalink
Issue simc#57. Implement .slice() on string
Browse files Browse the repository at this point in the history
  • Loading branch information
mjstel committed Nov 30, 2020
1 parent 56643f9 commit f7046e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/src/string.dart
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ extension StringX on String {
/// Returns a new substring containing all characters between [start]
/// (inclusive) and [end] (inclusive).
/// If [end] is omitted, it is being set to `lastIndex`.
///
///
/// ```dart
/// print('awesomeString'.slice(0,6)); // awesome
/// print('awesomeString'.slice(7)); // String
Expand Down
14 changes: 7 additions & 7 deletions test/string_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,19 @@ void main() {
);
});

test('.slice()', (){
expect('awesomeString'.slice(0,6), 'awesome');
expect('awesomeString'.slice(0,-7), 'awesome');
test('.slice()', () {
expect('awesomeString'.slice(0, 6), 'awesome');
expect('awesomeString'.slice(0, -7), 'awesome');
expect('awesomeString'.slice(7), 'String');
expect('awesomeString'.slice(-6), 'String');
expect('awesomeString'.slice(-6, -1), 'String');
expect('awesomeString'.slice(-6,8), 'St');
expect('awesomeString'.slice(-6, 8), 'St');
expect('awesomeString'.slice(0), 'awesomeString');

expect(() => ''.slice(0), throwsRangeError);
expect(() => ''.slice(0,1), throwsRangeError);
expect(() => ''.slice(0, 1), throwsRangeError);
expect(() => ''.slice(-1), throwsRangeError);
expect(() => ''.slice(0,-1), throwsRangeError);
expect(() => ''.slice(0, -1), throwsRangeError);
expect(() => 'awesomeString'.slice(1, 13), throwsRangeError);
expect(() => 'awesomeString'.slice(2, 1), throwsRangeError);
expect(() => 'awesomeString'.slice(13), throwsRangeError);
Expand Down

0 comments on commit f7046e7

Please sign in to comment.