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
|
Description: Fix conversion_error warning leading to FTBFS
Note: original patch misses the same issue in interop_test.cpp
Author: Thomas Goirand <zigo@debian.org>
Bug-Debian: https://bugs.debian.org/897841
Origin: upstream, https://github.com/apache/qpid-proton/commit/49f4cb5
Last-Update: 2019-01-07
--- qpid-proton-0.22.0.orig/proton-c/bindings/cpp/src/interop_test.cpp
+++ qpid-proton-0.22.0/proton-c/bindings/cpp/src/interop_test.cpp
@@ -63,22 +63,22 @@ void test_decoder_primitives_exact() {
decoder d(dv);
d.decode(read("primitives"));
ASSERT(d.more());
- try { get< ::int8_t>(d); FAIL("got bool as byte"); } catch(conversion_error){}
+ try { get< ::int8_t>(d); FAIL("got bool as byte"); } catch(const conversion_error&){}
ASSERT_EQUAL(true, get<bool>(d));
ASSERT_EQUAL(false, get<bool>(d));
- try { get< ::int8_t>(d); FAIL("got ubyte as byte"); } catch(conversion_error){}
+ try { get< ::int8_t>(d); FAIL("got ubyte as byte"); } catch(const conversion_error&){}
ASSERT_EQUAL(42, get< ::uint8_t>(d));
- try { get< ::int32_t>(d); FAIL("got uint as ushort"); } catch(conversion_error){}
+ try { get< ::int32_t>(d); FAIL("got uint as ushort"); } catch(const conversion_error&){}
ASSERT_EQUAL(42, get< ::uint16_t>(d));
- try { get< ::uint16_t>(d); FAIL("got short as ushort"); } catch(conversion_error){}
+ try { get< ::uint16_t>(d); FAIL("got short as ushort"); } catch(const conversion_error&){}
ASSERT_EQUAL(-42, get< ::int16_t>(d));
ASSERT_EQUAL(12345u, get< ::uint32_t>(d));
ASSERT_EQUAL(-12345, get< ::int32_t>(d));
ASSERT_EQUAL(12345u, get< ::uint64_t>(d));
ASSERT_EQUAL(-12345, get< ::int64_t>(d));
- try { get<double>(d); FAIL("got float as double"); } catch(conversion_error){}
+ try { get<double>(d); FAIL("got float as double"); } catch(const conversion_error&){}
ASSERT_EQUAL(0.125f, get<float>(d));
- try { get<float>(d); FAIL("got double as float"); } catch(conversion_error){}
+ try { get<float>(d); FAIL("got double as float"); } catch(const conversion_error&){}
ASSERT_EQUAL(0.125, get<double>(d));
ASSERT(!d.more());
}
--- qpid-proton-0.22.0.orig/proton-c/bindings/cpp/src/scalar_test.hpp
+++ qpid-proton-0.22.0/proton-c/bindings/cpp/src/scalar_test.hpp
@@ -86,18 +86,18 @@ template <class V, class T> void simple_
// Test invalid gets, valid same-type get<T> is tested by simple_type_test
// Templated to test both scalar and value.
template<class V> void bad_get_test() {
- try { get<bool>(V(int8_t(1))); FAIL("byte as bool"); } catch (conversion_error) {}
- try { get<uint8_t>(V(true)); FAIL("bool as uint8_t"); } catch (conversion_error) {}
- try { get<uint8_t>(V(int8_t(1))); FAIL("int8 as uint8"); } catch (conversion_error) {}
- try { get<int16_t>(V(uint16_t(1))); FAIL("uint16 as int16"); } catch (conversion_error) {}
- try { get<int16_t>(V(int32_t(1))); FAIL("int32 as int16"); } catch (conversion_error) {}
- try { get<symbol>(V(std::string())); FAIL("string as symbol"); } catch (conversion_error) {}
- try { get<std::string>(V(binary())); FAIL("binary as string"); } catch (conversion_error) {}
- try { get<binary>(V(symbol())); FAIL("symbol as binary"); } catch (conversion_error) {}
- try { get<binary>(V(timestamp())); FAIL("timestamp as binary"); } catch (conversion_error) {}
- try { get<int>(V(timestamp())); FAIL("timestamp as int"); } catch (conversion_error) {}
- try { get<timestamp>(V(0)); FAIL("int as timestamp"); } catch (conversion_error) {}
- try { get<timestamp>(V(std::string())); FAIL("string as timestamp"); } catch (conversion_error) {}
+ try { get<bool>(V(int8_t(1))); FAIL("byte as bool"); } catch (const conversion_error&) {}
+ try { get<uint8_t>(V(true)); FAIL("bool as uint8_t"); } catch (const conversion_error&) {}
+ try { get<uint8_t>(V(int8_t(1))); FAIL("int8 as uint8"); } catch (const conversion_error&) {}
+ try { get<int16_t>(V(uint16_t(1))); FAIL("uint16 as int16"); } catch (const conversion_error&) {}
+ try { get<int16_t>(V(int32_t(1))); FAIL("int32 as int16"); } catch (const conversion_error&) {}
+ try { get<symbol>(V(std::string())); FAIL("string as symbol"); } catch (const conversion_error&) {}
+ try { get<std::string>(V(binary())); FAIL("binary as string"); } catch (const conversion_error&) {}
+ try { get<binary>(V(symbol())); FAIL("symbol as binary"); } catch (const conversion_error&) {}
+ try { get<binary>(V(timestamp())); FAIL("timestamp as binary"); } catch (const conversion_error&) {}
+ try { get<int>(V(timestamp())); FAIL("timestamp as int"); } catch (const conversion_error&) {}
+ try { get<timestamp>(V(0)); FAIL("int as timestamp"); } catch (const conversion_error&) {}
+ try { get<timestamp>(V(std::string())); FAIL("string as timestamp"); } catch (const conversion_error&) {}
}
// Test some valid coercions and some bad ones with mixed types.
@@ -124,17 +124,17 @@ template<class V> void coerce_test() {
// Bad coercions, types are not `is_convertible`
V s("foo");
- try { coerce<bool>(s); FAIL("string as bool"); } catch (conversion_error) {}
- try { coerce<int>(s); FAIL("string as int"); } catch (conversion_error) {}
- try { coerce<double>(s); FAIL("string as double"); } catch (conversion_error) {}
-
- try { coerce<std::string>(V(0)); FAIL("int as string"); } catch (conversion_error) {}
- try { coerce<symbol>(V(true)); FAIL("bool as symbol"); } catch (conversion_error) {}
- try { coerce<binary>(V(0.0)); FAIL("double as binary"); } catch (conversion_error) {}
- try { coerce<symbol>(V(binary())); FAIL("binary as symbol"); } catch (conversion_error) {}
- try { coerce<binary>(V(symbol())); FAIL("symbol as binary"); } catch (conversion_error) {}
- try { coerce<binary>(s); } catch (conversion_error) {}
- try { coerce<symbol>(s); } catch (conversion_error) {}
+ try { coerce<bool>(s); FAIL("string as bool"); } catch (const conversion_error&) {}
+ try { coerce<int>(s); FAIL("string as int"); } catch (const conversion_error&) {}
+ try { coerce<double>(s); FAIL("string as double"); } catch (const conversion_error&) {}
+
+ try { coerce<std::string>(V(0)); FAIL("int as string"); } catch (const conversion_error&) {}
+ try { coerce<symbol>(V(true)); FAIL("bool as symbol"); } catch (const conversion_error&) {}
+ try { coerce<binary>(V(0.0)); FAIL("double as binary"); } catch (const conversion_error&) {}
+ try { coerce<symbol>(V(binary())); FAIL("binary as symbol"); } catch (const conversion_error&) {}
+ try { coerce<binary>(V(symbol())); FAIL("symbol as binary"); } catch (const conversion_error&) {}
+ try { coerce<binary>(s); } catch (const conversion_error&) {}
+ try { coerce<symbol>(s); } catch (const conversion_error&) {}
}
template <class V> void null_test() {
@@ -149,7 +149,7 @@ template <class V> void null_test() {
ASSERT_EQUAL(NULL_TYPE, v.type());
v = "foo";
ASSERT_EQUAL(STRING, v.type());
- try { get<null>(v); FAIL("Expected conversion_error"); } catch (conversion_error) {}
+ try { get<null>(v); FAIL("Expected conversion_error"); } catch (const conversion_error&) {}
v = null();
get<null>(v);
}
|