diff --git a/src/FSharpAux/String.fs b/src/FSharpAux/String.fs index 61d9867..fc2b2c8 100644 --- a/src/FSharpAux/String.fs +++ b/src/FSharpAux/String.fs @@ -9,10 +9,17 @@ open System open System.Globalization module String = - - /// Checks whether the given text starts with the given prefix + + /// + /// Checks whether the given text starts with the given prefix. + /// let inline startsWith (prefix:string) (text:string) = text.StartsWith prefix + /// + /// Checks whether the given text ends with the given suffix. + /// + let inline endsWith (suffix : string) (str : string) = str.EndsWith suffix + /// Replaces the given "replacement" for every occurence of the pattern in the given text let inline replace (pattern:string) replacement (text:string) = text.Replace(pattern,replacement) diff --git a/tests/FSharpAux.Tests/StringTests.fs b/tests/FSharpAux.Tests/StringTests.fs index f57b99d..4f7d3be 100644 --- a/tests/FSharpAux.Tests/StringTests.fs +++ b/tests/FSharpAux.Tests/StringTests.fs @@ -6,6 +6,10 @@ open Expecto [] let stringTests = testList "StringTests" [ + testList "String.endsWith" [ + testCase "Returns correct bool" <| fun _ -> + Expect.isTrue (String.endsWith "World" "Hello World") "Returned incorrect bool" + ] testList "String.trim" [ testCase "trims input correctly" <| fun _ -> Expect.equal (String.trim " \tHi there!\n ") "Hi there!" "String.trim did not trim correctly"