Beispiel #1
0
 public void TestArrayCountDuplicatesAndUnique()
 {
     int[] array = { 1, 2, 20, 2, 56, 1, 100, 320, 20, 400, 600 };
     int[] N     = W3Resource.ArrayCountDuplicatesAndUnique(array);
     Assert.AreEqual(N[0], 3);
     Assert.AreEqual(N[1], 5);
 }
Beispiel #2
0
 public void TestMergeTwoArraysAndOrderAscending()
 {
     int[] ary1   = { 1, 2, 3 };
     int[] ary2   = { 1, 2, 3 };
     int[] merged = W3Resource.MergeTwoArraysAndOrderAscending(ary1, ary2);
     int[] ary3   = { 1, 1, 2, 2, 3, 3 };
     Assert.AreEqual(merged, ary3);
 }
Beispiel #3
0
        public void TestArrayCopyContent()
        {
            int[] ary  = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            int[] ary1 = W3Resource.ArrayCopyContent(ary);

            for (int i = 0; i < ary.Length; i++)
            {
                Assert.AreEqual(ary[i], ary1[i]);
            }
        }
Beispiel #4
0
        public void TestFrequencyOfEachElementInArray()
        {
            int[] array = { 1, 2, 20, 2, 56, 1, 100, 320, 20, 400, 600 };
            var   freqs = W3Resource.FrequencyOfEachElementInArray(array);
            IDictionary <int, int> expfreqs = new Dictionary <int, int>();

            expfreqs.Add(1, 2);
            expfreqs.Add(2, 2);
            expfreqs.Add(20, 2);
            expfreqs.Add(56, 1);
            expfreqs.Add(100, 1);
            expfreqs.Add(320, 1);
            expfreqs.Add(400, 1);
            expfreqs.Add(600, 1);

            Assert.AreEqual(freqs, expfreqs);
        }