Esempio n. 1
0
        protected virtual void CheckBestPrices()
        {
            PrintImportant("Testing best prices...");
            double[] actualBestPrices = null;
            bool     actualBestPriceFound;

            for (int i = 0; i < testSize; i++)
            {
#if DEBUG
                PrintMessage("Testing vertex {0}", i);
#endif
                Exception exception;
                actualBestPriceFound = GetResult(() =>
                {
                    return(graph.findBestPrice(i, out actualBestPrices));
                }, out exception);
                if (exception != null)
                {
                    throw exception;
                }
                try
                {
                    CompareResult(expectedBestPrices[i], actualBestPrices, "Best prices");
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Esempio n. 2
0
        private static int performTestPart2(int testId, double [] expectedBestPrices, int currencyCount, int currency, ExchangePair [] exchanges)
        {
            double[]      bestPrices;
            CurrencyGraph cg     = new CurrencyGraph(currencyCount, exchanges);
            bool          result = cg.findBestPrice(currency, out bestPrices);

            bool success = result && bestPrices != null && bestPrices.Length == expectedBestPrices.Length;

            if (success)
            {
                for (int i = 0; i < bestPrices.Length; ++i)
                {
                    if (Math.Abs(bestPrices [i] - expectedBestPrices [i]) > 10e-8)
                    {
                        success = false;
                        break;
                    }
                }
            }

            Console.Write("Test #{0}: {1}", testId, success ? "SUCCESS" : "FAILURE");

            //if (!success)
            //	Console.Write (" (details: test result: [{0}]; expected result: [{1}])", string.Join(", ", bestPrices), string.Join(", ", expectedBestPrices));

            Console.WriteLine("");
            return(success ? 1 : 0);
        }