File: HDF2DArray_gtest.cpp

package info (click to toggle)
pbseqlib 5.3.5%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 7,020 kB
  • sloc: cpp: 77,250; python: 331; sh: 103; makefile: 41
file content (101 lines) | stat: -rw-r--r-- 2,556 bytes parent folder | download | duplicates (4)
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
/*
 * ==========================================================================
 *
 *       Filename:  HDF2DArray_gtest.cpp
 *
 *    Description:  Test hdf/HDF2DArray.hpp
 *
 *        Version:  1.0
 *        Created:  08/21/2013 07:00:49 PM
 *       Revision:  08/20/2014
 *       Compiler:  gcc
 *
 *         Author:  Yuan Li (yli), yli@pacificbiosciences.com
 *        Company:  Pacific Biosciences
 *
 * ==========================================================================
 */

#include <string>

#include <gtest/gtest.h>

#include <pbdata/testdata.h>
#include <hdf/HDF2DArray.hpp>
#include <hdf/HDFArray.hpp>
#include <hdf/HDFGroup.hpp>
#include <pbdata/reads/HoleXY.hpp>

using namespace H5;

/*
//Note ::testing::Test not ::testing::TEST
//SetUp() and TearDown(), not Setup() and Teardown()
class HDF2DArrayTest: public :: testing::Test {
public:
    virtual void SetUp() {
    }
    virtual void TearDown() {
    }
    std::string x;
};

TEST_F(HDF2DArrayTest, x) {
    EXPECT_TRUE(true);
}
*/

class HDF2DArrayTest : public ::testing::Test
{
public:
    virtual void SetUp()
    {
        fileName = baxFile2;  // Defined in testdata.h
        try {
            FileAccPropList propList;
            pbihdfFile.openFile(fileName.c_str(), H5F_ACC_RDONLY, propList);
        } catch (Exception &e) {
            std::cout << "ERROR, could not open hdf file" << fileName << ", exiting." << std::endl;
            std::exit(EXIT_FAILURE);
        }

        ASSERT_NE(rootGroup.Initialize(pbihdfFile, "/"), 0);
        ASSERT_NE(pulseDataGroup.Initialize(rootGroup, "PulseData"), 0);
        ASSERT_NE(baseCallsGroup.Initialize(pulseDataGroup, "BaseCalls"), 0);
        ASSERT_NE(zmwGroup.Initialize(baseCallsGroup, "ZMW"), 0);
    }

    virtual void TearDown()
    {
        rootGroup.Close();
        pulseDataGroup.Close();
        baseCallsGroup.Close();
        zmwGroup.Close();
        pbihdfFile.close();
    }

    std::string fileName;
    H5File pbihdfFile;
    HDFGroup rootGroup, pulseDataGroup, baseCallsGroup, zmwGroup;
};

//Test HDF2DArray, int16
TEST_F(HDF2DArrayTest, int16)
{
    HDF2DArray<int16_t> xyArray;
    xyArray.Initialize(zmwGroup, "HoleXY");
    std::vector<HoleXY> xys;
    xys.resize(10);
    for (int i = 0; i < 10; i++) {
        xyArray.Read(i, i + 1, xys[i].xy);
        ASSERT_EQ(xys[i].xy[0], 43);
        ASSERT_EQ(xys[i].xy[1], 44 + i);
    }

    int last = 54493;

    xyArray.Read(last, last + 1, xys[0].xy);
    ASSERT_EQ(xys[0].xy[0], -43);
    ASSERT_EQ(xys[0].xy[1], -44);
    xyArray.Close();
}