libStatGen Software  1
TrimSequence_test.cpp
00001 /*
00002  *  Copyright (C) 2010  Regents of the University of Michigan
00003  *
00004  *   This program is free software: you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation, either version 3 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   This program is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 #include <string>
00018 #include <TrimSequence.h>
00019 
00020 #include <gtest/gtest.h>
00021 
00022 TEST(TrimSequenceTest, trimSequenceTest)
00023 {
00024     std::string test;
00025     std::string::iterator result;
00026 
00027     test = "445566";
00028     result = trimSequence(test, '5', true);
00029     EXPECT_EQ(result - test.begin() , 2);
00030 
00031     test = "445554555";
00032     result = trimSequence(test, '5', true);
00033     EXPECT_EQ(result - test.begin(), 6);
00034 
00035     test = "4455545556";
00036     result = trimSequence(test, '5', true);
00037     EXPECT_EQ(result - test.begin(), 6);
00038 
00039     test = "44555455566";
00040     result = trimSequence(test, '5', true);
00041     EXPECT_EQ(result - test.begin(), 6);
00042 
00043     test = "665544";
00044     result = trimSequence(test, '5', false);
00045     EXPECT_EQ(test.end() - result , 2);
00046 
00047     test = "555455544";
00048     result = trimSequence(test, '5', false);
00049     EXPECT_EQ(test.end() - result, 6);
00050 
00051     test = "6555455544";
00052     result = trimSequence(test, '5', false);
00053     EXPECT_EQ(test.end() - result, 6);
00054 
00055     // Paul's test cases in TrimSequence.cpp 
00056     //
00057     // from the left:
00058     //
00059     test = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
00060     result = trimSequence(test, 'A', true);
00061     EXPECT_TRUE(result == test.begin());
00062 
00063     test = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
00064     result = trimSequence(test, '~', true);
00065     EXPECT_TRUE(result == test.end());
00066 
00067     test = "AAAAABCDEFGHIJKLMNOPQRSTUVWXYZ";
00068     result = trimSequence(test, 'B', true);
00069     EXPECT_TRUE(result == (test.begin() + 5));
00070 
00071     test = "AAAAAAAABCDEFGHIJKLMNOPQRSTUVWXYZ";
00072     result = trimSequence(test, 'B', true);
00073     EXPECT_TRUE(result == (test.begin() + 8));
00074 
00075     test = "AAAAAAAABCDEFGHIJKLMNOPQRSTUVWXYZ";
00076     result = trimSequence(test, 'F', true);
00077     EXPECT_TRUE(result == (test.begin() + 12));
00078 
00079     test = "AAAAAAAABCDEFGHIJKLMNOPQRSTUVWXYZ";
00080     result = trimSequence(test, '@', true);
00081     EXPECT_TRUE(result == (test.begin() + 0));
00082 
00083     test = "AAAAAAAABCDEFGHIJKLMNOPQRSTUVWXYZ";
00084     result = trimSequence(test, '@', true);
00085     EXPECT_TRUE(result == (test.begin() + 0));
00086 
00087     test = "AAAFAAAABCDEFGHIJKLMNOPQRSTUVWXYZ";
00088     result = trimSequence(test, 'F', true);
00089     EXPECT_TRUE(result == (test.begin() + 12));
00090 
00091     //
00092     // from the right:
00093     //
00094     test = "ZYXWVUTSRQPONMLKJIHGFEDCBA";
00095     result = trimSequence(test, 'A', false);
00096     EXPECT_TRUE(result == test.end());
00097 
00098     test = "ZYXWVUTSRQPONMLKJIHGFEDCBA";
00099     result = trimSequence(test, '~', false);
00100     EXPECT_TRUE(result == test.begin());
00101 
00102     test = "ZYXWVUTSRQPONMLKJIHGFEDCBAAAAA";
00103     result = trimSequence(test, 'B', false);
00104     EXPECT_TRUE(result == (test.end() - 5));
00105 
00106     test = "ZYXWVUTSRQPONMLKJIHGFEDCBAAAAAAA";
00107     result = trimSequence(test, 'B', false);
00108     EXPECT_TRUE(result == (test.end() - 7));
00109 
00110     test = "ZYXWVUTSRQPONMLKJIHGFEDCBAAAAAAAA";
00111     result = trimSequence(test, 'F', false);
00112     EXPECT_TRUE(result == (test.end() - 12));
00113 
00114     test = "ZYXWVUTSRQPONMLKJIHGFEDCBAAAAAAAA";
00115     result = trimSequence(test, '@', false);
00116     EXPECT_TRUE(result == (test.end() + 0));
00117 
00118     test = "ZYXWVUTSRQPONMLKJIHGFEDCBAAAAFAAA";
00119     result = trimSequence(test, 'F', false);
00120     EXPECT_TRUE(result == (test.end() - 12));
00121 };
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends