Debian Codegraph @

c/tests/condition_test.cpp

raw
1 /*
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
20 #include "./pn_test.hpp"
21
22 #include <proton/condition.h>
23 #include <proton/connection.h>
24
25 using Catch::Matchers::Equals;
26 using namespace pn_test;
27
28 TEST_CASE("condition") {
29 auto_free<pn_connection_t, pn_connection_free> c(pn_connection());
30 REQUIRE(c);
31 pn_condition_t *cond = pn_connection_condition(c);
32 REQUIRE(cond);
33
34 // Verify empty
35 CHECK(!pn_condition_is_set(cond));
36 CHECK(!pn_condition_get_name(cond));
37 CHECK(!pn_condition_get_description(cond));
38
39 // Format a condition
40 pn_condition_format(cond, "foo", "hello %d", 42);
41 CHECK(pn_condition_is_set(cond));
42 CHECK_THAT("foo", Equals(pn_condition_get_name(cond)));
43 CHECK_THAT("hello 42", Equals(pn_condition_get_description(cond)));
44
45 // Clear and verify empty
46 pn_condition_clear(cond);
47 CHECK(!pn_condition_is_set(cond));
48 CHECK(!pn_condition_get_name(cond));
49 CHECK(!pn_condition_get_description(cond));
50 }