public void Test_GetBytes() { var ansel = new AnselEncoding(); char[] chars = null; Assert.Throws(typeof(ArgumentNullException), () => { ansel.GetBytes(chars, 0, 0, null, 0); }); chars = new char[] { ' ' }; byte[] bytes = null; Assert.Throws(typeof(ArgumentNullException), () => { ansel.GetBytes(chars, 0, 0, bytes, 0); }); bytes = new byte[0]; Assert.Throws(typeof(ArgumentOutOfRangeException), () => { ansel.GetBytes(chars, -1, 0, bytes, 0); }); string s = null; Assert.Throws(typeof(ArgumentNullException), () => { ansel.GetBytes(s, 0, 0, null, 0); }); }
public void Test_Complex() { var ansel = new AnselEncoding(); Assert.IsNotNull(ansel); byte[] data; string res, sampleUnic, sampleAnsel; // code: E0 (Unicode: hook above, 0309)/low rising tone mark/ sampleAnsel = "αAαBαCαDαEαFαGαHαIαJαKαLαMαNαOαPαQαRαSαTαUαVαWαXαYαZ"; sampleUnic = "ẢB̉C̉D̉ẺF̉G̉H̉ỈJ̉K̉L̉M̉N̉ỎP̉Q̉R̉S̉T̉ỦV̉W̉X̉ỶZ̉"; //Assert.AreEqual(52, ansel.GetByteCount(sampleAnsel)); //chars = sampleUnic.ToCharArray(); //Assert.AreEqual(52, ansel.GetByteCount(chars, 0, chars.Length)); //Assert.AreEqual(52, ansel.GetByteCount(sampleUnic)); data = Encoding.GetEncoding(437).GetBytes(sampleAnsel); Assert.AreEqual(52, data.Length); res = ansel.GetString(data); Assert.AreEqual(sampleUnic, res); Assert.AreEqual(52, res.Length); res = ansel.GetString(data, 0, data.Length); Assert.AreEqual(sampleUnic, res); Assert.AreEqual(52, res.Length); data = ansel.GetBytes(res); res = Encoding.GetEncoding(437).GetString(data); Assert.AreEqual(sampleAnsel, res.Trim('\0')); //FIXME: ALERT! }