GCC Code Coverage Report


Directory: ./
File: openvdb_ax/openvdb_ax/test/integration/TestCast.cc
Date: 2022-07-25 17:40:05
Exec Total Coverage
Lines: 62 62 100.0%
Functions: 10 10 100.0%
Branches: 113 220 51.4%

Line Branch Exec Source
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3
4 #include "TestHarness.h"
5
6 #include "../util.h"
7
8 #include <cppunit/extensions/HelperMacros.h>
9
10 using namespace openvdb::points;
11
12
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
1 class TestCast : public unittest_util::AXTestCase
13 {
14 public:
15
3/6
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 10 times.
✗ Branch 8 not taken.
30 std::string dir() const override { return GET_TEST_DIRECTORY(); }
16
17
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
4 CPPUNIT_TEST_SUITE(TestCast);
18
5/10
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
6 CPPUNIT_TEST(explicitScalar);
19
4/8
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
4 CPPUNIT_TEST_SUITE_END();
20
21 void explicitScalar();
22 };
23
24 CPPUNIT_TEST_SUITE_REGISTRATION(TestCast);
25
26
27 void
28 1 TestCast::explicitScalar()
29 {
30 1 auto generate = [this](const auto& types) {
31
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for (const auto& t1 : types) {
32 std::string code;
33 size_t idx = 1;
34
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 5 times.
30 for (const auto& t2 : types) {
35
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 20 times.
25 if (t1 == t2) continue;
36
2/4
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
20 std::string tmp = "_T1_@_A1_ = _T1_(_T2_@_A2_);";
37
3/6
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
40 unittest_util::replace(tmp, "_A1_", "test" + std::to_string(idx));
38
3/6
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
40 unittest_util::replace(tmp, "_A2_", "test" + t2);
39
2/4
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
20 unittest_util::replace(tmp, "_T1_", t1);
40
2/4
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
20 unittest_util::replace(tmp, "_T2_", t2);
41
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 code += tmp + "\n";
42 20 ++idx;
43 }
44
45
3/6
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 5 times.
✗ Branch 8 not taken.
10 this->registerTest(code, "cast_explicit." + t1 + ".ax");
46 }
47 1 };
48
49
9/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 5 times.
✓ Branch 23 taken 1 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
6 generate(std::vector<std::string>{ "bool", "int32", "int64", "float", "double" });
50
51
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 const auto names = unittest_util::nameSequence("test", 4);
52 const std::map<std::string, std::function<void()>> expected = {
53 1 { "bool", [&](){
54
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 mHarness.addAttribute<int32_t>("testint32", 1, 1);
55
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 mHarness.addAttribute<int64_t>("testint64", 0, 0);
56
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 mHarness.addAttribute<float>("testfloat", 2.3f, 2.3f);
57
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 mHarness.addAttribute<double>("testdouble", 0.1, 0.1);
58
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 mHarness.addAttributes<bool>(names, {true, false, true, true});
59 1 }
60 },
61 1 { "int32", [&](){
62
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 mHarness.addAttribute<bool>("testbool", true, true);
63
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 mHarness.addAttribute<int64_t>("testint64", 2, 2);
64
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 mHarness.addAttribute<float>("testfloat", 2.3f, 2.3f);
65
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 mHarness.addAttribute<double>("testdouble", 2.1, 2.1);
66
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 mHarness.addAttributes<int32_t>(names, {1, 2, 2, 2});
67 1 }
68 },
69 1 { "int64", [&]() {
70
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 mHarness.addAttribute<bool>("testbool", true, true);
71
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 mHarness.addAttribute<int32_t>("testint32", 2, 2);
72
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 mHarness.addAttribute<float>("testfloat", 2.3f, 2.3f);
73
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 mHarness.addAttribute<double>("testdouble", 2.1, 2.1);
74
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 mHarness.addAttributes<int64_t>(names, {1, 2, 2, 2});
75 1 }
76 },
77 1 { "float", [&]() {
78
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 mHarness.addAttribute<bool>("testbool", true, true);
79
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 mHarness.addAttribute<int32_t>("testint32", 1, 1);
80
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 mHarness.addAttribute<int64_t>("testint64", 1, 1);
81
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 mHarness.addAttribute<double>("testdouble", 1.1, 1.1);
82
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 mHarness.addAttributes<float>(names, {1.0f, 1.0f, 1.0f, float(1.1)});
83 1 }
84 },
85 1 { "double", [&]() {
86
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 mHarness.addAttribute<bool>("testbool", true, true);
87
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 mHarness.addAttribute<int32_t>("testint32", 1, 1);
88
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 mHarness.addAttribute<int64_t>("testint64", 1, 1);
89
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 mHarness.addAttribute<float>("testfloat", 1.1f, 1.1f);
90
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 mHarness.addAttributes<double>(names, {1.0, 1.0, 1.0, double(1.1f)});
91 1 }
92 }
93
6/14
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
12 };
94
95
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for (const auto& expc : expected) {
96
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 mHarness.reset();
97
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 expc.second.operator()();
98
3/6
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 5 times.
✗ Branch 8 not taken.
10 this->execute("cast_explicit." + expc.first + ".ax");
99 }
100 1 }
101
102
103