File: FASTQSequence_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 (74 lines) | stat: -rw-r--r-- 2,112 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
/*
 * =====================================================================================
 *
 *       Filename:  FASTQSequence_gtest.cpp
 *
 *    Description:  Test pbdata/FASTQSequence.hpp
 *
 *        Version:  1.0
 *        Created:  1/13/2017 05:19:13 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Yuan Li (yli), yli@pacificbiosciences.com
 *        Company:  Pacific Biosciences
 *
 * =====================================================================================
 */

#include <climits>
#include <fstream>
#include <iostream>

#include <gtest/gtest.h>

#include <pbdata/FASTQSequence.hpp>

class FASTQSequenceTest : public ::testing::Test
{
public:
    virtual void SetUp() {}

    virtual void TearDown() { fastqOne.Free(); }

    FASTQSequence fastqOne;

    std::streambuf* sbuf;
    std::ofstream ofs;
};

TEST_F(FASTQSequenceTest, ReverseComplementSelf)
{
    EXPECT_TRUE(fastqOne.title == NULL);
    EXPECT_TRUE(fastqOne.titleLength == 0);
    EXPECT_TRUE(fastqOne.seq == NULL);
    EXPECT_TRUE(fastqOne.length == 0);
    EXPECT_FALSE(fastqOne.deleteOnExit);
    EXPECT_TRUE(fastqOne.qual.Empty());
    EXPECT_TRUE(fastqOne.deletionQV.Empty());
    EXPECT_TRUE(fastqOne.insertionQV.Empty());
    EXPECT_TRUE(fastqOne.substitutionQV.Empty());
    EXPECT_TRUE(fastqOne.mergeQV.Empty());
    EXPECT_TRUE(fastqOne.preBaseDeletionQV.Empty());
    EXPECT_EQ(fastqOne.GetStorageSize(), 0);

    const std::string name = "fastq_seq_one comments";
    const std::string s = "TTAGCTAG";
    const std::string q = "23!abcde";
    const std::string r = "CTAGCTAA";
    const std::string rq = "edcba!32";
    fastqOne.CopyTitle(name);

    EXPECT_EQ(fastqOne.title, name);
    static_cast<FASTASequence*>(&fastqOne)->Copy(s);
    EXPECT_EQ(fastqOne.length, s.size());

    fastqOne.qual.Copy(q);
    EXPECT_EQ(fastqOne.qual.ToString(), q);

    // Test ReverseComplementSelf()
    fastqOne.ReverseComplementSelf();
    EXPECT_EQ(memcmp(fastqOne.seq, r.c_str(), r.size() * sizeof(char)), 0);
    EXPECT_EQ(fastqOne.title, name);
    EXPECT_EQ(fastqOne.qual.ToString(), rq);
}