Пример #1
0
 public void Test_S1ChordAngle_GetS2PointConstructorMaxError()
 {
     // Check that the error bound returned by GetS2PointConstructorMaxError() is
     // large enough.
     for (var iter = 0; iter < 100000; ++iter)
     {
         S2Testing.Random.Reset(iter);  // Easier to reproduce a specific case.
         var x = S2Testing.RandomPoint();
         var y = S2Testing.RandomPoint();
         if (S2Testing.Random.OneIn(10))
         {
             // Occasionally test a point pair that is nearly identical or antipodal.
             var r = S1Angle.FromRadians(S2.DoubleError * S2Testing.Random.RandDouble());
             y = S2.GetPointOnLine(x, y, r);
             if (S2Testing.Random.OneIn(2))
             {
                 y = -y;
             }
         }
         S1ChordAngle dist  = new(x, y);
         var          error = dist.GetS2PointConstructorMaxError();
         var          er1   = S2Pred.CompareDistance(x, y, dist.PlusError(error));
         if (er1 > 0)
         {
         }
         Assert.True(er1 <= 0);
         var er2 = S2Pred.CompareDistance(x, y, dist.PlusError(-error));
         if (er2 < 0)
         {
         }
         Assert.True(er2 >= 0);
     }
 }
Пример #2
0
    static void Main()
    {
        var s2 = new S2(1);

        S2Foo(in s2);
        Console.WriteLine(s2.A);
    }
Пример #3
0
    public static void Main()
    {
        S2 vr0 = new S2(new S1(1));

        System.Console.WriteLine(vr0.F0.F1);
        System.Console.WriteLine(vr0.F0.F2);
    }
Пример #4
0
    public static void Test()
    {
        S2 <int>    di = new S2 <int>();
        S2 <string> ds = new S2 <string>();
        S2 <object> d  = new S2 <object>();

        S1 <int>    s1i = new S1 <int>();
        S1 <string> s1s = new S1 <string>();
        S1 <object> s1  = new S1 <object>();


        I <S2 <int> >    is2i = s1i;
        I <S2 <string> > is2s = s1s;
        I <S2 <object> > is2  = s1;

        is2i.m(di);
        is2s.m(ds);
        is2.m(d);

        I <S1 <int> >    is1i = di;
        I <S1 <string> > is1s = ds;
        I <S1 <object> > is1  = d;

        is1i.m(s1i);
        is1s.m(s1s);
        is1.m(s1);
    }
Пример #5
0
	public static int Main ()
	{
		S? s = null;
		bool res = s > 1;
		if (res)
			return 1;

		S2 s2 = new S2 ();

		var b = s2 >> 3;
		if (b != 1250)
			return 2;

		var b2 = s2 >> s2;
		if (b2 != 0)
			return 3;

		var b3 = s2 + 1;
		if (b3 != 10001)
			return 4;

		var s3 = new S3 ();
		if ((s3 == null) != false)
			return 5;

		if ((s3 != null) != true)
			return 6;
		
		if (S3.counter != 2)
			return 7;

		Console.WriteLine ("ok");
		return 0;
	}
Пример #6
0
    // Returns the centroid of the shape multiplied by the measure of the shape,
    // which is defined as follows:
    //
    //  - For dimension 0 shapes, the measure is shape.num_edges().
    //  - For dimension 1 shapes, the measure is GetLength(shape).
    //  - For dimension 2 shapes, the measure is GetArea(shape).
    //
    // Note that the result is not unit length, so you may need to call
    // Normalize() before passing it to other S2 functions.
    //
    // The result is scaled by the measure defined above for two reasons: (1) it
    // is cheaper to compute this way, and (2) this makes it easier to compute the
    // centroid of a collection of shapes.  (This requires simply summing the
    // centroids of all shapes in the collection whose dimension is maximal.)
    public static S2Point GetCentroid(S2Shape shape)
    {
        var centroid = S2Point.Empty;

        S2Point[] vertices;
        int       dimension  = shape.Dimension();
        int       num_chains = shape.NumChains();

        for (int chain_id = 0; chain_id < num_chains; ++chain_id)
        {
            switch (dimension)
            {
            case 0:
                centroid += shape.GetEdge(chain_id).V0;
                break;

            case 1:
                GetChainVertices(shape, chain_id, out vertices);
                centroid += S2PolylineMeasures.GetCentroid(vertices);
                break;

            default:
                GetChainVertices(shape, chain_id, out vertices);
                centroid += S2.GetCentroid(vertices.ToList());
                break;
            }
        }
        return(centroid);
    }
