File: StringUtils_gtest.cpp

package info (click to toggle)
pbseqlib 0~20161219-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,924 kB
  • ctags: 5,123
  • sloc: cpp: 82,727; makefile: 305; python: 239; sh: 8
file content (80 lines) | stat: -rw-r--r-- 2,165 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
/*
 * ==================================================================
 *
 *       Filename:  StringUtils_gtest.cpp
 *
 *    Description:  Test pbdata/StringUtils.hpp
 *
 *        Version:  1.0
 *        Created:  03/28/2015 03:54:55 PM
 *       Compiler:  gcc
 *
 *         Author:  Yuan Li (yli), yli@pacificbiosciences.com
 *        Company:  Pacific Biosciences
 *
 * ==================================================================
 */
#include "gtest/gtest.h"
#include "reads/ReadType.hpp"
#include "StringUtils.hpp"

using namespace std;


TEST(StringUtilTest, MakeReadGroupId) {

    string movieName = "m140905_042212_sidney_c100564852550000001823085912221377_s1_X0";
    ReadType::ReadTypeEnum readType = ReadType::SUBREAD;
    string expectedReadGroupId = "b89a4406";
    EXPECT_EQ(MakeReadGroupId(movieName, readType), expectedReadGroupId);

    movieName = "movie32";
    readType = ReadType::CCS;
    expectedReadGroupId = "f5b4ffb6";
    EXPECT_EQ(MakeReadGroupId(movieName, readType), expectedReadGroupId);
}

TEST(StringUtilTest, Splice) {
    vector<string> tokens;

    Splice("movie/zmw/0_1", "/", tokens);
    vector<string> exp = {"movie", "zmw", "0_1"};
    EXPECT_EQ(tokens, exp); 

    string test = "abc,ef,12,4";
    Splice(test, ",", tokens);
    exp = vector<string>{"abc", "ef", "12", "4"};
    EXPECT_EQ(tokens, exp); 
    
    Splice(test, "ef,", tokens);
    exp = vector<string>{"abc,", "12,4"};
    EXPECT_EQ(tokens, exp);

    Splice("", ",", tokens);
    exp = vector<string>{""};
    EXPECT_EQ(tokens, exp); 

    Splice(",", ",", tokens);
    exp = vector<string>{"", ""};
    EXPECT_EQ(tokens, exp); 
    
    Splice(",abc,", ",", tokens);
    exp = vector<string>{"", "abc", ""};
    EXPECT_EQ(tokens, exp); 

    Splice("abc,", ",", tokens);
    exp = vector<string>{"abc", ""};
    EXPECT_EQ(tokens, exp); 

    Splice(",abc", ",",  tokens);
    exp = vector<string>{"", "abc"};
    EXPECT_EQ(tokens, exp); 

    Splice("abc", "abc",  tokens);
    exp = vector<string>{"", ""};
    EXPECT_EQ(tokens, exp); 

    Splice("a\tb\tc", "\t",  tokens);
    exp = vector<string>{"a", "b", "c"};
    EXPECT_EQ(tokens, exp); 
}