File: test-property-type.cxx

package info (click to toggle)
libcmis 0.5.1%2Bgit20160603-3
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 3,088 kB
  • ctags: 2,704
  • sloc: cpp: 23,427; xml: 4,499; makefile: 486; sh: 216; ansic: 111
file content (250 lines) | stat: -rw-r--r-- 8,204 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
/* libcmis
 * Version: MPL 1.1 / GPLv2+ / LGPLv2+
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License or as specified alternatively below. You may obtain a copy of
 * the License at http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * Major Contributor(s):
 * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
 *
 *
 * All Rights Reserved.
 *
 * For minor contributions see the git repository.
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
 * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
 * instead of those above.
 */

#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/TestFixture.h>
#include <cppunit/TestAssert.h>

#include "internals.hxx"
#include "property-type.h"
#include "test-dummies.hxx"

using namespace std;

class PropertyTypeTest : public CppUnit::TestFixture
{
    private:
        libcmis_PropertyTypePtr getTested( string id, string xmlType );

    public:
        void getIdTest( );
        void getLocalNameTest( );
        void getLocalNamespaceTest( );
        void getDisplayNameTest( );
        void getQueryNameTest( );
        void getTypeTest( );
        void isMultiValuedTest( );
        void isUpdatableTest( );
        void isInheritedTest( );
        void isRequiredTest( );
        void isQueryableTest( );
        void isOrderableTest( );
        void isOpenChoiceTest( );

        CPPUNIT_TEST_SUITE( PropertyTypeTest );
        CPPUNIT_TEST( getIdTest );
        CPPUNIT_TEST( getLocalNameTest );
        CPPUNIT_TEST( getLocalNamespaceTest );
        CPPUNIT_TEST( getDisplayNameTest );
        CPPUNIT_TEST( getQueryNameTest );
        CPPUNIT_TEST( getTypeTest );
        CPPUNIT_TEST( isMultiValuedTest );
        CPPUNIT_TEST( isUpdatableTest );
        CPPUNIT_TEST( isInheritedTest );
        CPPUNIT_TEST( isRequiredTest );
        CPPUNIT_TEST( isQueryableTest );
        CPPUNIT_TEST( isOrderableTest );
        CPPUNIT_TEST( isOpenChoiceTest );
        CPPUNIT_TEST_SUITE_END( );
};

CPPUNIT_TEST_SUITE_REGISTRATION( PropertyTypeTest );

libcmis_PropertyTypePtr PropertyTypeTest::getTested( string id, string xmlType )
{
    libcmis_PropertyTypePtr result = new libcmis_property_type( );
    libcmis::PropertyTypePtr handle( new dummies::PropertyType( id, xmlType ) );
    result->handle = handle;

    return result;
}

void PropertyTypeTest::getIdTest( )
{
    string id( "Id" );
    libcmis_PropertyTypePtr tested = getTested( id, "string" );
    char* actual = libcmis_property_type_getId( tested );
    CPPUNIT_ASSERT_EQUAL( id, string( actual ) );

    free( actual );
    libcmis_property_type_free( tested );
}

void PropertyTypeTest::getLocalNameTest( )
{
    libcmis_PropertyTypePtr tested = getTested( "id", "string" );
    char* actual = libcmis_property_type_getLocalName( tested );
    CPPUNIT_ASSERT_EQUAL( string( "PropertyType::LocalName" ), string( actual ) );

    free( actual );
    libcmis_property_type_free( tested );
}

void PropertyTypeTest::getLocalNamespaceTest( )
{
    libcmis_PropertyTypePtr tested = getTested( "id", "string" );
    char* actual = libcmis_property_type_getLocalNamespace( tested );
    CPPUNIT_ASSERT_EQUAL( string( "PropertyType::LocalNamespace" ), string( actual ) );

    free( actual );
    libcmis_property_type_free( tested );
}

void PropertyTypeTest::getDisplayNameTest( )
{
    libcmis_PropertyTypePtr tested = getTested( "id", "string" );
    char* actual = libcmis_property_type_getDisplayName( tested );
    CPPUNIT_ASSERT_EQUAL( string( "PropertyType::DisplayName" ), string( actual ) );

    free( actual );
    libcmis_property_type_free( tested );
}

void PropertyTypeTest::getQueryNameTest( )
{
    libcmis_PropertyTypePtr tested = getTested( "id", "string" );
    char* actual = libcmis_property_type_getQueryName( tested );
    CPPUNIT_ASSERT_EQUAL( string( "PropertyType::QueryName" ), string( actual ) );

    free( actual );
    libcmis_property_type_free( tested );
}