Пример #7
0
	static int Main ()
	{
		var s = new S1 ();
		if (s.Value != 17)
			return 1;

		var s2 = new S2 ();
		if (s2.Value != 23)
			return 2;

		var s3 = new S3 ();
		if (s3.Value != 5)
			return 3;

		var s4 = new S4 (5);
		if (s4.Value != 11)
			return 4;

		var s5 = new S5 (2);
		if (s5.Value != 9)
			return 5;

		Console.WriteLine ("ok");
		return 0;
	}
Пример #8
0
        public override Task RunAsync(string[] args)
        {
            Output.Write("testing Equals() for Slice structures... ");
            Output.Flush();

            // Define some default values.
            var def_cls = new C(5);
            var def_s   = new S1("name");

            string[] def_ss = new string[] { "one", "two", "three" };
            int[]    def_il = new int[3] {
                1, 2, 3
            };
            var def_sd = new Dictionary <string, string>
            {
                { "abc", "def" }
            };
            var def_prx = IObjectPrx.Parse("test", Communicator);

            _ = new S2(true, 98, 99, 100, 101, 1.0f, 2.0, "string", def_ss, def_il, def_sd, def_s, def_cls, def_prx);

            // Compare default-constructed structures.
            Assert(new S2() == new S2());

            var s3     = new S3("foo", new int[] { 4, 7, 10 });
            var s3Copy = s3;

            Assert(s3 == s3Copy);
            Assert(s3.GetHashCode() == s3Copy.GetHashCode());
            s3Copy.IntList = new int[] { 4, 7, 10 };          // same values, different object
            Assert(s3 != s3Copy);
            Assert(s3.GetHashCode() != s3Copy.GetHashCode()); // can be the same, just unlikely
            Output.WriteLine("ok");
            return(Task.CompletedTask);
        }
Пример #9
0
    public static void Main()
    {
        S2 vr2 = new S2(new S1(new S0(true)));

        System.Console.WriteLine(vr2.F0.F0.F0);
        System.Console.WriteLine(vr2.F0.F0.F4);
    }
Пример #10
0
        public void testConversion()
        {
            // Test special cases: poles, "date line"
            assertDoubleNear(
                new S2LatLng(S2LatLng.FromDegrees(90.0, 65.0).ToPoint()).Lat.Degrees, 90.0);
            assertEquals(
                new S2LatLng(S2LatLng.FromRadians(-S2.PiOver2, 1).ToPoint()).Lat.Radians, -S2.PiOver2);
            assertDoubleNear(
                Math.Abs(new S2LatLng(S2LatLng.FromDegrees(12.2, 180.0).ToPoint()).Lng.Degrees), 180.0);
            assertEquals(
                Math.Abs(new S2LatLng(S2LatLng.FromRadians(0.1, -S2.Pi).ToPoint()).Lng.Radians),
                S2.Pi);

            // Test a bunch of random points.
            for (var i = 0; i < 100000; ++i)
            {
                var p = randomPoint();
                assertTrue(S2.ApproxEquals(p, new S2LatLng(p).ToPoint()));
            }

            // Test generation from E5
            var test = S2LatLng.FromE5(123456, 98765);

            assertDoubleNear(test.Lat.Degrees, 1.23456);
            assertDoubleNear(test.Lng.Degrees, 0.98765);
        }
Пример #11
0
    public static int Main()
    {
        S2 vr0 = new S2(new S1(new C0(), new S0(0)));

        M17(ref vr0.F0.F2.F4.F1);
        return(100);
    }
