From f7411d5daa2b080bdda1144488cdad4c56e9c0e7 Mon Sep 17 00:00:00 2001 From: EoflaOE Date: Fri, 15 Oct 2021 09:37:21 +0300 Subject: [PATCH] Made version 2021.9.1 to implement repeating string 0 times --- Extensification.Tests/String.vb | 10 +++++++++- Extensification/Extensification.vbproj | 7 +++++-- Extensification/Texts/String/Manipulation.vb | 4 ++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Extensification.Tests/String.vb b/Extensification.Tests/String.vb index 9403444..cc00d20 100644 --- a/Extensification.Tests/String.vb +++ b/Extensification.Tests/String.vb @@ -161,13 +161,21 @@ Public Class StringTests End Sub ''' - ''' Tests reserving orders of characters in a string + ''' Tests repeating the string ''' Public Sub TestRepeat() Dim TargetString As String = "Hi! " Assert.AreEqual("Hi! Hi! Hi! ", TargetString.Repeat(3)) End Sub + ''' + ''' Tests repeating the string zero times + ''' + Public Sub TestRepeatZero() + Dim TargetString As String = "Hi! " + Assert.AreEqual("", TargetString.Repeat(0)) + End Sub + ''' ''' Tests retrieving substring ''' diff --git a/Extensification/Extensification.vbproj b/Extensification/Extensification.vbproj index 7bd3ea0..56be690 100644 --- a/Extensification/Extensification.vbproj +++ b/Extensification/Extensification.vbproj @@ -10,7 +10,7 @@ true EoflaOE EoflaOE - 2021.9 + 2021.9.1 Extensification is an extension pack to .NET Framework that extends your ability to use more functions on strings, integers, and objects. Initially, it started with the string, integer, double, long, dictionary, array, arraylist, and list extensions, and inherited from Kernel Simulator. Over time, it grows with support for more objects. en-US GPL-3.0-or-later @@ -19,7 +19,10 @@ https://github.com/EoflaOE/Extensification git extensions, extension methods - 2021.9: + 2021.9.1: +- Repeat is no longer strict about zeroes + +2021.9: - Added new extensions 2021.8: diff --git a/Extensification/Texts/String/Manipulation.vb b/Extensification/Texts/String/Manipulation.vb index cf4dee7..3779b92 100644 --- a/Extensification/Texts/String/Manipulation.vb +++ b/Extensification/Texts/String/Manipulation.vb @@ -155,9 +155,9 @@ Namespace StringExts Public Function Repeat(Str As String, Times As Long) As String If Str Is Nothing Then Throw New ArgumentNullException(NameOf(Str)) - If Times <= 0 Then Throw New ArgumentException("Zero or negative times aren't allowed.", NameOf(Str)) + If Times < 0 Then Throw New ArgumentException("Negative times isn't allowed.", NameOf(Str)) Dim Target As String = "" - For i As Long = 1 To Times + For i As Long = 0 To Times - 1 Target += Str Next Return Target