public void TestFindNextOccurrence4BitDigitSearchEmptyString() { Stream s = FourBitDigitBigArrayTests.convertStringTo4BitDigitStream(""); ; Assert.Throws <ArgumentException>(() => SearchString.FindNextOccurrence4BitDigit(s, "1", 0)); }
public void TestFindNextOccurrence4BitDigitLookForEmptyString() { const string STR = "123456789991234"; Stream s = FourBitDigitBigArrayTests.convertStringTo4BitDigitStream(STR); Assert.Throws <ArgumentException>(() => SearchString.FindNextOccurrence4BitDigit(s, "", 0)); }
public void TestFindNextOccurrence4BitDigitLookForLongerThanLeftInToSearch() { const string STR = "123456789991234"; Stream s = FourBitDigitBigArrayTests.convertStringTo4BitDigitStream(STR); Assert.AreEqual(-1, SearchString.FindNextOccurrence4BitDigit(s, "43", STR.Length - 1)); }
public void TestFindNextOccurrence4BitDigitSearchFullString() { const string STR = "123456789991234"; Stream s = FourBitDigitBigArrayTests.convertStringTo4BitDigitStream(STR); Assert.AreEqual(0, SearchString.FindNextOccurrence4BitDigit(s, STR, 0)); }
public void TestFindNextOccurrence4BitDigitSearchLastDigit() { const string STR = "123456789991234"; Stream s = FourBitDigitBigArrayTests.convertStringTo4BitDigitStream(STR); Assert.AreEqual(STR.Length - 1, SearchString.FindNextOccurrence4BitDigit(s, STR[STR.Length - 1].ToString(), STR.Length - 1)); Assert.AreEqual(-1, SearchString.FindNextOccurrence4BitDigit(s, "5", STR.Length - 1)); }
public void TestFindNextOccurrence4BitDigit() { const string STR = "123456789991234"; Stream s = FourBitDigitBigArrayTests.convertStringTo4BitDigitStream(STR); Dictionary <Tuple <string, long>, long> answers = new Dictionary <Tuple <string, long>, long>() { { Tuple.Create("1", 0L), 0 }, { Tuple.Create("2", 0L), 1 }, { Tuple.Create("123", 0L), 0 }, { Tuple.Create("1", 1L), 11 } }; foreach (KeyValuePair <Tuple <string, long>, long> kvp in answers) { string find = kvp.Key.Item1; long fromIdx = kvp.Key.Item2; long expected = kvp.Value; long actual = SearchString.FindNextOccurrence4BitDigit(s, find, fromIdx); Assert.AreEqual(expected, actual); } }