Пример #12
0
	public static int Main ()
	{
		if (P != 4)
			return 1;

		var c = new C ();
		if (c.P != -3)
			return 2;

		if (c.P2 != 1)
			return 3;

		c.P2 = 9;
		if (c.P2 != 9)
			return 4;

		var s = new S2 (null);
		if (s.P != 4)
			return 12;

		if (s.P2 != 1)
			return 13;

		s.P2 = 9;
		if (s.P2 != 9)
			return 14;

		return 0;
	}
Пример #13
0
 public void SetUp()
 {
     f  = new F();
     s  = new S();
     f2 = new F2();
     s2 = new S2();
 }
Пример #14
0
        private void StrictSetEqual <S1, S2>() where S1 : IStrictSet <int>, new() where S2 : IStrictSet <int>, new()
        {
            var s1 = new S1();
            var s2 = new S2();

            Fill(s1, 0, 10000);
            Fill(s2, 0, 5000);
            Assert.False(s1.IsEqualWith(s2));

            var s3 = new S1();
            var s4 = new S2();

            Fill(s3, 0, 1000);
            Fill(s4, 0, 1000);
            Assert.True(s3.IsEqualWith(s4));

            var s5 = new S1();
            var s6 = new S2();

            Fill(s5, 0, 1000);
            Fill(s6, 1000, 1000);
            Assert.False(s5.IsEqualWith(s6));

            var s7 = new S1();
            var s8 = new S2();

            Fill(s7, 0, 1000);
            Fill(s8, 0, 1999);
            Assert.False(s7.IsEqualWith(s8));

            var s9  = new S1();
            var s10 = new S2();

            Assert.True(s9.IsEqualWith(s10));
        }
Пример #15
0
    public static void Main()
    {
        S2 vr0 = new S2(new S1(true, new S0()));

        System.Console.WriteLine(vr0.F0.F2);
        System.Console.WriteLine(vr0.F0.F3);
    }
Пример #16
0
        private void StrictSetDisjoint <S1, S2>() where S1 : IStrictSet <int>, new() where S2 : IStrictSet <int>, new()
        {
            var s1 = new S1();
            var s2 = new S2();

            Fill(s1, 0, 1000);
            Fill(s2, 1000, 2000);
            Assert.True(s1.IsDisjointWith(s2));

            var s3 = new S1();
            var s4 = new S2();

            Fill(s3, 0, 2000);
            Fill(s4, 1000, 2000);
            Assert.False(s3.IsDisjointWith(s4));

            var s5 = new S1();
            var s6 = new S2();

            Assert.True(s5.IsDisjointWith(s6));

            var s7 = new S1();
            var s8 = new S2();

            Fill(s7, 0, 1000);
            Assert.True(s7.IsDisjointWith(s8));
            Assert.True(s8.IsDisjointWith(s7));
        }
Пример #17
0
    private static S2Point PerturbATowardsB(S2Point a, S2Point b)
    {
        var choice = S2Testing.Random.RandDouble();

        if (choice < 0.1)
        {
            return(a);
        }
        if (choice < 0.3)
        {
            // Return a point that is exactly proportional to A and that still
            // satisfies S2.IsUnitLength().
            for (; ;)
            {
                var b2 = (2 - a.Norm() + 5 * (S2Testing.Random.RandDouble() - 0.5) * S2.DoubleEpsilon) * a;
                if (b2 != a && b2.IsUnitLength())
                {
                    return(b2);
                }
            }
        }
        if (choice < 0.5)
        {
            // Return a point such that the distance squared to A will underflow.
            return(S2.InterpolateAtDistance(S1Angle.FromRadians(1e-300), a, b));
        }
        // Otherwise return a point whose distance from A is near S2Constants.DoubleEpsilon such
        // that the log of the pdf is uniformly distributed.
        double distance = S2.DoubleEpsilon * 1e-5 * Math.Pow(1e6, S2Testing.Random.RandDouble());

        return(S2.InterpolateAtDistance(S1Angle.FromRadians(distance), a, b));
    }
