コード例 #1
0
        public void Merge()
        {
            const int count = 32;
            var rand = new Random(2);

            var rs = new RegisterSet(count);
            var rss = new RegisterSet[5];

            for (var i = 0; i < rss.Length; ++i)
            {
                rss[i] = new RegisterSet(count);
                for (uint pos = 0; pos < rs.Count; ++pos)
                {
                    var val = (uint)rand.Next(10);
                    rs.UpdateIfGreater(pos, val);
                    rss[i].Set(pos, val);
                }
            }

            var merged = new RegisterSet(count);
            foreach (var t in rss)
                merged.Merge(t);

            for (uint pos = 0; pos < rs.Count; pos++)
                Assert.That(merged.Get(pos), Is.EqualTo(rs.Get(pos)));
        }
コード例 #2
0
 public void GetAndSet_AllPositions()
 {
     var rs = new RegisterSet(Pow(2, 4));
     for (uint i = 0; i < Pow(2, 4); ++i)
     {
         rs.Set(i, i % 31);
         Assert.That(rs.Get(i), Is.EqualTo(i % 31));
     }
 }
コード例 #3
0
 public void GetAndSet_WithSmallBits()
 {
     var rs = new RegisterSet(6);
     rs.Set(0, 11);
     Assert.That(rs.Get(0), Is.EqualTo(11));
 }
コード例 #4
0
 public void GetAndSet()
 {
     var rs = new RegisterSet(Pow(2, 4));
     rs.Set(0, 11);
     Assert.That(rs.Get(0), Is.EqualTo(11));
 }