b313bd8008c0b62363390ccd59044a05d5b1c73b
[mono.git] / mcs / class / corlib / Test / System.Text / UTF32EncodingTest.cs
1 using NUnit.Framework;
2 using System;
3 using System.Text;
4
5 #if NET_2_0
6
7 namespace MonoTests.System.Text {
8
9         [TestFixture]
10         public class UTF32EncodingTest : Assertion {
11
12                 [Test]
13                 public void TestGetPreamble() {
14                         byte[] lePreamble = new UTF32Encoding(false, true).GetPreamble();
15                         if (!AreEqual(lePreamble, new byte[]{ 0xff, 0xfe, 0, 0 })) {
16                                 Fail ("Little-endian UTF32 preamble is incorrect");
17                         }
18
19                         byte[] bePreamble = new UTF32Encoding(true, true).GetPreamble();
20                         if (!AreEqual(bePreamble, new byte[]{ 0, 0, 0xfe, 0xff })) {
21                                 Fail ("Big-endian UTF32 preamble is incorrect");
22                         }
23                 }
24
25                 private bool AreEqual(byte[] a, byte[] b) {
26                         if (a.Length != b.Length)
27                                 return false;
28                         for (int i = 0; i < a.Length; ++i) {
29                                 if (a[i] != b[i])
30                                         return false;
31                         }
32                         return true;
33                 }
34         }
35 }
36
37 #endif
38