From e32df2043c295426a9317f41eab020c456982d4f Mon Sep 17 00:00:00 2001 From: Enkidu93 Date: Fri, 12 Jul 2024 17:09:17 -0400 Subject: [PATCH] Check for empty string --- src/SIL.Machine/Scripture/ScriptureRangeParser.cs | 5 +++++ .../SIL.Machine.Tests/Scripture/ScriptureRangeParserTests.cs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/SIL.Machine/Scripture/ScriptureRangeParser.cs b/src/SIL.Machine/Scripture/ScriptureRangeParser.cs index bad5211e0..ddd40ca50 100644 --- a/src/SIL.Machine/Scripture/ScriptureRangeParser.cs +++ b/src/SIL.Machine/Scripture/ScriptureRangeParser.cs @@ -151,6 +151,11 @@ public Dictionary> GetChapters(string chapterSelections) Dictionary> chaptersPerBook = new Dictionary>(); chapterSelections = chapterSelections.Trim(); + if (chapterSelections.Length == 0) + { + return chaptersPerBook; + } + char delimiter = ';'; if (chapterSelections.Contains(';')) { diff --git a/tests/SIL.Machine.Tests/Scripture/ScriptureRangeParserTests.cs b/tests/SIL.Machine.Tests/Scripture/ScriptureRangeParserTests.cs index efc597b01..13da8cabb 100644 --- a/tests/SIL.Machine.Tests/Scripture/ScriptureRangeParserTests.cs +++ b/tests/SIL.Machine.Tests/Scripture/ScriptureRangeParserTests.cs @@ -177,6 +177,7 @@ public static IEnumerable GetCases() new Dictionary> { { "JHN", new List() } }, false ); + yield return new TestCaseData("", new Dictionary>(), false); //*Throw exceptions yield return new TestCaseData("MAT3-1", new Dictionary>(), true); @@ -185,7 +186,6 @@ public static IEnumerable GetCases() yield return new TestCaseData("MAT0-10", new Dictionary>(), true); yield return new TestCaseData("MAT-FLUM", new Dictionary>(), true); yield return new TestCaseData("-MAT-FLUM", new Dictionary>(), true); - yield return new TestCaseData("", new Dictionary>(), true); yield return new TestCaseData("ABC", new Dictionary>(), true); yield return new TestCaseData("MAT-ABC", new Dictionary>(), true); yield return new TestCaseData("NT;-ABC-LUK", new Dictionary>(), true);