summaryrefslogtreecommitdiff
path: root/matlab/test/Ice/checksum/AllTests.m
blob: 16eaf366f6e859abc7399f27518c21aa7e8d561f (plain)
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
%{
**********************************************************************

Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved.

This copy of Ice is licensed to you under the terms described in the
ICE_LICENSE file included in this distribution.

**********************************************************************
%}

classdef AllTests
    methods(Static)
        function r = allTests(app)
            import test.Ice.checksum.Test.*;

            communicator = app.communicator();

            ref = ['test:', app.getTestEndpoint(0, '')];
            base = communicator.stringToProxy(ref);
            assert(~isempty(base));

            checksum = ChecksumPrx.checkedCast(base);
            assert(~isempty(checksum));

            %
            % Verify that no checksums are present for local types.
            %
            fprintf('testing checksums... ');
            map = SliceChecksums();
            keys = map.keys();
            for i = 1:length(keys)
                key = keys{i};
                assert(isempty(strfind(key, 'Local')));
            end

            %
            % Get server's Slice checksums.
            %
            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.
            %
            skeys = d.keys();
            for i = 1:length(skeys)
                n = 0;
                key = skeys{i};
                pos = regexp(key, '\d+');
                if ~isempty(pos)
                    n = str2num(key(pos:end));
                end

                assert(map.isKey(key));
                value = map(key);

                if n <= 1
                    assert(strcmp(value, d(key)));
                else
                    assert(~strcmp(value, d(key)));
                end
            end
            fprintf('ok\n');

            r = checksum;
        end
    end
end