# | Line 4 | Line 4 | CPPUNIT_TEST_SUITE_REGISTRATION( NextCombinationTestCa | |
---|---|---|
4 | ||
5 | // Registers the fixture into the 'registry' | |
6 | CPPUNIT_TEST_SUITE_REGISTRATION( NextCombinationTestCase); | |
7 | + | |
8 | + | |
9 | void NextCombinationTestCase::testNextCombination() { | |
10 | < | std::vector<double> dv; |
11 | < | std::vector<std::vector<double>::iterator> ic; |
10 | > | 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 | ||
18 | < | while (next_combination(ic, dv.begin(), dv.end())) { |
18 | > | 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 | ||
27 | < | |
27 | > | 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 | > | |
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 | } | |
53 | + |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |