File: lasvariablerecord_test.cpp

package info (click to toggle)
liblas 1.2.1-5
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 3,672 kB
  • sloc: cpp: 10,473; sh: 9,594; ansic: 3,427; makefile: 130
file content (108 lines) | stat: -rw-r--r-- 2,858 bytes parent folder | download | duplicates (2)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// $Id: lasvariablerecord_test.cpp 712 2008-05-14 22:47:43Z hobu $
//
// (C) Copyright Mateusz Loskot 2008, mateusz@loskot.net
// Distributed under the BSD License
// (See accompanying file LICENSE.txt or copy at
// http://www.opensource.org/licenses/bsd-license.php)
//
#include <liblas/lasvariablerecord.hpp>
#include <liblas/cstdint.hpp>
#include <tut/tut.hpp>
#include <string>

namespace tut
{ 
    struct lasvariablerecord_data
    {
        liblas::LASVariableRecord m_default;

        void test_default(liblas::LASVariableRecord const& h)
        {
            ensure_equals("wrong default reserved bytes",
                h.GetReserved(), liblas::uint16_t());

            ensure_equals("wrong default record identifier",
                h.GetRecordId(), liblas::uint16_t());

            ensure_equals("wrong default record length",
                h.GetRecordLength(), liblas::uint16_t());

            ensure_equals("wrong default user identifier",
                h.GetUserId(true).c_str(), std::string());

            ensure_equals("wrong default description",
                h.GetDescription(true).c_str(), std::string());
        }
    };

    typedef test_group<lasvariablerecord_data> tg;
    typedef tg::object to;

    tg test_group_lasvariablerecord("liblas::LASVariableRecord");

    // Test default constructor
    template<>
    template<>
    void to::test<1>()
    {
        test_default(m_default);
    }

    // Test copy constructor
    template<>
    template<>
    void to::test<2>()
    {
        liblas::LASVariableRecord hdr_copy(m_default);
        test_default(hdr_copy);
    }

    // Test assignment operator
    template<>
    template<>
    void to::test<3>()
    {
        liblas::LASVariableRecord hdr_copy;
        test_default(hdr_copy);

        hdr_copy = m_default;
        test_default(hdr_copy);
    }

    // Test equal function
    template<>
    template<>
    void to::test<4>()
    {
        liblas::LASVariableRecord hdr;
        ensure("two default headers not equal", m_default.equal(hdr));

        liblas::LASVariableRecord hdr_copy(m_default);
        ensure("copy of default header not equal", hdr.equal(m_default));
    }

    // Test equal-to operator
    template<>
    template<>
    void to::test<5>()
    {
        liblas::LASVariableRecord hdr;
        ensure("two default headers not equal", m_default == hdr);

        liblas::LASVariableRecord hdr_copy(m_default);
        ensure("copy of default header not equal", hdr == m_default);
    }

    // Test not-equal-to operator
    template<>
    template<>
    void to::test<6>()
    {
        liblas::LASVariableRecord hdr;
        ensure_not("two default headers not equal", m_default != hdr);

        liblas::LASVariableRecord hdr_copy(m_default);
        ensure_not("copy of default header not equal", hdr != m_default);
    }
}