Пример #18
0
        private async void ScrollViewViewChanging(object sender, ScrollViewerViewChangingEventArgs e)
        {
            try
            {
                var sc = sender as ScrollViewer;
                HandleGoUpRefreshButtons(sc);
                if (sc.VerticalOffset >= GridMainScrollViewer.ActualHeight && !tryingEnableSCs)
                {
                    tryingEnableSCs = true;
                    sc.DisableScroll();
                    S1?.EnableScroll();
                    S2?.EnableScroll();
                    //isMainScrollEnabled = false;
                    ("DISABELING SC MAIN").PrintDebug();
                    GridMainScrollViewer.Height = 0;
                    //SCMain.ChangeView(null, GridMainScrollViewer.ActualHeight, null);
                    try
                    {
                        await Task.Delay(40);

                        S1?.ChangeView(null, lastSC1Offset, null);
                        S2?.ChangeView(null, lastSC2Offset, null);
                    }
                    catch { }
                    await Task.Delay(500);

                    tryingEnableSCs = false;
                }
            }
            catch { }
        }
Пример #19
0
    public static int Main()
    {
        S?s = new S();

        foreach (var a in s)
        {
        }

        if (DisposeCounter != 1)
        {
            return(1);
        }

        S2?s2 = new S2();

        foreach (var a in s2)
        {
        }

        if (DisposeCounter != 2)
        {
            return(2);
        }

        return(0);
    }
Пример #20
0
        private static void allTests(Communicator communicator)
        {
            Console.Out.Write("testing equals() for Slice structures... ");
            Console.Out.Flush();

            //
            // Define some default values.
            //
            C  def_cls = new C(5);
            S1 def_s   = new S1("name");

            string[] def_ss = new string[] { "one", "two", "three" };
            int[]    def_il = new int[3];
            def_il[0] = 1;
            def_il[1] = 2;
            def_il[2] = 3;
            var def_sd = new Dictionary <string, string>();

            def_sd.Add("abc", "def");
            var def_prx = IObjectPrx.Parse("test", communicator);

            _ = new S2(true, 98, 99, 100, 101, 1.0f, 2.0, "string", def_ss, def_il, def_sd, def_s, def_cls, def_prx);

            //
            // Compare default-constructed structures.
            //
            {
                Assert(new S2().Equals(new S2()));
            }

            Console.Out.WriteLine("ok");
        }
Пример #21
0
        public void assign_s2()
        {
            S2 v = new S2(1, 2, 3, 4);

            check_s2(v, 1, 2, 3, 4);

            v.a = null;                  check_s2(v, null, 2, 3, 4);
            v.a = 5;                     check_s2(v, 5, 2, 3, 4);
            v.SetA(null);              check_s2(v, null, 2, 3, 4);
            v.SetA(6);                 check_s2(v, 6, 2, 3, 4);

            v.b = null;                  check_s2(v, 6, null, 3, 4);
            v.b = 7;                     check_s2(v, 6, 7, 3, 4);
            v.SetB(null);              check_s2(v, 6, null, 3, 4);
            v.SetB(8);                 check_s2(v, 6, 8, 3, 4);

            v.c = null;                  check_s2(v, 6, 8, null, 4);
            v.c = 9;                     check_s2(v, 6, 8, 9, 4);
            v.SetC(null);              check_s2(v, 6, 8, null, 4);
            v.SetC(10);                check_s2(v, 6, 8, 10, 4);

            v.d = null;                  check_s2(v, 6, 8, 10, null);
            v.d = 11;                    check_s2(v, 6, 8, 10, 11);
            v.SetD(null);              check_s2(v, 6, 8, 10, null);
            v.SetD(12);                check_s2(v, 6, 8, 10, 12);
        }
