[feat]网络层增加Byte[]和ArraySegment的发送重载,直达底层,这是用户最常用的方法,也是性能最好的路径。
大石头 authored at 2024-11-19 10:06:42
1.75 KiB
X
using System;
using NewLife.Data;
using NewLife.Log;
using Xunit;

namespace XUnitTest.Expressions
{
    public class BinaryTreeTests
    {
        [Fact]
        public void Test1()
        {
            XTrace.WriteLine("开始二叉树运算");

            var nums = new Double[] { 5, 5, 5, 5 };
            var bt = new BinaryTree();
            var ss = bt.Execute(nums, 24);
            XTrace.WriteLine("共有结果:{0}", ss.Length);
            foreach (var item in ss)
            {
                XTrace.WriteLine(item);
            }
            Assert.Single(ss);
            Assert.Equal("((5 * 5) - (5 / 5))", ss[0]);
        }

        [Fact]
        public void Test2()
        {
            XTrace.WriteLine("开始二叉树运算");

            var nums = new Double[] { 1, 2, 3, 4 };
            var bt = new BinaryTree();
            var ss = bt.Execute(nums, 24);
            XTrace.WriteLine("共有结果:{0}", ss.Length);
            //foreach (var item in ss)
            //{
            //    XTrace.WriteLine(item);
            //}
            Assert.Equal(307, ss.Length);
            Assert.Equal("(4 * (1 + (2 + 3)))", ss[0]);
        }

        [Fact]
        public void Test22()
        {
            XTrace.WriteLine("开始二叉树运算");

            var nums = new Double[] { 1, 2, 3, 4 };
            var bt = new BinaryTree();
            bt.Operations.Add("Sqrt");
            //bt.Operations.Add("Cbrt");
            var ss = bt.Execute(nums, 24);
            XTrace.WriteLine("共有结果:{0}", ss.Length);
            //foreach (var item in ss)
            //{
            //    XTrace.WriteLine(item);
            //}

            Assert.Equal(654, ss.Length);
            Assert.Equal("(4 * (1 + (2 + 3)))", ss[0]);
        }
    }
}