File: AllTests.cs

package info (click to toggle)
zeroc-ice 3.7.10-3.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 75,696 kB
  • sloc: cpp: 356,894; java: 226,081; cs: 98,312; javascript: 35,027; python: 28,716; objc: 27,050; php: 7,526; ruby: 7,190; yacc: 2,949; ansic: 2,469; xml: 1,589; lex: 1,241; makefile: 472; sh: 52
file content (82 lines) | stat: -rw-r--r-- 2,820 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//

using System;
using System.Collections.Generic;

namespace Ice
{
    namespace checksum
    {
        public class AllTests : global::Test.AllTests
        {
            public static Test.ChecksumPrx
            allTests(global::Test.TestHelper helper, bool collocated)
            {
                var output = helper.getWriter();
                Ice.Communicator communicator = helper.communicator();
                string rf = "test:" + helper.getTestEndpoint(0);
                Ice.ObjectPrx baseProxy = communicator.stringToProxy(rf);
                test(baseProxy != null);

                Test.ChecksumPrx checksum = Test.ChecksumPrxHelper.checkedCast(baseProxy);
                test(checksum != null);

                //
                // Verify that no checksums are present for local types.
                //
                output.Write("testing checksums... ");
                output.Flush();
                foreach(KeyValuePair<string, string> entry in Ice.SliceChecksums.checksums)
                {
                    string key = entry.Key;
                    int pos = key.IndexOf("Local");
                    test(pos == -1);
                }

                //
                // Get server's Slice checksums.
                //
                Dictionary<string, string> d = checksum.getSliceChecksums();

                //
                // Compare the checksums. For a type FooN whose name ends in an integer N,
                // we assume that the server's type does not change for N = 1, and does
                // change for N > 1.
                //
                char[] digits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
                foreach(KeyValuePair<string, string> entry in d)
                {
                    string key = entry.Key;
                    int start = key.IndexOfAny(digits);
                    if(start != -1)
                    {
                        int end = start;
                        while(end < key.Length && char.IsDigit(key[end]))
                        {
                            end++;
                        }
                        int n = int.Parse(key.Substring(start, end - start));

                        string value = Ice.SliceChecksums.checksums[key];
                        test(value != null);

                        if(n <= 1)
                        {
                            test(value.Equals(entry.Value));
                        }
                        else
                        {
                            test(!value.Equals(entry.Value));
                        }
                    }
                }

                output.WriteLine("ok");

                return checksum;
            }
        }
    }
}