Пример #22
0
        internal static Task UnitTest2Async()
        {
            using var mem = new MemoryStream();
            var serializer = new S2(mem);

            return(UnitTestAsync(serializer, mem));
        }
        /// <summary>
        /// Asserts that the documents returned by <code>q1</code>
        /// are a subset of those returned by <code>q2</code>.
        ///
        /// Both queries will be filtered by <code>filter</code>
        /// </summary>
        protected internal virtual void AssertSubsetOf(Query q1, Query q2, Filter filter)
        {
            // TRUNK ONLY: test both filter code paths
            if (filter != null && Random().NextBoolean())
            {
                q1     = new FilteredQuery(q1, filter, TestUtil.RandomFilterStrategy(Random()));
                q2     = new FilteredQuery(q2, filter, TestUtil.RandomFilterStrategy(Random()));
                filter = null;
            }

            // not efficient, but simple!
            TopDocs td1 = S1.Search(q1, filter, Reader.MaxDoc);
            TopDocs td2 = S2.Search(q2, filter, Reader.MaxDoc);

            Assert.IsTrue(td1.TotalHits <= td2.TotalHits);

            // fill the superset into a bitset
            BitArray bitset = new BitArray(td2.ScoreDocs.Length);

            for (int i = 0; i < td2.ScoreDocs.Length; i++)
            {
                bitset.Set(td2.ScoreDocs[i].Doc, true);
            }

            // check in the subset, that every bit was set by the super
            for (int i = 0; i < td1.ScoreDocs.Length; i++)
            {
                Assert.IsTrue(bitset.Get(td1.ScoreDocs[i].Doc));
            }
        }
Пример #24
0
        public int CompareTo(HexWeight other)
        {
            int cs0 = S0.CompareTo(other.S0); if (cs0 != 0)
            {
                return(cs0);
            }
            int cs1 = S1.CompareTo(other.S1); if (cs1 != 0)
            {
                return(cs1);
            }
            int cs2 = S2.CompareTo(other.S2); if (cs2 != 0)
            {
                return(cs2);
            }
            int cs3 = S3.CompareTo(other.S3); if (cs3 != 0)
            {
                return(cs3);
            }
            int cs4 = S4.CompareTo(other.S4); if (cs4 != 0)
            {
                return(cs4);
            }
            int cs5 = S5.CompareTo(other.S5); if (cs5 != 0)

            {
                return(cs5);
            }

            return(0);
        }
Пример #25
0
        internal static void UnitTest2()
        {
            using var mem = new MemoryStream();
            var serializer = new S2(mem);

            UnitTest(serializer, mem);
        }
Пример #26
0
    public static void Main()
    {
        S2 vr0 = new S2(new S1(1, new S0(0)));

        System.Console.WriteLine(vr0.F0.F0);
        System.Console.WriteLine(vr0.F0.F2.F0);
    }
Пример #27
0
        public void CalculateTest()
        {
            Input input = new Input
            {
                Set         = 1,
                HargaKainA  = 32,
                Lebar       = 110,
                Tinggi      = 104,
                HargaCincin = 7,
                Layout      = "T",
            };

            IFormula formula = new S2();
            Output   actual  = formula.Calculate(input);

            Assert.AreEqual(actual.Jumlah, 392.72);
            Assert.AreEqual(actual.UpahKainA, 18);
            Assert.AreEqual(actual.UpahCincin, 67.20);
            Assert.AreEqual(actual.HargaKainA, 307.52);
            Assert.AreEqual(actual.Keping, 6);
            Assert.AreEqual(actual.TailorTotalKeping, 6);
            Assert.AreEqual(actual.TailorKeping, 3);
            Assert.AreEqual(actual.TailorMeterA, 4.44);
            Assert.AreEqual(actual.TailorKepingA, 2);
            Assert.IsTrue(actual.DetailedBreakdown.Contains("Jumlah"));
            Assert.IsTrue(actual.DetailedBreakdown.Contains("Harga"));

            input.Layout = "L";
            actual       = formula.Calculate(input);

            Assert.AreEqual(actual.TailorKeping, 6);
            Assert.AreEqual(actual.TailorMeterA, 8.75);
            Assert.AreEqual(actual.TailorKepingA, 1);
        }
