public void CopyTest() { var str1 = new StrWithCursor("te"); var str2 = new StrWithCursor(str1); str2++; Assert.AreEqual(true, str1 != str2); }
public void EqualWithCharOperatorTest() { var str1 = new StrWithCursor("t"); var symbol = 't'; Assert.AreEqual(true, str1 == symbol); symbol = 'e'; Assert.AreEqual(false, str1 == symbol); }
public void EqualOperatorTest() { var str1 = new StrWithCursor("te"); var str2 = new StrWithCursor("te"); Assert.AreEqual(true,str1==str2); str2++; Assert.AreEqual(false, str1 == str2); }
public void NonResultIncrementTest() { var str = new StrWithCursor("te"); Assert.AreEqual('t', str.Value); str++; Assert.AreEqual('e', str.Value); str++; Assert.AreEqual('e', str.Value); }
private void DeterminateTag(StrWithCursor pattern, StringBuilder tag) { do { tag.Append(pattern.Value); pattern++; }while (pattern != '>' && pattern != '*'); tag.Append(pattern.Value); pattern++; }
private void DeterminateNextTag(StrWithCursor fileName, StrWithCursor pattern, out Dictionary <FrameType, string> frames) { //TODO :: Why do we need to use a copy constructor? fileName = new StrWithCursor(fileName); pattern = new StrWithCursor(pattern); var tag = new StringBuilder(); //Detreminated tag var value = new StringBuilder(); //Determinated value while (fileName != '*' && pattern != '*' && fileName == pattern) //Go to first different symbol { fileName++; pattern++; } if (pattern == '<') { DeterminateTag(pattern, tag); } else { frames = null; return; //If this is not tag - error => return null } while (fileName != '*' || pattern == '*') { if (pattern == fileName) //Maybe it first symbol after tag { if (fileName == '*') //if end of string than this valid string { frames = new Dictionary <FrameType, string> { { Frame.GetEnum(tag.ToString()), value.ToString() } }; //Create and eturn them return; } DeterminateNextTag(fileName, pattern, out frames); //If not end of string, determinate next if (frames != null) //If recusive method returned non-null dictionary its actualy end of tag { frames.Add(Frame.GetEnum(tag.ToString()), value.ToString()); //We should return them return; } //If returned null, then this not end of string. Continue reading } value.Append(fileName.Value); fileName++; } frames = null; }
private void DeterminateNextTag(StrWithCursor fileName, StrWithCursor pattern, out Dictionary<FrameType, string> frames) { //TODO :: Why do we need to use a copy constructor? fileName = new StrWithCursor(fileName); pattern = new StrWithCursor(pattern); var tag = new StringBuilder(); //Detreminated tag var value = new StringBuilder(); //Determinated value while(fileName != '*' && pattern != '*' && fileName == pattern) //Go to first different symbol { fileName++; pattern++; } if (pattern == '<') DeterminateTag(pattern, tag); else { frames = null; return; //If this is not tag - error => return null } while (fileName!='*' || pattern=='*') { if(pattern==fileName) //Maybe it first symbol after tag { if (fileName == '*') //if end of string than this valid string { frames = new Dictionary<FrameType, string> {{Frame.GetEnum(tag.ToString()), value.ToString()}}; //Create and eturn them return; } DeterminateNextTag(fileName,pattern, out frames); //If not end of string, determinate next if (frames != null) //If recusive method returned non-null dictionary its actualy end of tag { frames.Add(Frame.GetEnum(tag.ToString()), value.ToString()); //We should return them return; } //If returned null, then this not end of string. Continue reading } value.Append(fileName.Value); fileName++; } frames = null; }
public List<FrameType> GetTags() { var pattern = new StrWithCursor(Pattern); var parsedTags = new SortedSet<FrameType>(); var tag = new StringBuilder(); while (pattern!='*') { if (pattern == '<') { DeterminateTag(pattern, tag); parsedTags.Add(Frame.GetEnum(tag.ToString())); tag.Clear(); } else pattern++; } return parsedTags.Count != 0 ? parsedTags.ToList() : null; }
public List <FrameType> GetTags() { var pattern = new StrWithCursor(Pattern); var parsedTags = new SortedSet <FrameType>(); var tag = new StringBuilder(); while (pattern != '*') { if (pattern == '<') { DeterminateTag(pattern, tag); parsedTags.Add(Frame.GetEnum(tag.ToString())); tag.Clear(); } else { pattern++; } } return(parsedTags.Count != 0 ? parsedTags.ToList() : null); }
public StrWithCursor(StrWithCursor input) { _str = input._str; _cursor = input._cursor; }
protected bool Equals(StrWithCursor other) { return string.Equals(_str, other._str) && _cursor == other._cursor; }
protected bool Equals(StrWithCursor other) { return(string.Equals(_str, other._str) && _cursor == other._cursor); }
private void DeterminateTag(StrWithCursor pattern, StringBuilder tag) { do { tag.Append(pattern.Value); pattern++; } while (pattern != '>' && pattern != '*'); tag.Append(pattern.Value); pattern++; }