~eda-qa/dhlib/main

« back to all changes in this revision

Viewing changes to app-words/words/test/PermuteTest.mhx

  • Committer: edA-qa mort-ora-y
  • Date: 2010-02-16 05:36:32 UTC
  • Revision ID: eda-qa@disemia.com-20100216053632-60lt7fndfi3fgblw
first

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* <license>
 
2
 * This file is part of the dis-Emi-A HaXe Library. Copyright © edA-qa mort-ora-y
 
3
 * For full copyright and license information please refer to doc/license.txt.
 
4
 * </license> 
 
5
 */
 
6
package words.test;
 
7
 
 
8
class PermuteTest extends haxe.unit.TestCaseX
 
9
{
 
10
        static var allABC = [
 
11
                "abc",
 
12
                "acb",
 
13
                "bac",
 
14
                "bca",
 
15
                "cab",
 
16
                "cba",
 
17
                "ab",
 
18
                "ac",
 
19
                "ba",
 
20
                "bc",
 
21
                "ca",
 
22
                "cb",
 
23
                "a",
 
24
                "b",
 
25
                "c"
 
26
                ];
 
27
        public function testString()
 
28
        {
 
29
                var tree = words.PermutationTree.withString( "abc" );
 
30
                var all = new Hash<Bool>();
 
31
                
 
32
                var node = tree.root();
 
33
                do
 
34
                {
 
35
                        all.set( node.stringToHere(), true );
 
36
                } while( node.childFirstStep() );
 
37
 
 
38
                //inclusive
 
39
                for( w in allABC )
 
40
                        assertTrue( all.exists( w ) );
 
41
                        
 
42
                //exclusive
 
43
                var abcHash = HashUtil.fromArrayValue( allABC, true );
 
44
                for( w in  all.keys() )
 
45
                        assertTrue( abcHash.exists( w ) );
 
46
        }
 
47
}