aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/ProtocolBuffersLite.Test/TestUtil.cs
blob: 44c09b9c537edf5081f0b9c0d544d34d67c9f1ca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Google.ProtocolBuffers
{
    class TestUtil
    {
        internal static void AssertBytesEqual(byte[] a, byte[] b)
        {
            if (a == null || b == null)
            {
                Assert.AreEqual<object>(a, b);
            }
            else
            {
                Assert.AreEqual(a.Length, b.Length, "The byte[] is not of the expected length.");

                for (int i = 0; i < a.Length; i++)
                {
                    if (a[i] != b[i])
                    {
                        Assert.AreEqual(a[i], b[i], "Byte[] differs at index " + i);
                    }
                }
            }
        }

    }
}