Beispiel #1
0
		public void ReadNextText_MultilineTagStateFollowedByMedialTag_1stPartOf2ndLineText()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"\\tag\ntext \\tag more text"));
			SFMReader test = new SFMReader(stream);

			Assert.AreEqual("text ", test.ReadNextText());
			Assert.AreEqual("more text", test.ReadNextText());
		}
Beispiel #2
0
		public void ReadNextText_MultilineInitialTextStateFollowedByInitialTagThenText_2ndLineText()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"text first\n\\tag more text"));
			SFMReader test = new SFMReader(stream);

			Assert.AreEqual("more text", test.ReadNextText());
		}
Beispiel #3
0
		public void ReadNextText_MultilineInitialTextStateFollowedByTagOnly_Empty()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"text first\n\\tag"));
			SFMReader test = new SFMReader(stream);

			Assert.AreEqual(string.Empty, test.ReadNextText());
		}
Beispiel #4
0
		public void ReadNextText_MultilineInitialTextStateFollowedByEmpty_Null()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"text first\n"));
			SFMReader test = new SFMReader(stream);

			Assert.AreEqual("text first\n", test.ReadInitialText());
			Assert.IsNull(test.ReadNextText());
		}
Beispiel #5
0
		public void Offset_After3LetterTag4LetterWordAndASpace_10()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"\\tag text "));
			SFMReader test = new SFMReader(stream);
			test.ReadNextTag();
			test.ReadNextText();

			Assert.AreEqual(10, test.Offset);
		}
Beispiel #6
0
		public void Offset_After3LetterTagAfterEOF_4()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"\\tag"));
			SFMReader test = new SFMReader(stream);
			test.ReadNextTag();
			test.ReadNextText();

			Assert.AreEqual(4, test.Offset);
		}
Beispiel #7
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 #8
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);
		}
Beispiel #9
0
		public void ReadNextTextThenReadInitialText_Throw()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(@"\tag1 some text\tag2"));
			SFMReader test = new SFMReader(stream);
			test.ReadNextText();

			Assert.Throws<InvalidOperationException>(
				() => test.ReadInitialText());
		}
Beispiel #10
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 #11
0
		public void ReadNextText_TextOnly_Null()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					@"text first"));
			SFMReader test = new SFMReader(stream);

			Assert.IsNull(test.ReadNextText());
		}
Beispiel #12
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 #13
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 #14
0
		public void ReadNextText_MultilineEmptyFollowedByTag_Empty()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"\\tag\n\n\\tag"));
			SFMReader test = new SFMReader(stream);

			Assert.AreEqual("\n", test.ReadNextText());
		}
Beispiel #15
0
		public void ReadNextText_TwoTagsInARow_Empty()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					@"\tag1\tag2"));
			SFMReader test = new SFMReader(stream);

			string token = test.ReadNextText();
			Assert.AreEqual(string.Empty, token);
		}
Beispiel #16
0
		public void ReadNextText_NoText_Null()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					@""));
			SFMReader test = new SFMReader(stream);

			string token = test.ReadNextText();
			Assert.IsNull(token);
		}
Beispiel #17
0
		public void ReadNextText_TagOnly_Empty()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					@"\one"));
			SFMReader test = new SFMReader(stream);

			string token = test.ReadNextText();
			Assert.AreEqual("", token);
		}
Beispiel #18
0
		public void ReadNextText_TagLast_Empty()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					@"\one text first\two"));
			SFMReader test = new SFMReader(stream);

			test.ReadNextText();
			string token = test.ReadNextText();
			Assert.AreEqual(string.Empty, token);
		}
Beispiel #19
0
		public void ReadNextText_MedialText()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					@"\one text first\bf"));
			SFMReader test = new SFMReader(stream);

			string token = test.ReadNextText();
			Assert.AreEqual("text first", token);
		}
Beispiel #20
0
		public void ReadNextText_MultilineTagStateFollowedByEmpty_Null()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"\\tag\n"));
			SFMReader test = new SFMReader(stream);

			Assert.AreEqual(string.Empty, test.ReadNextText());
		}
Beispiel #21
0
		public void ReadNextText_MultilineTextStateFollowedByEmpty_1stAnd2ndLineText()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"\\tag text first\n"));
			SFMReader test = new SFMReader(stream);

			Assert.AreEqual("text first\n", test.ReadNextText());
		}