-
Notifications
You must be signed in to change notification settings - Fork 23
/
fastq_unittest.cpp
82 lines (70 loc) · 1.77 KB
/
fastq_unittest.cpp
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
#include <list>
#include <iostream>
#include <sstream>
#include "fastq.h"
#include "gtest/gtest.h"
#include "bxzstr.hpp"
TEST(Fastq, DefaultConstructor)
{
Fastq fq;
EXPECT_EQ(0, fq.name().compare(""));
EXPECT_EQ(0, fq.seq().compare(""));
EXPECT_EQ(0, fq.qual().compare(""));
}
TEST(Fastq, ConstructorWithValues)
{
Fastq fq("name", "ACGT", "IIGH");
EXPECT_EQ(0, fq.name().compare("name"));
EXPECT_EQ(0, fq.seq().compare("ACGT"));
EXPECT_EQ(0, fq.qual().compare("IIGH"));
}
TEST(Fastq, setValues)
{
Fastq fq;
fq.name("name");
fq.seq("ACGT");
fq.qual("IIII");
EXPECT_EQ(0, fq.name().compare("name"));
EXPECT_EQ(0, fq.seq().compare("ACGT"));
EXPECT_EQ(0, fq.qual().compare("IIII"));
}
TEST(Fastq, ReadFromFile)
{
Fastq fq;
unsigned int counter = 0;
bxz::ifstream inStream("test_files/fastq_unittest.fastq");
if (! inStream.is_open())
{
cerr << "Error opening test file test_files/fastq_unittest.fastq" << endl;
exit(1);
}
while (fq.fillFromFile(inStream))
{
counter++;
ostringstream stream;
stream << counter;
string expectedName = stream.str();
EXPECT_EQ(0, fq.name().compare(expectedName));
EXPECT_EQ(0, fq.seq().compare("ACGT"));
}
}
TEST(Fastq, ReadFromGzFile)
{
Fastq fq;
unsigned int counter = 0;
bxz::ifstream inStream("test_files/fastq_unittest.fastq.gz");
if (! inStream.is_open())
{
cerr << "Error opening test file test_files/fastq_unittest.fastq.gz" << endl;
exit(1);
}
while (fq.fillFromFile(inStream))
{
counter++;
ostringstream stream;
stream << counter;
string expectedName = stream.str();
EXPECT_EQ(0, fq.name().compare(expectedName));
EXPECT_EQ(0, fq.seq().compare("ACGT"));
}
}