Esempio n. 1
0
        public void runUnit(Solution s)
        {
            for (int i = 0; i < _testNum; ++i) {
                IList<IList<int>> list = s.ThreeSum (_inputTest [i]);
                IList<IList<int>> result = _output[i];

                if (list.Count != result.Count) {
                    throw new Exception ("failed ---- " + i);
                }

                for(int j = 0; j < list.Count; ++j){
                    IList<int> l = list[j];
                    IList<int> r = result[j];

                    for(int k = 0; k < 3; ++k){
                        int lv = l.IndexOf (k), rv = r.IndexOf (k);
                        if (lv != rv) {
                            throw new Exception ("failed ---- " + i);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        public void runTwoSumTest(Solution s)
        {
            // 1
            //			int[] rray = { };
            //			int res = 0;

            // 2
            //			int[] rray = {1,1};
            //			int res = 2;

            // 3
            //			int[] rray = {1,1,2,2};
            //			int res = 3;

            // 4
            //			int[] rray = {1,1,1};
            //			int res = 2;

            // 5
            //			int[] rray = {1,2,4,3,5,6};
            //			int res = 7;

            // 6
            //			int[] rray = {1,2,4,3,5,6,1,2,4,3,5,6};
            //			int res = 7;

            //			int arrlen = rray.Length;
            //			s.TwoSumTest (rray, 0, res);
        }