blob: 0e34b1690192465104f71df541507123ffdcb1a9 [file] [log] [blame]
Jens Geyerae0b22c2014-09-04 23:04:21 +02001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19#define BOOST_TEST_MODULE EnumTest
20#include <boost/test/unit_test.hpp>
Jens Geyer4d223c62014-09-05 22:31:39 +020021#include "gen-cpp/EnumTest_types.h"
Jens Geyerae0b22c2014-09-04 23:04:21 +020022
Konrad Grochowski16a23a62014-11-13 15:33:38 +010023BOOST_AUTO_TEST_SUITE(EnumTest)
Jens Geyerae0b22c2014-09-04 23:04:21 +020024
Konrad Grochowski16a23a62014-11-13 15:33:38 +010025BOOST_AUTO_TEST_CASE(test_enum) {
Jens Geyerae0b22c2014-09-04 23:04:21 +020026 // Check that all the enum values match what we expect
nameb3e5ebe2014-09-12 11:15:24 +020027 BOOST_CHECK_EQUAL(MyEnum1::ME1_0, 0);
28 BOOST_CHECK_EQUAL(MyEnum1::ME1_1, 1);
29 BOOST_CHECK_EQUAL(MyEnum1::ME1_2, 2);
30 BOOST_CHECK_EQUAL(MyEnum1::ME1_3, 3);
31 BOOST_CHECK_EQUAL(MyEnum1::ME1_5, 5);
32 BOOST_CHECK_EQUAL(MyEnum1::ME1_6, 6);
Jens Geyerae0b22c2014-09-04 23:04:21 +020033
nameb3e5ebe2014-09-12 11:15:24 +020034 BOOST_CHECK_EQUAL(MyEnum2::ME2_0, 0);
35 BOOST_CHECK_EQUAL(MyEnum2::ME2_1, 1);
36 BOOST_CHECK_EQUAL(MyEnum2::ME2_2, 2);
Jens Geyerae0b22c2014-09-04 23:04:21 +020037
nameb3e5ebe2014-09-12 11:15:24 +020038 BOOST_CHECK_EQUAL(MyEnum3::ME3_0, 0);
39 BOOST_CHECK_EQUAL(MyEnum3::ME3_1, 1);
40 BOOST_CHECK_EQUAL(MyEnum3::ME3_N2, -2);
41 BOOST_CHECK_EQUAL(MyEnum3::ME3_N1, -1);
42 BOOST_CHECK_EQUAL(MyEnum3::ME3_D0, 0);
43 BOOST_CHECK_EQUAL(MyEnum3::ME3_D1, 1);
44 BOOST_CHECK_EQUAL(MyEnum3::ME3_9, 9);
45 BOOST_CHECK_EQUAL(MyEnum3::ME3_10, 10);
Jens Geyerae0b22c2014-09-04 23:04:21 +020046
nameb3e5ebe2014-09-12 11:15:24 +020047 BOOST_CHECK_EQUAL(MyEnum4::ME4_A, 0x7ffffffd);
48 BOOST_CHECK_EQUAL(MyEnum4::ME4_B, 0x7ffffffe);
49 BOOST_CHECK_EQUAL(MyEnum4::ME4_C, 0x7fffffff);
Jens Geyerae0b22c2014-09-04 23:04:21 +020050}
51
Konrad Grochowski16a23a62014-11-13 15:33:38 +010052BOOST_AUTO_TEST_CASE(test_enum_constant) {
Jens Geyerae0b22c2014-09-04 23:04:21 +020053 MyStruct ms;
54 BOOST_CHECK_EQUAL(ms.me2_2, 2);
55 BOOST_CHECK_EQUAL(ms.me3_n2, -2);
56 BOOST_CHECK_EQUAL(ms.me3_d1, 1);
57}
58
59BOOST_AUTO_TEST_SUITE_END()