GCC Code Coverage Report


Directory: ./
File: openvdb/openvdb/unittest/TestName.cc
Date: 2022-07-25 17:40:05
Exec Total Coverage
Lines: 31 31 100.0%
Functions: 3 3 100.0%
Branches: 31 174 17.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/util/Name.h>
6
7 #include <gtest/gtest.h>
8
9
10 3 class TestName : public ::testing::Test
11 {
12 };
13
14
15
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 TEST_F(TestName, test)
16 {
17 using namespace openvdb;
18
19 Name name;
20
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Name name2("something");
21
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Name name3 = std::string("something2");
22
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 name = "something";
23
24
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(name == name2);
25
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(name != name3);
26
2/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
2 EXPECT_TRUE(name != Name("testing"));
27
2/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
1 EXPECT_TRUE(name == Name("something"));
28 1 }
29
30
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 TEST_F(TestName, testIO)
31 {
32 using namespace openvdb;
33
34 1 Name name("some name that i made up");
35
36
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::ostringstream ostr(std::ios_base::binary);
37
38
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 openvdb::writeString(ostr, name);
39
40
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 name = "some other name";
41
42
2/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
1 EXPECT_TRUE(name == Name("some other name"));
43
44
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::istringstream istr(ostr.str(), std::ios_base::binary);
45
46
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 name = openvdb::readString(istr);
47
48
2/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
1 EXPECT_TRUE(name == Name("some name that i made up"));
49 1 }
50
51
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 TEST_F(TestName, testMultipleIO)
52 {
53 using namespace openvdb;
54
55 1 Name name("some name that i made up");
56
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Name name2("something else");
57
58
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::ostringstream ostr(std::ios_base::binary);
59
60
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 openvdb::writeString(ostr, name);
61
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 openvdb::writeString(ostr, name2);
62
63
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::istringstream istr(ostr.str(), std::ios_base::binary);
64
65
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 Name n = openvdb::readString(istr), n2 = openvdb::readString(istr);
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(name == n);
68
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(name2 == n2);
69 1 }
70