Пример #28
0
    // Returns the point at distance "r" from A along the line AB.
    //
    // Note that the line AB has a well-defined direction even when A and B are
    // antipodal or nearly so.  If A == B then an arbitrary direction is chosen.
    public static S2Point GetPointOnLine(S2Point a, S2Point b, S1Angle r)
    {
        // See comments above.
        S2Point dir = S2.RobustCrossProd(a, b).CrossProd(a).Normalize();

        return(GetPointOnRay(a, dir, r));
    }
Пример #29
0
    // Returns the pair of points (a, b) that achieves the minimum distance
    // between edges a0a1 and b0b1, where "a" is a point on a0a1 and "b" is a
    // point on b0b1.  If the two edges intersect, "a" and "b" are both equal to
    // the intersection point.  Handles a0 == a1 and b0 == b1 correctly.
    public static (S2Point, S2Point) GetEdgePairClosestPoints(S2Point a0, S2Point a1, S2Point b0, S2Point b1)
    {
        if (S2.CrossingSign(a0, a1, b0, b1) > 0)
        {
            S2Point x = S2.GetIntersection(a0, a1, b0, b1, null);
            return(x, x);
        }
        // We save some work by first determining which vertex/edge pair achieves
        // the minimum distance, and then computing the closest point on that edge.
        var min_dist = S1ChordAngle.Zero;

        AlwaysUpdateMinDistance(a0, b0, b1, ref min_dist, true);

        var closest_vertex = 0;

        if (UpdateMinDistance(a1, b0, b1, ref min_dist))
        {
            closest_vertex = 1;
        }
        if (UpdateMinDistance(b0, a0, a1, ref min_dist))
        {
            closest_vertex = 2;
        }
        if (UpdateMinDistance(b1, a0, a1, ref min_dist))
        {
            closest_vertex = 3;
        }
        return(closest_vertex switch
        {
            0 => (a0, Project(a0, b0, b1)),
            1 => (a1, Project(a1, b0, b1)),
            2 => (Project(b0, a0, a1), b0),
            3 => (Project(b1, a0, a1), b1),
            _ => throw new ApplicationException("Unreached (to suppress Android compiler warning)"),
        });
Пример #30
0
        private void form_services_Load(object sender, EventArgs e)
        {
            AddS.Enabled    = true;
            Reset.Enabled   = true;
            EditS.Enabled   = false;
            DeleteS.Enabled = false;
            loadAll();
            S1.Hide();
            S2.Hide();
            label1.Hide();
            label2.Hide();



            string select = "SELECT max(trt_id) from dc_trtmnt";

            conn.Open();
            MySqlCommand     comm = new MySqlCommand(select, conn);
            MySqlDataAdapter adp  = new MySqlDataAdapter(comm);

            comm.ExecuteNonQuery();
            conn.Close();
            DataTable dt = new DataTable();

            adp.Fill(dt);
            if (dt.Rows.Count == 1)
            {
                int treat_id = (int)dt.Rows[0][0];
                int add1     = treat_id + 1;
                label1.Text    = "SC0" + add1;
                src_id.Text    = label1.Text;
                src_id.Enabled = false;
            }
        }
Пример #31
0
    public static void Main()
    {
        S2 vr3 = new S2(new S1(new S0(1)));

        System.Console.WriteLine(vr3.F0.F1.F1);
        System.Console.WriteLine(vr3.F0.F1.F3);
    }
Пример #32
0
    public short Method7(S1 p_s1_194, S2 p_s2_195, ref S2 p_s2_196, ref S2 p_s2_197, S1 p_s1_198, out S1 p_s1_199, S2 p_s2_200, S2 p_s2_201)
    {
        unchecked
        {
            short short_207 = 2;
            int   int_208   = 0;
            switch (int_208 << int_25 + s_int_9)
            {
            case 1:
            {
                break;
            }

            case 5:
            {
                break;
            }

            case 2:
            {
                break;
            }

            default:
            {
                s_s1_17 = s1_33;
                break;
            }
            }
            return(short_207);
        }
    }
Пример #33
0
 void TestProjectUnproject(Projection projection, R2Point px, S2Point x)
 {
     // The arguments are chosen such that projection is exact, but
     // unprojection may not be.
     Assert.Equal(px, projection.Project(x));
     Assert.True(S2.ApproxEquals(x, projection.Unproject(px)));
 }
Пример #34
0
 public void TestPassNestedStructAsObjectWithMutation() {
     Func<int> f = () => {
         var s2 = new S2 { x = 1, s = new S2A { y = 2 } };
         var r = MutateS2(s2);
         return r + s2.x + s2.s.y;
     };
     this.Test(f);
 }
Пример #35
0
	public static void Main ()
	{
		S s = new S ();
		int b = s.Prop ();
		string bb = s.Prop;
		
		S2 s2 = new S2 ();
		int b2 = s2.Prop ();
		bool bb2 = s2.Prop;
	}
Пример #36
0
	public static int Main ()
	{
		S? s = new S ();
		S? s2 = null;
		S? s4 = null;

		if ((s == s2) != false)
			return 1;

		if ((s2 == s) != false)
			return 2;

		if ((s2 == s4) != true)
			return 3;

		S x = new S ();

		if ((s2 == x) != false)
			return 5;

		if ((x == s2) != false)
			return 6;

		S2? s2_1 = new S2 ();
		S2? s2_3 = new S2 ();
		S2 x2 = new S2 ();

		if ((s2_1 == s2_3) != true)
			return 7;

		if ((s2_1 == x2) != true)
			return 8;

		if ((x2 == s2_1) != true)
			return 9;

		if (S2.counter != 3)
			return 10;

		S3 s3;

		if ((s3 == null) != true)
			return 20;

		if ((null == s3) != true)
			return 21;

		if (S3.counter != 2)
			return 22;

		return 0;
	}
Пример #37
0
        public void DescribeTo()
        {
            P1 p1 = new P1();
            P2 p2 = new P2();
            S1 s1 = new S1();
            S2 s2 = new S2();

            this.testee.Register(p1);
            this.testee.Register(p2);
            this.testee.Register(s1);
            this.testee.Register(s2);

            StringWriter writer = new StringWriter();
            this.testee.DescribeTo(writer);

            writer.Close();
            writer.ToString();
        }
Пример #38
0
	public static int Main ()
	{
		S1? s1 = new S1 ();
		switch (s1) {
		case 1:
			break;
		default:
			return 1;
		}

		S2? s2 = new S2 ();
		switch (s2) {
		case null:
			break;
		default:
			return 2;
		}

		S3? s3 = new S3 ();
		switch (s3) {
		case 2:
			break;
		default:
			return 3;
		}

		S4 s4 = new S4 ();
		switch (s4) {
		case 3:
			break;
		default:
			return 4;
		}

		return 0;
	}
Пример #39
0
 public static extern void InvokeCallback2(MyCallback2 callback, S2 s);
Пример #40
0
    private static void allTests(Ice.Communicator communicator)
    {
        Console.Out.Write("testing equals() for Slice structures... ");
        Console.Out.Flush();

        //
        // Define some default values.
        //
        C def_cls = new C(5);
        S1 def_s = new S1("name");
        string[] def_ss = new string[]{ "one", "two", "three" };
        IntList def_il = new IntList();
        def_il.Add(1);
        def_il.Add(2);
        def_il.Add(3);
        Dictionary<string, string> def_sd = new Dictionary<string, string>();
        def_sd.Add("abc", "def");
        Ice.ObjectPrx def_prx = communicator.stringToProxy("test");
        S2 def_s2 = new S2(true, (byte)98, (short)99, 100, 101, (float)1.0, 2.0, "string", def_ss, def_il, def_sd,
                           def_s, def_cls, def_prx);

        //
        // Compare default-constructed structures.
        //
        {
            test(new S2().Equals(new S2()));
        }

        //
        // Change one primitive member at a time.
        //
        {
            S2 v;

            v = (S2)def_s2.Clone();
            test(v.Equals(def_s2));

            v = (S2)def_s2.Clone();
            v.bo = false;
            test(!v.Equals(def_s2));

            v = (S2)def_s2.Clone();
            v.by--;
            test(!v.Equals(def_s2));

            v = (S2)def_s2.Clone();
            v.sh--;
            test(!v.Equals(def_s2));

            v = (S2)def_s2.Clone();
            v.i--;
            test(!v.Equals(def_s2));

            v = (S2)def_s2.Clone();
            v.l--;
            test(!v.Equals(def_s2));

            v = (S2)def_s2.Clone();
            v.f--;
            test(!v.Equals(def_s2));

            v = (S2)def_s2.Clone();
            v.d--;
            test(!v.Equals(def_s2));

            v = (S2)def_s2.Clone();
            v.str = "";
            test(!v.Equals(def_s2));
        }

        //
        // String member
        //
        {
            S2 v1, v2;

            v1 = (S2)def_s2.Clone();
            v1.str = (string)def_s2.str.Clone();
            test(v1.Equals(def_s2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v1.str = null;
            test(!v1.Equals(v2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v2.str = null;
            test(!v1.Equals(v2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v1.str = null;
            v2.str = null;
            test(v1.Equals(v2));
        }

        //
        // Sequence member
        //
        {
            S2 v1, v2;

            v1 = (S2)def_s2.Clone();
            v1.ss = (string[])def_s2.ss.Clone();
            test(v1.Equals(def_s2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v1.ss = null;
            test(!v1.Equals(v2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v2.ss = null;
            test(!v1.Equals(v2));
        }

        //
        // Custom sequence member
        //
        {
            S2 v1, v2;

            v1 = (S2)def_s2.Clone();
            v1.il = (IntList)def_s2.il.Clone();
            test(v1.Equals(def_s2));

            v1 = (S2)def_s2.Clone();
            v1.il = new IntList();
            test(!v1.Equals(def_s2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v1.il = null;
            test(!v1.Equals(v2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v2.il = null;
            test(!v1.Equals(v2));
        }

        //
        // Dictionary member
        //
        {
            S2 v1, v2;

            v1 = (S2)def_s2.Clone();
            v1.sd = new Dictionary<string, string>(def_s2.sd);
            test(v1.Equals(def_s2));

            v1 = (S2)def_s2.Clone();
            v1.sd = new Dictionary<string, string>();
            test(!v1.Equals(def_s2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v1.sd = null;
            test(!v1.Equals(v2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v2.sd = null;
            test(!v1.Equals(v2));
        }

        //
        // Struct member
        //
        {
            S2 v1, v2;

            v1 = (S2)def_s2.Clone();
            v1.s = (S1)def_s2.s.Clone();
            test(v1.Equals(def_s2));

            v1 = (S2)def_s2.Clone();
            v1.s = new S1("name");
            test(v1.Equals(def_s2));

            v1 = (S2)def_s2.Clone();
            v1.s = new S1("noname");
            test(!v1.Equals(def_s2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v1.s = null;
            test(!v1.Equals(v2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v2.s = null;
            test(!v1.Equals(v2));
        }

        //
        // Class member
        //
        {
            S2 v1, v2;

            v1 = (S2)def_s2.Clone();
            v1.cls = (C)def_s2.cls.Clone();
            test(!v1.Equals(def_s2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v1.cls = null;
            test(!v1.Equals(v2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v2.cls = null;
            test(!v1.Equals(v2));
        }

        //
        // Proxy member
        //
        {
            S2 v1, v2;

            v1 = (S2)def_s2.Clone();
            v1.prx = communicator.stringToProxy("test");
            test(v1.Equals(def_s2));

            v1 = (S2)def_s2.Clone();
            v1.prx = communicator.stringToProxy("test2");
            test(!v1.Equals(def_s2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v1.prx = null;
            test(!v1.Equals(v2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v2.prx = null;
            test(!v1.Equals(v2));
        }

        Console.Out.WriteLine("ok");
    }
Пример #41
0
	public static void Main()
	{
		S2 s2 = new S2 ();
		int r = s2 ^ 5.04f;
	}
Пример #42
0
 public static extern S2 InvokeCallback2R(MyCallback2 callback, S2 s);