GCC Code Coverage Report


Directory: ./
File: openvdb/openvdb/unittest/TestInternalOrigin.cc
Date: 2022-07-25 17:40:05
Exec Total Coverage
Lines: 34 35 97.1%
Functions: 3 3 100.0%
Branches: 33 176 18.8%

Line Branch Exec Source
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3
4 #include <openvdb/Exceptions.h>
5 #include <openvdb/openvdb.h>
6 #include <gtest/gtest.h>
7
8 #include <set>
9
10 1 class TestInternalOrigin: public ::testing::Test
11 {
12 public:
13 1 void SetUp() override { openvdb::initialize(); }
14 1 void TearDown() override { openvdb::uninitialize(); }
15 };
16
17
18
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 TEST_F(TestInternalOrigin, test)
19 {
20 std::set<openvdb::Coord> indices;
21
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 indices.insert(openvdb::Coord( 0, 0, 0));
22
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 indices.insert(openvdb::Coord( 1, 0, 0));
23
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 indices.insert(openvdb::Coord( 0,100, 8));
24
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 indices.insert(openvdb::Coord(-9, 0, 8));
25
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 indices.insert(openvdb::Coord(32, 0, 16));
26
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 indices.insert(openvdb::Coord(33, -5, 16));
27
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 indices.insert(openvdb::Coord(42,707,-35));
28 indices.insert(openvdb::Coord(43, 17, 64));
29
30 typedef openvdb::tree::Tree4<float,5,4,3>::Type FloatTree4;
31 2 FloatTree4 tree(0.0f);
32 1 std::set<openvdb::Coord>::iterator iter=indices.begin();
33
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
9 for (int n = 0; iter != indices.end(); ++n, ++iter) {
34
1/2
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
16 tree.setValue(*iter, float(1.0 + double(n) * 0.5));
35 }
36
37 openvdb::Coord C3, G;
38 typedef FloatTree4::RootNodeType Node0;
39 typedef Node0::ChildNodeType Node1;
40 typedef Node1::ChildNodeType Node2;
41 typedef Node2::LeafNodeType Node3;
42
2/2
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
6 for (Node0::ChildOnCIter iter0=tree.root().cbeginChildOn(); iter0; ++iter0) {//internal 1
43
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 openvdb::Coord C0=iter0->origin();
44 iter0.getCoord(G);
45
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
4 EXPECT_EQ(C0,G);
46
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
8 for (Node1::ChildOnCIter iter1=iter0->cbeginChildOn(); iter1; ++iter1) {//internal 2
47
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 openvdb::Coord C1=iter1->origin();
48 iter1.getCoord(G);
49
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
4 EXPECT_EQ(C1,G);
50
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
4 EXPECT_TRUE(C0 <= C1);
51
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
4 EXPECT_TRUE(C1 <= C0 + openvdb::Coord(Node1::DIM,Node1::DIM,Node1::DIM));
52
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4 times.
11 for (Node2::ChildOnCIter iter2=iter1->cbeginChildOn(); iter2; ++iter2) {//leafs
53
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 openvdb::Coord C2=iter2->origin();
54 iter2.getCoord(G);
55
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
7 EXPECT_EQ(C2,G);
56
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
7 EXPECT_TRUE(C1 <= C2);
57
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
7 EXPECT_TRUE(C2 <= C1 + openvdb::Coord(Node2::DIM,Node2::DIM,Node2::DIM));
58
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 7 times.
15 for (Node3::ValueOnCIter iter3=iter2->cbeginValueOn(); iter3; ++iter3) {//leaf voxels
59 iter3.getCoord(G);
60
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 iter = indices.find(G);
61
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
8 EXPECT_TRUE(iter != indices.end());
62 8 indices.erase(iter);
63 }
64 }
65 }
66 }
67
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(indices.size() == 0);
68 1 }
69