void PropertyTypeTest::getTypeTest( )
{
    // String
    {
        libcmis_PropertyTypePtr tested = getTested( "id", "string" );
        libcmis_property_type_Type actualType = libcmis_property_type_getType( tested );
        CPPUNIT_ASSERT_EQUAL( libcmis_String, actualType );
        char* actualXml = libcmis_property_type_getXmlType( tested );
        CPPUNIT_ASSERT_EQUAL( string( "String" ), string( actualXml ) );

        free( actualXml );
        libcmis_property_type_free( tested );
    }
    
    // DateTime
    {
        libcmis_PropertyTypePtr tested = getTested( "id", "datetime" );
        libcmis_property_type_Type actualType = libcmis_property_type_getType( tested );
        CPPUNIT_ASSERT_EQUAL( libcmis_DateTime, actualType );
        char* actualXml = libcmis_property_type_getXmlType( tested );
        CPPUNIT_ASSERT_EQUAL( string( "DateTime" ), string( actualXml ) );

        free( actualXml );
        libcmis_property_type_free( tested );
    }
    
    // Integer
    {
        libcmis_PropertyTypePtr tested = getTested( "id", "integer" );
        libcmis_property_type_Type actualType = libcmis_property_type_getType( tested );
        CPPUNIT_ASSERT_EQUAL( libcmis_Integer, actualType );
        char* actualXml = libcmis_property_type_getXmlType( tested );
        CPPUNIT_ASSERT_EQUAL( string( "Integer" ), string( actualXml ) );

        free( actualXml );
        libcmis_property_type_free( tested );
    }
    
    // Html
    {
        libcmis_PropertyTypePtr tested = getTested( "id", "html" );
        libcmis_property_type_Type actualType = libcmis_property_type_getType( tested );
        CPPUNIT_ASSERT_EQUAL( libcmis_String, actualType );
        char* actualXml = libcmis_property_type_getXmlType( tested );
        CPPUNIT_ASSERT_EQUAL( string( "Html" ), string( actualXml ) );

        free( actualXml );
        libcmis_property_type_free( tested );
    }
}

void PropertyTypeTest::isMultiValuedTest( )
{
    libcmis_PropertyTypePtr tested = getTested( "id", "string" );
    bool actual = libcmis_property_type_isMultiValued( tested );
    CPPUNIT_ASSERT_EQUAL( true , actual );

    libcmis_property_type_free( tested );
}

void PropertyTypeTest::isUpdatableTest( )
{
    libcmis_PropertyTypePtr tested = getTested( "id", "string" );
    bool actual = libcmis_property_type_isUpdatable( tested );
    CPPUNIT_ASSERT_EQUAL( true , actual );

    libcmis_property_type_free( tested );
}

void PropertyTypeTest::isInheritedTest( )
{
    libcmis_PropertyTypePtr tested = getTested( "id", "string" );
    bool actual = libcmis_property_type_isInherited( tested );
    CPPUNIT_ASSERT_EQUAL( true , actual );

    libcmis_property_type_free( tested );
}

void PropertyTypeTest::isRequiredTest( )
{
    libcmis_PropertyTypePtr tested = getTested( "id", "string" );
    bool actual = libcmis_property_type_isRequired( tested );
    CPPUNIT_ASSERT_EQUAL( true , actual );

    libcmis_property_type_free( tested );
}

void PropertyTypeTest::isQueryableTest( )
{
    libcmis_PropertyTypePtr tested = getTested( "id", "string" );
    bool actual = libcmis_property_type_isQueryable( tested );
    CPPUNIT_ASSERT_EQUAL( true , actual );

    libcmis_property_type_free( tested );
}

void PropertyTypeTest::isOrderableTest( )
{
    libcmis_PropertyTypePtr tested = getTested( "id", "string" );
    bool actual = libcmis_property_type_isOrderable( tested );
    CPPUNIT_ASSERT_EQUAL( true , actual );

    libcmis_property_type_free( tested );
}

void PropertyTypeTest::isOpenChoiceTest( )
{
    libcmis_PropertyTypePtr tested = getTested( "id", "string" );
    bool actual = libcmis_property_type_isOpenChoice( tested );
    CPPUNIT_ASSERT_EQUAL( true , actual );

    libcmis_property_type_free( tested );
}