Skip to content

Commit 15cf956

Browse files
author
Luca Geretti
committed
Modify test_array to use explicit conversion between convertible types
1 parent 2297093 commit 15cf956

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

tests/utility/test_array.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,24 @@
3232

3333
using namespace Ariadne;
3434

35+
struct TestConvertibleTo {
36+
TestConvertibleTo(int a_) : a(a_) { }
37+
int a;
38+
};
39+
40+
struct TestClass {
41+
TestClass(int a_) : a(a_) { }
42+
explicit TestClass(TestConvertibleTo const& c) : TestClass(c.a) { }
43+
int a;
44+
};
45+
3546
class TestArray {
3647
public:
3748

3849
Void test_convert() {
39-
Array<int> ia = {1, 2};
40-
Array<double> da(ia);
41-
ARIADNE_TEST_ASSERT(da[0] == ia[0] and da[1] == ia[1]);
50+
Array<TestClass> tca = {TestClass(1), TestClass(2)};
51+
Array<TestConvertibleTo> tcta = {TestConvertibleTo(1), TestConvertibleTo(2)};
52+
ARIADNE_TEST_EXECUTE(Array<TestClass> tcac(tcta));
4253
}
4354

4455
Void test_print() {

0 commit comments

Comments
 (0)