File: copy_devproxy.cpp

package info (click to toggle)
tango 10.0.2%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 89,936 kB
  • sloc: cpp: 201,786; sh: 1,645; python: 953; java: 800; perl: 467; javascript: 447; xml: 325; makefile: 272; sql: 72; ruby: 24
file content (69 lines) | stat: -rw-r--r-- 1,357 bytes parent folder | download | duplicates (3)
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
// NOLINTBEGIN(*)

#include "old_common.h"

int main(int argc, char **argv)
{
    DeviceProxy *device;

    if(argc != 5)
    {
        TEST_LOG << "usage: copy_devproxy <device1> <device2> <device3> <idlver>" << endl;
        exit(-1);
    }

    string device1_name(argv[1]);
    string device2_name(argv[2]);
    string device3_name(argv[3]);
    int idlver = parse_as<int>(argv[4]);

    try
    {
        device = new DeviceProxy(device1_name);
    }
    catch(CORBA::Exception &e)
    {
        Except::print_exception(e);
        exit(1);
    }

    TEST_LOG << endl << "new DeviceProxy(" << device->name() << ") returned" << endl << endl;

    try
    {
        // Test copy constructor

        DeviceProxy dev2(*device);

        assert(dev2.name() == device1_name);
#ifndef COMPAT
        assert(dev2.get_idl_version() == idlver);
#endif
    }
    catch(Tango::DevFailed &e)
    {
        Except::print_exception(e);
        exit(-1);
    }

    TEST_LOG << "   Copy constructor --> OK" << endl;

    // Test assignement operator

    DeviceProxy dev2(device2_name);
    DeviceProxy dev3(device3_name);

    dev3 = *device;

    assert(dev3.name() == device1_name);
#ifndef COMPAT
    assert(dev3.get_idl_version() == idlver);
#endif

    TEST_LOG << "   Assignement operator --> OK" << endl;

    delete device;
    return 0;
}

// NOLINTEND(*)