예제 #1
0
        public void TestAllocThenAddData()
        {
            int maxId = 5000;

            int[] maxNumItems = { 25, 50, 20, 100, 15, 500, 10, 1000, 5, 1024, 2 };
            int[,] count = new int[maxNumItems.Length, maxId];
            AllocOnlyTestLoader loader = new AllocOnlyTestLoader(maxId);

            BigNestedIntArray[] nestedArray = new BigNestedIntArray[maxNumItems.Length];

            for (int i = 0; i < maxNumItems.Length; i++)
            {
                for (int id = 0; id < maxId; id++)
                {
                    int cnt = id % (maxNumItems[i] + 1);
                    loader.AddSize(id, cnt);
                    count[i, id] = cnt;
                }
                nestedArray[i] = new BigNestedIntArray();
                nestedArray[i].Load(maxId, loader);
                loader.Reset();

                for (int id = 0; id < maxId; id++)
                {
                    for (int data = 0; data < count[i, id]; data++)
                    {
                        nestedArray[i].AddData(id, data);
                    }
                }
            }

            for (int i = 0; i < maxNumItems.Length; i++)
            {
                int[] buf = new int[1024];
                for (int id = 0; id < maxId; id++)
                {
                    int cnt = nestedArray[i].GetData(id, buf);
                    Assert.AreEqual(count[i, id], cnt, "count[" + i + "," + id + "]");

                    if (cnt > 0)
                    {
                        for (int val = 0; val < cnt; val++)
                        {
                            Assert.AreEqual(val, buf[val], "item[" + i + "," + id + "," + val + "]");
                        }
                    }
                }
            }
        }
예제 #2
0
        public void TestMaxItems()
        {
            int maxId = 5000;

            int[] maxNumItems = { 25, 50, 20, 100, 15, 500, 10, 1000, 5, 1024, 2 };
            int[,] count = new int[maxNumItems.Length, maxId];
            AllocOnlyTestLoader loader = new AllocOnlyTestLoader(maxId);

            BigNestedIntArray[] nestedArray = new BigNestedIntArray[maxNumItems.Length];

            for (int i = 0; i < maxNumItems.Length; i++)
            {
                for (int id = 0; id < maxId; id++)
                {
                    int cnt = id % 2000;
                    loader.AddSize(id, cnt);
                    count[i, id] = cnt;
                }
                nestedArray[i]          = new BigNestedIntArray();
                nestedArray[i].MaxItems = maxNumItems[i];
                nestedArray[i].Load(maxId, loader);
                loader.Reset();

                for (int id = 0; id < maxId; id++)
                {
                    bool failed = false;
                    for (int data = 0; data < count[i, id]; data++)
                    {
                        if (nestedArray[i].AddData(id, data))
                        {
                            if (!failed && (data + 1 > maxNumItems[i]))
                            {
                                failed = true;
                                Assert.AreEqual(data, maxNumItems[i], "maxItems");
                            }
                        }
                    }
                }
            }
        }
        public void TestMaxItems()
        {
            int maxId = 5000;
            int[] maxNumItems = { 25, 50, 20, 100, 15, 500, 10, 1000, 5, 1024, 2 };
            int[,] count = new int[maxNumItems.Length, maxId];
            AllocOnlyTestLoader loader = new AllocOnlyTestLoader(maxId);
            BigNestedIntArray[] nestedArray = new BigNestedIntArray[maxNumItems.Length];
    
            for(int i = 0 ; i < maxNumItems.Length; i++)
            {
                for(int id = 0; id < maxId; id++)
                {
                    int cnt = id % 2000;
                    loader.AddSize(id, cnt);
                    count[i, id] = cnt;
                }
                nestedArray[i] = new BigNestedIntArray();
                nestedArray[i].MaxItems = maxNumItems[i];
                nestedArray[i].Load(maxId, loader);
                loader.Reset();

                for(int id = 0; id < maxId; id++)
                {
                    bool failed = false;
                    for(int data = 0; data < count[i, id]; data++)
                    {
                        if(nestedArray[i].AddData(id, data))
                        {
                            if(!failed && (data + 1 > maxNumItems[i]))
                            {
                                failed = true;
                                Assert.AreEqual(data, maxNumItems[i], "maxItems");
                            }
                        }
                    }
                }
            }
        }
        public void TestAllocThenAddData()
        {
            int maxId = 5000;
            int[] maxNumItems = { 25, 50, 20, 100, 15, 500, 10, 1000, 5, 1024, 2 };
            int[,] count = new int[maxNumItems.Length, maxId];
            AllocOnlyTestLoader loader = new AllocOnlyTestLoader(maxId);
            BigNestedIntArray[] nestedArray = new BigNestedIntArray[maxNumItems.Length];

            for(int i = 0 ; i < maxNumItems.Length; i++)
            {
                for(int id = 0; id < maxId; id++)
                {
                    int cnt = id % (maxNumItems[i] + 1);
                    loader.AddSize(id, cnt);
                    count[i, id] = cnt;
                }
                nestedArray[i] = new BigNestedIntArray();
                nestedArray[i].Load(maxId, loader);
                loader.Reset();

                for(int id = 0; id < maxId; id++)
                {
                    for(int data = 0; data < count[i, id]; data++)
                    {
                        nestedArray[i].AddData(id, data);
                    }
                }
            }

            for(int i = 0 ; i < maxNumItems.Length; i++)
            {
                int[] buf = new int[1024];
                for(int id = 0; id < maxId; id++)
                {
                    int cnt = nestedArray[i].GetData(id, buf);
                    Assert.AreEqual(count[i, id], cnt, "count[" + i + "," + id + "]");

                    if(cnt > 0)
                    {
                        for(int val = 0; val < cnt; val++)
                        {
                            Assert.AreEqual(val, buf[val], "item[" + i + "," + id + "," + val + "]");
                        }
                    }
                }
            }
        }