From f7046e7407d2a82e572a43f531dc80ac13ce14da Mon Sep 17 00:00:00 2001 From: Mirco Date: Mon, 30 Nov 2020 19:13:07 +0100 Subject: [PATCH] Issue #57. Implement .slice() on string --- lib/src/string.dart | 2 +- test/string_test.dart | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/src/string.dart b/lib/src/string.dart index e39ff20..4fafc88 100644 --- a/lib/src/string.dart +++ b/lib/src/string.dart @@ -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 diff --git a/test/string_test.dart b/test/string_test.dart index c3051d4..7a83aba 100644 --- a/test/string_test.dart +++ b/test/string_test.dart @@ -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);