Esempio n. 1
0
        public void FallbackRecursiveError()
        {
            Buffer b = NewInstance();

            b.Fallback(new byte [] {}, 0);
            b.Fallback(new byte [] {}, 0);
        }
Esempio n. 2
0
        public void FallbackSequential()
        {
            Buffer b = NewInstance();

            b.Fallback(new byte [] {}, 0);
            b.GetNextChar();
            b.Fallback(new byte [] {}, 0);
        }
		public void FallbackEmptyForEncodingUTF8 ()
		{
			Buffer b = new DecoderReplacementFallbackBuffer (new DecoderReplacementFallback (String.Empty));
			Assert.IsFalse (b.Fallback (new byte [] {}, 0), "#1");
			Assert.IsFalse (b.MovePrevious (), "#2");
			Assert.AreEqual (0, b.Remaining, "#3");
			// the string does not exist.
			Assert.AreEqual (char.MinValue, b.GetNextChar (), "#4");
		}
Esempio n. 4
0
        public void FallbackDefaultEncodingUTF8()
        {
            Buffer b = Encoding.UTF8.DecoderFallback.CreateFallbackBuffer() as Buffer;

            Assert.IsTrue(b.Fallback(new byte [] {}, 0), "#1");
            Assert.IsFalse(b.MovePrevious(), "#2");
            Assert.AreEqual(1, b.Remaining, "#3");
            Assert.AreEqual('\uFFFD', b.GetNextChar(), "#4");
        }
Esempio n. 5
0
        public void FallbackEmptyDefault()
        {
            Buffer b = NewInstance();

            Assert.IsTrue(b.Fallback(new byte [] {}, 0), "#0");
            Assert.IsFalse(b.MovePrevious(), "#1");
            Assert.AreEqual(1, b.Remaining, "#2");
            Assert.AreEqual('?', b.GetNextChar(), "#3");
            Assert.AreEqual(0, b.Remaining, "#4");
            // the string is already consumed.
            Assert.AreEqual(char.MinValue, b.GetNextChar(), "#5");
        }
Esempio n. 6
0
        public void Iterate()
        {
            Assert.AreEqual('\0', Encoding.UTF8.DecoderFallback
                            .CreateFallbackBuffer().GetNextChar(), "#1");

            Buffer b = NewInstance();

//			Assert.AreEqual (1, b.Remaining, "#2");
//			Assert.AreEqual ('?', b.GetNextChar (), "#3");
            Assert.AreEqual(0, b.Remaining, "#4");
            Assert.AreEqual('\0', b.GetNextChar(), "#5");
//			Assert.IsTrue (b.MovePrevious (), "#6");
//			Assert.AreEqual (1, b.Remaining, "#7");
            Assert.IsFalse(b.MovePrevious(), "#8");
//			Assert.AreEqual ('?', b.GetNextChar (), "#9");
        }
Esempio n. 7
0
 public static double[][] binLoad_SGG_data(string fn)
 {
     System.IO.FileInfo fi =new System.IO.FileInfo(fn);
     long size = fi.Length/8/4;
     System.IO.Stream file = System.IO.File.Open(fn, System.IO.FileMode.Open);
     System.IO.BinaryReader br = new System.IO.BinaryReader(file);
     double[][] d = new double[size][];
        int nsize = 0;
     System.Text.DecoderReplacementFallbackBuffer fb = new DecoderReplacementFallbackBuffer(new DecoderReplacementFallback("x"));
     while ((br.BaseStream.Length - br.BaseStream.Position) > 8)
     {
         double d1=br.ReadDouble(),d2=br.ReadDouble(),d3=br.ReadDouble(),d4=br.ReadDouble();
         d[nsize] = new double[] { d1,d2,d3,d4};
         nsize++;
     }
     br.Close();
     file.Close();
     return d;
 }
		public void Reset ()
		{
			DecoderReplacementFallback f = new DecoderReplacementFallback ("X");
			DecoderReplacementFallbackBuffer b = new DecoderReplacementFallbackBuffer (f);
			b.Fallback (new byte [0], 0);
			Assert.AreEqual (1, b.Remaining, "#1");
			b.Reset ();
			Assert.AreEqual (0, b.Remaining, "#2");
			b.Fallback (new byte [0], 0); // do not raise an error
			b.Reset ();
			Assert.AreEqual (0, (int) b.GetNextChar (), "#3");
		}