File: utils_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 (40 lines) | stat: -rw-r--r-- 1,067 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
/*
 * =====================================================================================
 *
 *       Filename:  utils_gtest.cpp
 *
 *    Description:  Test pbdata/utils.hpp
 *
 *        Version:  1.0
 *        Created:  08/19/2014 05:22:58 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Yuan Li (yli), yli@pacificbiosciences.com
 *        Company:  Pacific Biosciences
 *
 * =====================================================================================
 */

#include <fstream>
#include <string>

#include <gtest/gtest.h>

#include <pbdata/utils.hpp>

TEST(UTILS, CrucialOpen)
{
    std::ifstream ifs;
    std::string filename = "/nonexistingdir/nonexistingfile";
    //Expected behavour: exit with a message.
    EXPECT_EXIT(CrucialOpen(filename, ifs, std::ios::in), ::testing::ExitedWithCode(1), "");
}

TEST(UTILS, CeilOfFraction)
{
    EXPECT_EQ(CeilOfFraction<int>(7, 100), 1);
    EXPECT_EQ(CeilOfFraction<int>(100, 7), 15);
    EXPECT_EQ(CeilOfFraction<int>(100, 99), 2);
    EXPECT_EQ(CeilOfFraction<int>(100, 5), 20);
}