Beispiel #1
0
        public void ReadNextTag_TwoTagsInARow()
        {
            Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
                                                 @"\tag1\tag2"));
            SFMReader test = new SFMReader(stream);

            Assert.AreEqual("tag1", test.ReadNextTag());
            Assert.AreEqual("tag2", test.ReadNextTag());
        }
Beispiel #2
0
        public void ReadNextTag_FinalTag()
        {
            Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
                                                 @"\tag text first\bf"));
            SFMReader test = new SFMReader(stream);

            test.ReadNextTag();
            string token = test.ReadNextTag();

            Assert.AreEqual("bf", token);
        }
Beispiel #3
0
        public void ReadNextTag_MultilineTagModeFollowedByTextOnly_Null()
        {
            Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
                                                 "\\taginitial\nsome text"));
            SFMReader test = new SFMReader(stream);

            test.ReadNextTag();
            string token = test.ReadNextTag();

            Assert.IsNull(token);
        }
Beispiel #4
0
        public void ReadNextTag_AfterFinalText_Null()
        {
            Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
                                                 @"\bf text"));
            SFMReader test = new SFMReader(stream);

            test.ReadNextTag();
            string token = test.ReadNextTag();

            Assert.IsNull(token);
        }
Beispiel #5
0
        public void ReadNextTag_MultilineTagModeFollowedByTagOnly_2ndLineTag()
        {
            Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
                                                 "\\taginitial\n\\tag"));
            SFMReader test = new SFMReader(stream);

            test.ReadNextTag();
            string token = test.ReadNextTag();

            Assert.AreEqual("tag", token);
        }
Beispiel #6
0
        public void Offset_After3LetterTagAnd4LetterWordASpaceThen4LetterTag_15()
        {
            Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
                                                 "\\tag text \\tag2"));
            SFMReader test = new SFMReader(stream);

            test.ReadNextTag();
            test.ReadNextText();
            test.ReadNextTag();

            Assert.AreEqual(15, test.Offset);
        }
Beispiel #7
0
        public void ReadNextTextThenReadNextTag()
        {
            Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
                                                 @"\tag1 some text\tag2"));
            SFMReader test = new SFMReader(stream);

            test.ReadNextText();
            Assert.AreEqual("tag2", test.ReadNextTag());
        }
Beispiel #8
0
        public void DefaultMode_TagTerminiatedByAsterisk()
        {
            Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
                                                 @"\tag1*some text"));
            SFMReader test = new SFMReader(stream);

            Assert.AreEqual("tag1*some", test.ReadNextTag());
            Assert.AreEqual("text", test.ReadNextText());
        }
Beispiel #9
0
        public void ReadNextTagThenReadInitialText_Throw()
        {
            Stream    stream = new MemoryStream(Encoding.ASCII.GetBytes(@"\tag1 some text\tag2"));
            SFMReader test   = new SFMReader(stream);

            test.ReadNextTag();
            Assert.Throws <InvalidOperationException>(
                () => test.ReadInitialText());
        }
Beispiel #10
0
        public void Offset_After3LetterTagThenSpace_5()
        {
            Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
                                                 "\\tag "));
            SFMReader test = new SFMReader(stream);

            test.ReadNextTag();

            Assert.AreEqual(5, test.Offset);
        }
Beispiel #11
0
        public void ReadNextTag_EmptyTag()
        {
            Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
                                                 @"\ some text"));
            SFMReader test = new SFMReader(stream);

            string token = test.ReadNextTag();

            Assert.AreEqual(string.Empty, token);
        }
Beispiel #12
0
        public void ReadNextTag_MultilineEmptyFollowedByText_Null()
        {
            Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
                                                 "\ntext"));
            SFMReader test = new SFMReader(stream);

            string token = test.ReadNextTag();

            Assert.IsNull(token);
        }
Beispiel #13
0
        public void ReadNextTag_MultilineEmptyFollowedByTagThenText()
        {
            Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
                                                 "\n\\tag text"));
            SFMReader test = new SFMReader(stream);

            string token = test.ReadNextTag();

            Assert.AreEqual("tag", token);
        }
Beispiel #14
0
        public void ReadNextTag_MultilineInitialTextFollowedByTextThenTag()
        {
            Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
                                                 "initial text\ntext\\tag"));
            SFMReader test = new SFMReader(stream);

            string token = test.ReadNextTag();

            Assert.AreEqual("tag", token);
        }
Beispiel #15
0
        public void ReadNextTag_MultilineInitialTextFollowedByText()
        {
            Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
                                                 "initial text\nsome text"));
            SFMReader test = new SFMReader(stream);

            string token = test.ReadNextTag();

            Assert.IsNull(token);
        }
Beispiel #16
0
        public void UsfmMode_TagTerminiatedByAsterisk()
        {
            Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
                                                 @"\tag1*some text"));
            SFMReader test = new SFMReader(stream);

            test.Mode = SFMReader.ParseMode.Usfm;

            Assert.AreEqual("tag1*", test.ReadNextTag());
            Assert.AreEqual("some text", test.ReadNextText());
        }
Beispiel #17
0
        public void Offset_ShoeboxModeAfter4LetterTagWithStarAfterEOF_5()
        {
            Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
                                                 "\\tag*"));
            SFMReader test = new SFMReader(stream);

            test.Mode = SFMReader.ParseMode.Shoebox;
            test.ReadNextTag();
            test.ReadNextText();

            Assert.AreEqual(5, test.Offset);
        }
Beispiel #18
0
        public void ShoeboxMode_TagsWithoutNewline_TreatedAsText()
        {
            Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
                                                 @"\tag text first\bf"));
            SFMReader test = new SFMReader(stream);

            test.Mode = SFMReader.ParseMode.Shoebox;
            Assert.AreEqual("text first\\bf", test.ReadNextText());
            string token = test.ReadNextTag();

            Assert.IsNull(token);
        }