public void EncodeLine_Backslashes() { byte[] line = TempSFFileMaker.EncodeLine("abc" + @"\\" + "def", Encoding.ASCII); Assert.AreEqual(10, line.Length); int i = 0; Assert.AreEqual('a', line[i++]); Assert.AreEqual('b', line[i++]); Assert.AreEqual('c', line[i++]); Assert.AreEqual('\\', line[i++]); Assert.AreEqual('\\', line[i++]); Assert.AreEqual('d', line[i++]); Assert.AreEqual('e', line[i++]); Assert.AreEqual('f', line[i++]); Assert.AreEqual(s_cr, line[i++]); Assert.AreEqual(s_lf, line[i++]); TempSFFileMaker testFileMaker = new TempSFFileMaker(); string filename = testFileMaker.CreateFile("EPH", new[] { @"\v 1 c:\abc\def" }, Encoding.UTF8, false); using (TextReader reader = FileUtils.OpenFileForRead(filename, Encoding.UTF8)) { Assert.AreEqual(@"\id EPH", reader.ReadLine()); Assert.AreEqual(@"\v 1 c:\abc\def", reader.ReadLine()); } }
public void EncodeLine_ASCII() { byte[] line = TempSFFileMaker.EncodeLine("abcd", Encoding.ASCII); Assert.AreEqual(6, line.Length); int i = 0; Assert.AreEqual(97, line[i++]); Assert.AreEqual(98, line[i++]); Assert.AreEqual(99, line[i++]); Assert.AreEqual(100, line[i++]); Assert.AreEqual(s_cr, line[i++]); Assert.AreEqual(s_lf, line[i++]); }
public void EncodeLine_UTF8() { byte[] line = TempSFFileMaker.EncodeLine("abc" + '\u1234', Encoding.UTF8); Assert.AreEqual(8, line.Length); int i = 0; Assert.AreEqual(97, line[i++]); Assert.AreEqual(98, line[i++]); Assert.AreEqual(99, line[i++]); Assert.AreEqual(0xe1, line[i++]); Assert.AreEqual(0x88, line[i++]); Assert.AreEqual(0xb4, line[i++]); Assert.AreEqual(s_cr, line[i++]); Assert.AreEqual(s_lf, line[i++]); }
public void EncodeLine_BigEndianUnicode() { byte[] line = TempSFFileMaker.EncodeLine("abc" + '\u1234', Encoding.BigEndianUnicode); Assert.AreEqual(12, line.Length); int i = 0; Assert.AreEqual(0, line[i++]); Assert.AreEqual(97, line[i++]); Assert.AreEqual(0, line[i++]); Assert.AreEqual(98, line[i++]); Assert.AreEqual(0, line[i++]); Assert.AreEqual(99, line[i++]); Assert.AreEqual(0x12, line[i++]); Assert.AreEqual(0x34, line[i++]); Assert.AreEqual(0, line[i++]); Assert.AreEqual(s_cr, line[i++]); Assert.AreEqual(0, line[i++]); Assert.AreEqual(s_lf, line[i++]); }