+2009-01-13 Jb Evain <jbevain@novell.com>
+
+ * Encoding.cs: when creating a ForwardingEncoder or a
+ ForwardingDecoder, don't crash if the Encoding doesn't
+ provide an EncoderFallback or a DecoderFallback.
Mon Oct 6 09:46:09 CEST 2008 Paolo Molaro <lupus@ximian.com>
{
encoding = enc;
#if NET_2_0
- Fallback = encoding.DecoderFallback;
+ DecoderFallback fallback = encoding.DecoderFallback;
+ if (fallback != null)
+ Fallback = fallback;
#endif
}
{
encoding = enc;
#if NET_2_0
- Fallback = encoding.EncoderFallback;
+ EncoderFallback fallback = encoding.EncoderFallback;
+ if (fallback != null)
+ Fallback = fallback;
#endif
}
+2009-01-13 Jb Evain <jbevain@novell.com>
+
+ * EncoderTest.cs: Make sure we can get an encoder for a custom
+ encoding.
+ * DecoderTest.cs: ditto.
+
2008-04-09 Atsushi Enomoto <atsushi@ximian.com>
* UTF7EncodingTest.cs : added test for broken GetCharCount() case.
Assert.AreEqual (625, charsUsed, "#2");
Assert.AreEqual (625, bytesUsed, "#3");
}
+
+
+ [Test]
+ public void CustomEncodingGetDecoder ()
+ {
+ var encoding = new CustomEncoding ();
+ var decoder = encoding.GetDecoder ();
+ Assert.IsNotNull (decoder);
+ }
+
+ class CustomEncoding : Encoding {
+
+ public override int GetByteCount (char [] chars, int index, int count)
+ {
+ throw new NotSupportedException ();
+ }
+
+ public override int GetBytes (char [] chars, int charIndex, int charCount, byte [] bytes, int byteIndex)
+ {
+ throw new NotSupportedException ();
+ }
+
+ public override int GetCharCount (byte [] bytes, int index, int count)
+ {
+ throw new NotSupportedException ();
+ }
+
+ public override int GetChars (byte [] bytes, int byteIndex, int byteCount, char [] chars, int charIndex)
+ {
+ throw new NotSupportedException ();
+ }
+
+ public override int GetMaxByteCount (int charCount)
+ {
+ throw new NotSupportedException ();
+ }
+
+ public override int GetMaxCharCount (int byteCount)
+ {
+ throw new NotSupportedException ();
+ }
+ }
#endif
}
}
Assert.AreEqual (625, bytesUsed, "#2");
Assert.AreEqual (625, charsUsed, "#3");
}
+
+ [Test]
+ public void CustomEncodingGetEncoder ()
+ {
+ var encoding = new CustomEncoding ();
+ var encoder = encoding.GetEncoder ();
+ Assert.IsNotNull (encoder);
+ }
+
+ class CustomEncoding : Encoding {
+
+ public override int GetByteCount (char [] chars, int index, int count)
+ {
+ throw new NotSupportedException ();
+ }
+
+ public override int GetBytes (char [] chars, int charIndex, int charCount, byte [] bytes, int byteIndex)
+ {
+ throw new NotSupportedException ();
+ }
+
+ public override int GetCharCount (byte [] bytes, int index, int count)
+ {
+ throw new NotSupportedException ();
+ }
+
+ public override int GetChars (byte [] bytes, int byteIndex, int byteCount, char [] chars, int charIndex)
+ {
+ throw new NotSupportedException ();
+ }
+
+ public override int GetMaxByteCount (int charCount)
+ {
+ throw new NotSupportedException ();
+ }
+
+ public override int GetMaxCharCount (int byteCount)
+ {
+ throw new NotSupportedException ();
+ }
+ }
#endif
}
}