Ejemplo n.º 1
0
        public static void DbFunctions_REPLACE()
        {
            DbFunctionTools tools = new DbFunctionTools();
            {
                Console.WriteLine("Testing DbFunctions.REPLACE(String,String,String)...");

                List <DbValue> args = new List <DbValue>();
                args.Add(tools.AllocValue(mstring.Prepare("apple is red")));
                args.Add(tools.AllocValue(mstring.Prepare("red")));
                args.Add(tools.AllocValue(mstring.Prepare("yellow")));
                DbFunctionArguments fargs = new DbFunctionArguments(args);

                DbValue   valOutput = DbFunctions.REPLACE(tools, fargs);
                ByteSlice bs        = valOutput.Eval();
                mstring   output    = tools.GetString(bs);

                mstring expected = mstring.Prepare("apple is yellow");

                if (expected != output)
                {
                    throw new Exception("DbFunctions.REPLACE(String,String,String) has failed.  Expected result: " + expected.ToString() + ", but received: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }

            {
                Console.WriteLine("Testing DbFunctions.REPLACE(String,String,String)...");

                List <DbValue> args = new List <DbValue>();
                args.Add(tools.AllocValue(mstring.Prepare("apple is red")));
                args.Add(tools.AllocValue(mstring.Prepare("black")));
                args.Add(tools.AllocValue(mstring.Prepare("yellow")));
                DbFunctionArguments fargs = new DbFunctionArguments(args);

                DbValue   valOutput = DbFunctions.REPLACE(tools, fargs);
                ByteSlice bs        = valOutput.Eval();
                mstring   output    = tools.GetString(bs);

                mstring expected = mstring.Prepare("apple is red");

                if (expected != output)
                {
                    throw new Exception("DbFunctions.REPLACE(String,String,String) has failed.  Expected result: " + expected.ToString() + ", but received: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }
        }
Ejemplo n.º 2
0
        public static void DbFunctions_SPACE()
        {
            DbFunctionTools tools = new DbFunctionTools();

            //String,Int32.
            {
                Console.WriteLine("Testing DbFunctions.SPACE(String)...");

                List <DbValue> args = new List <DbValue>();
                int            len  = 4;
                args.Add(tools.AllocValue(4));
                DbFunctionArguments fargs = new DbFunctionArguments(args);

                DbValue   valOutput = DbFunctions.SPACE(tools, fargs);
                ByteSlice bs        = valOutput.Eval();
                mstring   output    = tools.GetString(bs);

                mstring expected = mstring.Prepare("    ");

                if (expected != output)
                {
                    throw new Exception("DbFunctions.SPACE(String) has failed.  Expected result: " + expected.ToString() + ", but received: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }
        }
Ejemplo n.º 3
0
        public static void DbFunctions_RIGHT()
        {
            DbFunctionTools tools = new DbFunctionTools();

            //String,Int32.
            {
                Console.WriteLine("Testing DbFunctions.RIGHT(String,Int32)...");

                mstring        input = Utils.GenString(100);
                List <DbValue> args  = new List <DbValue>();
                args.Add(tools.AllocValue(input));
                args.Add(tools.AllocValue(5));
                DbFunctionArguments fargs = new DbFunctionArguments(args);

                DbValue   valOutput = DbFunctions.RIGHT(tools, fargs);
                ByteSlice bs        = valOutput.Eval();
                mstring   output    = tools.GetString(bs);

                string str      = input.ToString();
                string expected = str.Substring(str.Length - 5, 5);

                if (expected != output.ToString())
                {
                    throw new Exception("DbFunctions.RIGHT(String,Int32) has failed.  Expected result: " + expected.ToString() + ", but received: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }
        }
Ejemplo n.º 4
0
        public static void DbAggregators_LAST()
        {
            DbFunctionTools tools    = new DbFunctionTools();
            Random          rnd      = new Random();
            const int       rowcount = 20;

            //Double.
            {
                Console.WriteLine("Testing DbAggregators_LAST(Double)...");

                DbFunctionArguments[] fargs = new DbFunctionArguments[rowcount];
                double expected             = 0;

                for (int i = 0; i < fargs.Length; i++)
                {
                    double input = rnd.NextDouble();
                    if (input < 0.5)
                    {
                        input = input * -1d;
                    }
                    if (i == fargs.Length - 1)
                    {
                        expected = input;
                    }

                    List <DbValue> args = new List <DbValue>();
                    args.Add(tools.AllocValue(input));
                    fargs[i] = new DbFunctionArguments(args);
                }
                DbValue   valOutput = DbAggregators.LAST(tools, new DbAggregatorArguments(fargs));
                ByteSlice bs        = valOutput.Eval();
                double    output    = tools.GetDouble(bs);

                if (expected != output)
                {
                    throw new Exception("DbAggregators_LAST(Double) has failed.  Expected result: " + expected.ToString() + ", but received: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }

            {
                Console.WriteLine("Testing DbAggregators_LAST(Int32)...");

                DbFunctionArguments[] fargs = new DbFunctionArguments[rowcount];
                int expected = Int32.MaxValue;

                for (int i = 0; i < fargs.Length; i++)
                {
                    int input = rnd.Next(Int32.MinValue, Int32.MaxValue);
                    if (i == fargs.Length - 1)
                    {
                        expected = input;
                    }
                    List <DbValue> args = new List <DbValue>();
                    args.Add(tools.AllocValue(input));
                    fargs[i] = new DbFunctionArguments(args);
                }
                DbValue   valOutput = DbAggregators.LAST(tools, new DbAggregatorArguments(fargs));
                ByteSlice bs        = valOutput.Eval();
                int       output    = tools.GetInt(bs);

                if (expected != output)
                {
                    throw new Exception("DbAggregators_LAST(Int32) has failed.  Expected result: " + expected.ToString() + ", but received: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }

            {
                Console.WriteLine("Testing DbAggregators_LAST(Int64)...");

                DbFunctionArguments[] fargs = new DbFunctionArguments[rowcount];
                long expected = Int64.MaxValue;

                for (int i = 0; i < fargs.Length; i++)
                {
                    long input = DateTime.Now.Ticks;
                    if (input % 2 == 0)
                    {
                        input = input * -1;
                    }
                    if (i == fargs.Length - 1)
                    {
                        expected = input;
                    }
                    List <DbValue> args = new List <DbValue>();
                    args.Add(tools.AllocValue(input));
                    fargs[i] = new DbFunctionArguments(args);
                }
                DbValue   valOutput = DbAggregators.LAST(tools, new DbAggregatorArguments(fargs));
                ByteSlice bs        = valOutput.Eval();
                long      output    = tools.GetLong(bs);

                if (expected != output)
                {
                    throw new Exception("DbAggregators_LAST(Int64) has failed.  Expected result: " + expected.ToString() + ", but received: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }

            {
                Console.WriteLine("Testing DbAggregators_LAST(char(n))...");

                DbFunctionArguments[] fargs = new DbFunctionArguments[rowcount];
                string expected             = null;

                for (int i = 0; i < fargs.Length; i++)
                {
                    int     strlen = rnd.Next(1, 100);
                    mstring input  = Utils.GenString(strlen);
                    if (i == fargs.Length - 1)
                    {
                        expected = input.ToString();
                    }
                    List <DbValue> args = new List <DbValue>();
                    args.Add(tools.AllocValue(input));
                    fargs[i] = new DbFunctionArguments(args);
                }
                DbValue   valOutput = DbAggregators.LAST(tools, new DbAggregatorArguments(fargs));
                ByteSlice bs        = valOutput.Eval();
                mstring   output    = tools.GetString(bs);

                if (expected != output.ToString())
                {
                    throw new Exception("DbAggregators_LAST(char(n)) has failed.  Expected result: " + expected.ToString() + ", but received: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }
        }
Ejemplo n.º 5
0
        public static void DbFunctions_FORMAT()
        {
            DbFunctionTools tools = new DbFunctionTools();

            {
                Console.WriteLine("Testing DbFunctions.FORMAT('MM')...");

                List <DbValue> args      = new List <DbValue>();
                mstring        formatstr = mstring.Prepare("MM");
                args.Add(tools.AllocValue(formatstr));
                DateTime dt = new DateTime(2000, 9, 14, 12, 0, 0);
                args.Add(tools.AllocValue(dt));
                DbFunctionArguments fargs = new DbFunctionArguments(args);

                DbValue   valOutput = DbFunctions.FORMAT(tools, fargs);
                ByteSlice bs        = valOutput.Eval();
                mstring   output    = tools.GetString(bs);
                mstring   expected  = mstring.Prepare(dt.ToString(formatstr.ToString()));

                if (expected != output)
                {
                    throw new Exception("DbFunctions.FORMAT('MM') has failed.  Expected result: " + expected.ToString() + ", but received: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }

            {
                Console.WriteLine("Testing DbFunctions.FORMAT('dd')...");

                List <DbValue> args      = new List <DbValue>();
                mstring        formatstr = mstring.Prepare("dd");
                args.Add(tools.AllocValue(formatstr));
                DateTime dt = new DateTime(2000, 9, 14, 12, 0, 0);
                args.Add(tools.AllocValue(dt));
                DbFunctionArguments fargs = new DbFunctionArguments(args);

                DbValue   valOutput = DbFunctions.FORMAT(tools, fargs);
                ByteSlice bs        = valOutput.Eval();
                mstring   output    = tools.GetString(bs);
                mstring   expected  = mstring.Prepare(dt.ToString(formatstr.ToString()));

                if (expected != output)
                {
                    throw new Exception("DbFunctions.FORMAT('dd') has failed.  Expected result: " + expected.ToString() + ", but received: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }

            {
                Console.WriteLine("Testing DbFunctions.FORMAT('t')...");

                List <DbValue> args      = new List <DbValue>();
                mstring        formatstr = mstring.Prepare("t");
                args.Add(tools.AllocValue(formatstr));
                DateTime dt = new DateTime(2000, 9, 14, 12, 0, 0);
                args.Add(tools.AllocValue(dt));
                DbFunctionArguments fargs = new DbFunctionArguments(args);

                DbValue   valOutput = DbFunctions.FORMAT(tools, fargs);
                ByteSlice bs        = valOutput.Eval();
                mstring   output    = tools.GetString(bs);
                mstring   expected  = mstring.Prepare(dt.ToString(formatstr.ToString()));

                if (expected != output)
                {
                    throw new Exception("DbFunctions.FORMAT('t') has failed.  Expected result: " + expected.ToString() + ", but received: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }
        }
Ejemplo n.º 6
0
        public static void DbAggregators_BIT_AND()
        {
            DbFunctionTools tools    = new DbFunctionTools();
            Random          rnd      = new Random();
            const int       rowcount = 20;

            //Double.
            {
                Console.WriteLine("Testing DbAggregators_BIT_AND(Double)...");

                DbFunctionArguments[] fargs = new DbFunctionArguments[rowcount];
                double[] values             = new double[rowcount];

                for (int i = 0; i < fargs.Length; i++)
                {
                    double input = rnd.NextDouble();
                    if (input < 0.5)
                    {
                        input = input * -1d;
                    }
                    values[i] = input;
                    List <DbValue> args = new List <DbValue>();
                    args.Add(tools.AllocValue(input));
                    fargs[i] = new DbFunctionArguments(args);
                }
                DbValue   valOutput = DbAggregators.BIT_AND(tools, new DbAggregatorArguments(fargs));
                ByteSlice bs        = valOutput.Eval();
                double    output    = tools.GetDouble(bs);
                byte[]    expected  = bitop(values, 1);

                if (!compareBytes(expected, bs))
                {
                    throw new Exception("DbAggregators_BIT_AND(Double) has failed.");
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }

            {
                Console.WriteLine("Testing DbAggregators_BIT_AND(Int32)...");

                DbFunctionArguments[] fargs = new DbFunctionArguments[rowcount];
                int[] values = new int[rowcount];

                for (int i = 0; i < fargs.Length; i++)
                {
                    int input = rnd.Next(Int32.MinValue, Int32.MaxValue);
                    values[i] = input;
                    List <DbValue> args = new List <DbValue>();
                    args.Add(tools.AllocValue(input));
                    fargs[i] = new DbFunctionArguments(args);
                }
                DbValue   valOutput = DbAggregators.BIT_AND(tools, new DbAggregatorArguments(fargs));
                ByteSlice bs        = valOutput.Eval();
                int       output    = tools.GetInt(bs);
                byte[]    expected  = bitop(values, 1);
                if (!compareBytes(expected, bs))
                {
                    throw new Exception("DbAggregators_BIT_AND(Int32) has failed.");
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }

            {
                Console.WriteLine("Testing DbAggregators_BIT_AND(Int64)...");

                DbFunctionArguments[] fargs = new DbFunctionArguments[rowcount];
                long[] values = new long[rowcount];

                for (int i = 0; i < fargs.Length; i++)
                {
                    long input = DateTime.Now.Ticks;
                    if (input % 2 == 0)
                    {
                        input = input * -1;
                    }
                    values[i] = input;
                    List <DbValue> args = new List <DbValue>();
                    args.Add(tools.AllocValue(input));
                    fargs[i] = new DbFunctionArguments(args);
                }
                DbValue   valOutput = DbAggregators.BIT_AND(tools, new DbAggregatorArguments(fargs));
                ByteSlice bs        = valOutput.Eval();
                long      output    = tools.GetLong(bs);
                byte[]    expected  = bitop(values, 1);
                if (!compareBytes(expected, bs))
                {
                    throw new Exception("DbAggregators_BIT_AND(Int64) has failed.");
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }

            {
                Console.WriteLine("Testing DbAggregators_BIT_AND(char(n))...");

                DbFunctionArguments[] fargs  = new DbFunctionArguments[rowcount];
                mstring[]             values = new mstring[rowcount];

                for (int i = 0; i < fargs.Length; i++)
                {
                    int     strlen = 30;
                    mstring input  = Utils.GenString(strlen);
                    values[i] = input;
                    List <DbValue> args = new List <DbValue>();
                    args.Add(tools.AllocValue(input));
                    fargs[i] = new DbFunctionArguments(args);
                }
                DbValue   valOutput = DbAggregators.BIT_AND(tools, new DbAggregatorArguments(fargs));
                ByteSlice bs        = valOutput.Eval();
                mstring   output    = tools.GetString(bs);
                byte[]    expected  = bitop(values, 1);
                if (!compareBytes(expected, bs))
                {
                    throw new Exception("DbAggregators_BIT_AND(char(n)) has failed.");
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }
        }
Ejemplo n.º 7
0
        public static void DbAggregators_CHOOSERND()
        {
            DbFunctionTools tools    = new DbFunctionTools();
            Random          rnd      = new Random();
            const int       rowcount = 20;

            //Double.
            {
                Console.WriteLine("Testing DbAggregators_CHOOSERND(Double)...");

                DbFunctionArguments[]    fargs = new DbFunctionArguments[rowcount];
                Dictionary <double, int> dict  = new Dictionary <double, int>();

                for (int i = 0; i < fargs.Length; i++)
                {
                    double input = rnd.NextDouble();
                    if (input < 0.5)
                    {
                        input = input * -1d;
                    }
                    dict[input] = 1;
                    List <DbValue> args = new List <DbValue>();
                    args.Add(tools.AllocValue(input));
                    fargs[i] = new DbFunctionArguments(args);
                }
                DbValue   valOutput = DbAggregators.CHOOSERND(tools, new DbAggregatorArguments(fargs));
                ByteSlice bs        = valOutput.Eval();
                double    output    = tools.GetDouble(bs);

                if (!dict.ContainsKey(output))
                {
                    throw new Exception("DbAggregators_CHOOSERND(Double) has failed.  Value not found: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }

            {
                Console.WriteLine("Testing DbAggregators_CHOOSERND(Int32)...");

                DbFunctionArguments[] fargs = new DbFunctionArguments[rowcount];
                Dictionary <int, int> dict  = new Dictionary <int, int>();

                for (int i = 0; i < fargs.Length; i++)
                {
                    int input = rnd.Next(Int32.MinValue, Int32.MaxValue);
                    dict[input] = 1;
                    List <DbValue> args = new List <DbValue>();
                    args.Add(tools.AllocValue(input));
                    fargs[i] = new DbFunctionArguments(args);
                }
                DbValue   valOutput = DbAggregators.CHOOSERND(tools, new DbAggregatorArguments(fargs));
                ByteSlice bs        = valOutput.Eval();
                int       output    = tools.GetInt(bs);

                if (!dict.ContainsKey(output))
                {
                    throw new Exception("DbAggregators_CHOOSERND(Int32) has failed.  Value not found: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }

            {
                Console.WriteLine("Testing DbAggregators_CHOOSERND(Int64)...");

                DbFunctionArguments[]  fargs = new DbFunctionArguments[rowcount];
                Dictionary <long, int> dict  = new Dictionary <long, int>();

                for (int i = 0; i < fargs.Length; i++)
                {
                    long input = DateTime.Now.Ticks;
                    if (input % 2 == 0)
                    {
                        input = input * -1;
                    }
                    dict[input] = 1;
                    List <DbValue> args = new List <DbValue>();
                    args.Add(tools.AllocValue(input));
                    fargs[i] = new DbFunctionArguments(args);
                }
                DbValue   valOutput = DbAggregators.CHOOSERND(tools, new DbAggregatorArguments(fargs));
                ByteSlice bs        = valOutput.Eval();
                long      output    = tools.GetLong(bs);

                if (!dict.ContainsKey(output))
                {
                    throw new Exception("DbAggregators_CHOOSERND(Int64) has failed.  Value not found: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }

            {
                Console.WriteLine("Testing DbAggregators_CHOOSERND(char(n))...");

                DbFunctionArguments[]    fargs = new DbFunctionArguments[rowcount];
                Dictionary <string, int> dict  = new Dictionary <string, int>();

                for (int i = 0; i < fargs.Length; i++)
                {
                    int     strlen = rnd.Next(1, 100);
                    mstring input  = Utils.GenString(strlen);
                    dict[input.ToString()] = 1;
                    List <DbValue> args = new List <DbValue>();
                    args.Add(tools.AllocValue(input));
                    fargs[i] = new DbFunctionArguments(args);
                }
                DbValue   valOutput = DbAggregators.CHOOSERND(tools, new DbAggregatorArguments(fargs));
                ByteSlice bs        = valOutput.Eval();
                mstring   output    = tools.GetString(bs);

                if (!dict.ContainsKey(output.ToString()))
                {
                    throw new Exception("DbAggregators_CHOOSERND(char(n)) has failed.  Value not found: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }
        }
Ejemplo n.º 8
0
        public static void DbFunctions_LPAD()
        {
            DbFunctionTools tools = new DbFunctionTools();

            {
                Console.WriteLine("Testing DbFunctions.LPAD(String,Int32, String)...");

                List <DbValue> args = new List <DbValue>();
                args.Add(tools.AllocValue(mstring.Prepare("hello")));
                int len = 11;
                args.Add(tools.AllocValue(len));
                args.Add(tools.AllocValue(mstring.Prepare("xy")));
                DbFunctionArguments fargs = new DbFunctionArguments(args);

                DbValue   valOutput = DbFunctions.LPAD(tools, fargs);
                ByteSlice bs        = valOutput.Eval();
                mstring   output    = tools.GetString(bs);

                mstring expected = mstring.Prepare("xyxyxyhello");

                if (expected != output)
                {
                    throw new Exception("DbFunctions.LPAD(String,Int32, String) has failed.  Expected result: " + expected.ToString() + ", but received: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }

            {
                Console.WriteLine("Testing DbFunctions.LPAD(String,Int32, String)...");

                List <DbValue> args = new List <DbValue>();
                args.Add(tools.AllocValue(mstring.Prepare("hello")));
                int len = 10;
                args.Add(tools.AllocValue(len));
                args.Add(tools.AllocValue(mstring.Prepare("xy")));
                DbFunctionArguments fargs = new DbFunctionArguments(args);

                DbValue   valOutput = DbFunctions.LPAD(tools, fargs);
                ByteSlice bs        = valOutput.Eval();
                mstring   output    = tools.GetString(bs);

                mstring expected = mstring.Prepare("xyxyxhello");

                if (expected != output)
                {
                    throw new Exception("DbFunctions.LPAD(String,Int32, String) has failed.  Expected result: " + expected.ToString() + ", but received: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }

            {
                Console.WriteLine("Testing DbFunctions.LPAD(String,Int32, String)...");

                List <DbValue> args = new List <DbValue>();
                args.Add(tools.AllocValue(mstring.Prepare("hello")));
                int len = 5;
                args.Add(tools.AllocValue(len));
                args.Add(tools.AllocValue(mstring.Prepare("xy")));
                DbFunctionArguments fargs = new DbFunctionArguments(args);

                DbValue   valOutput = DbFunctions.LPAD(tools, fargs);
                ByteSlice bs        = valOutput.Eval();
                mstring   output    = tools.GetString(bs);

                mstring expected = mstring.Prepare("hello");

                if (expected != output)
                {
                    throw new Exception("DbFunctions.LPAD(String,Int32, String) has failed.  Expected result: " + expected.ToString() + ", but received: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }
            {
                Console.WriteLine("Testing DbFunctions.LPAD(String,Int32, String)...");

                List <DbValue> args = new List <DbValue>();
                args.Add(tools.AllocValue(mstring.Prepare("hello")));
                int len = 3;
                args.Add(tools.AllocValue(len));
                args.Add(tools.AllocValue(mstring.Prepare("xy")));
                DbFunctionArguments fargs = new DbFunctionArguments(args);

                DbValue   valOutput = DbFunctions.LPAD(tools, fargs);
                ByteSlice bs        = valOutput.Eval();
                mstring   output    = tools.GetString(bs);

                mstring expected = mstring.Prepare("hel");

                if (expected != output)
                {
                    throw new Exception("DbFunctions.LPAD(String,Int32, String) has failed.  Expected result: " + expected.ToString() + ", but received: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }
        }
Ejemplo n.º 9
0
        public static void DbFunctions_IIF()
        {
            DbFunctionTools tools = new DbFunctionTools();
            Random          rnd   = new Random();

            // int
            {
                Console.WriteLine("Testing DbFunctions.IIF(1, 'First', 'Second')...");

                List <DbValue> args = new List <DbValue>();
                args.Add(tools.AllocValue(1));
                args.Add(tools.AllocValue(mstring.Prepare("First")));
                args.Add(tools.AllocValue(mstring.Prepare("Second")));
                DbFunctionArguments fargs = new DbFunctionArguments(args);

                DbValue   valOutput = DbFunctions.IIF(tools, fargs);
                ByteSlice bs        = valOutput.Eval();
                mstring   output    = tools.GetString(bs);

                mstring expected = mstring.Prepare("First");

                if (expected != output)
                {
                    throw new Exception("DbFunctions.IIF(1, 'First', 'Second') has failed.  Expected result: " + expected.ToString() + ", but received: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }
            {
                Console.WriteLine("Testing DbFunctions.IIF(0, 'First', 'Second')...");

                List <DbValue> args = new List <DbValue>();
                args.Add(tools.AllocValue(0));
                args.Add(tools.AllocValue(mstring.Prepare("First")));
                args.Add(tools.AllocValue(mstring.Prepare("Second")));
                DbFunctionArguments fargs = new DbFunctionArguments(args);

                DbValue   valOutput = DbFunctions.IIF(tools, fargs);
                ByteSlice bs        = valOutput.Eval();
                mstring   output    = tools.GetString(bs);

                mstring expected = mstring.Prepare("Second");

                if (expected != output)
                {
                    throw new Exception("DbFunctions.IIF(0, 'First', 'Second') has failed.  Expected result: " + expected.ToString() + ", but received: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }
            {
                Console.WriteLine("Testing DbFunctions.IIF(42, 'First', 'Second')...");

                List <DbValue> args = new List <DbValue>();
                args.Add(tools.AllocValue(42));
                args.Add(tools.AllocValue(mstring.Prepare("First")));
                args.Add(tools.AllocValue(mstring.Prepare("Second")));
                DbFunctionArguments fargs = new DbFunctionArguments(args);

                DbValue   valOutput = DbFunctions.IIF(tools, fargs);
                ByteSlice bs        = valOutput.Eval();
                mstring   output    = tools.GetString(bs);

                mstring expected = mstring.Prepare("First");

                if (expected != output)
                {
                    throw new Exception("DbFunctions.IIF(42, 'First', 'Second') has failed.  Expected result: " + expected.ToString() + ", but received: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }

            // NULL
            {
                Console.WriteLine("Testing DbFunctions.IIF(NULL, 'First', 'Second')...");

                List <DbValue> args = new List <DbValue>();
                args.Add(tools.AllocNullValue());
                args.Add(tools.AllocValue(mstring.Prepare("First")));
                args.Add(tools.AllocValue(mstring.Prepare("Second")));
                DbFunctionArguments fargs = new DbFunctionArguments(args);

                DbValue   valOutput = DbFunctions.IIF(tools, fargs);
                ByteSlice bs        = valOutput.Eval();
                mstring   output    = tools.GetString(bs);

                mstring expected = mstring.Prepare("Second");

                if (expected != output)
                {
                    throw new Exception("DbFunctions.IIF(NULL, 'First', 'Second') has failed.  Expected result: " + expected.ToString() + ", but received: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }
        }