ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-3.0/test/utils/NextCombinationTestCase.cpp
Revision: 1677
Committed: Thu Oct 28 20:41:18 2004 UTC (19 years, 8 months ago) by tim
File size: 1970 byte(s)
Log Message:
ReplaceWildCard is working

File Contents

# User Rev Content
1 tim 1667 #include "utils/NextCombinationTestCase.hpp"
2     #include <iostream>
3     #include <algorithm>
4 tim 1668
5 tim 1667 // Registers the fixture into the 'registry'
6     CPPUNIT_TEST_SUITE_REGISTRATION( NextCombinationTestCase);
7 tim 1677
8    
9 tim 1667 void NextCombinationTestCase::testNextCombination() {
10 tim 1674 std::vector<int> iv;
11     std::vector<std::vector<int>::iterator> ic;
12     std::vector<std::vector<int>::iterator>::iterator i;
13     iv.push_back(0);
14     iv.push_back(1);
15     iv.push_back(4);
16     std::cout << std::endl;
17 tim 1667
18 tim 1674 std::vector<std::vector<int> > results;
19     while (next_combination(ic, iv.begin(), iv.end())) {
20     std::vector<int> v;
21     for(i = ic.begin();i != ic.end(); ++i) {
22     v.push_back(**i);
23     }
24     results.push_back(v);
25     }
26 tim 1667
27 tim 1674 CPPUNIT_ASSERT(results.size() == 7);
28     CPPUNIT_ASSERT(results[0][0] == 0 && results[0].size() == 1);
29     CPPUNIT_ASSERT(results[1][0] == 1 && results[1].size() == 1);
30     CPPUNIT_ASSERT(results[2][0] == 4 && results[2].size() == 1);
31     CPPUNIT_ASSERT(results[3][0] == 0 && results[3][1] == 1 && results[3].size() == 2);
32     CPPUNIT_ASSERT(results[4][0] == 0 && results[4][1] == 4 && results[4].size() == 2);
33     CPPUNIT_ASSERT(results[5][0] == 1 && results[5][1] == 4 && results[5].size() == 2);
34     CPPUNIT_ASSERT(results[6][0] == 0 && results[6][1] == 1 && results[6][2] == 4 && results[6].size() == 3);
35 tim 1677
36     std::vector<std::string> sv;
37     std::vector<std::vector<std::string>::iterator> sic;
38     std::vector<std::vector<std::string>::iterator>::iterator j;
39     std::vector<std::vector<std::string> > resultStrings;
40     std::vector<std::string> resultString;
41     sv.push_back("H");
42     sv.push_back("C");
43     sv.push_back("N");
44    
45     while (replaceWildCard(sic, sv, resultString)) {
46     for(std::vector<std::string>::iterator k = resultString.begin(); k != resultString.end(); ++k) {
47     std::cout << *k << "\t";
48     }
49     std::cout << std::endl;
50     resultStrings.push_back(resultString);
51     }
52 tim 1668 }
53 tim 1677