DecoderTest.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // DecoderTest.cs
  3. //
  4. // Author:
  5. // Atsushi Enomoto <[email protected]>
  6. //
  7. // (C) 2006 Novell, Inc.
  8. //
  9. using NUnit.Framework;
  10. using System;
  11. using System.Text;
  12. namespace MonoTests.System.Text
  13. {
  14. [TestFixture]
  15. public class DecoderTest
  16. {
  17. #if NET_2_0
  18. [Test]
  19. [ExpectedException (typeof (ArgumentNullException))]
  20. public void ConvertNullChars ()
  21. {
  22. int charsUsed, bytesUsed;
  23. bool done;
  24. Encoding.UTF8.GetDecoder ().Convert (
  25. null, 0, 100, new char [100], 0, 100, false,
  26. out charsUsed, out bytesUsed, out done);
  27. }
  28. [Test]
  29. [ExpectedException (typeof (ArgumentNullException))]
  30. public void ConvertNullBytes ()
  31. {
  32. int charsUsed, bytesUsed;
  33. bool done;
  34. Encoding.UTF8.GetDecoder ().Convert (
  35. new byte [100], 0, 100, null, 0, 100, false,
  36. out charsUsed, out bytesUsed, out done);
  37. }
  38. [Test]
  39. public void ConvertLimitedDestination ()
  40. {
  41. char [] chars = new char [10000];
  42. byte [] bytes = new byte [10000];
  43. Decoder conv = Encoding.UTF8.GetDecoder ();
  44. int charsUsed, bytesUsed;
  45. bool done;
  46. conv.Convert (bytes, 0, 10000, chars, 0, 1000, true,
  47. out charsUsed, out bytesUsed, out done);
  48. Assert.IsFalse (done, "#1");
  49. Assert.AreEqual (625, charsUsed, "#2");
  50. Assert.AreEqual (625, bytesUsed, "#3");
  51. }
  52. #endif
  53. }
  54. }