Пример #1
0
    def test_counter(self):
        node = HeaderNode("file.hpp")
        self.assertEqual(node.getCounter(), 0)

        node.setCounter(1)
        self.assertEqual(node.getCounter(), 1)

        node.setCounter(2)
        self.assertEqual(node.getCounter(), 2)
Пример #2
0
    def test_included(self):
        node = HeaderNode("file.hpp")
        self.assertFalse(node.isIncluded())

        node.setIncluded(True)
        self.assertTrue(node.isIncluded())

        node.setIncluded(False)
        self.assertFalse(node.isIncluded())
Пример #3
0
    def test_counter( self ):
        node = HeaderNode( "file.hpp" )
        self.assertEqual( node.getCounter(), 0 )

        node.setCounter( 1 )
        self.assertEqual( node.getCounter(), 1 )

        node.setCounter( 2 )
        self.assertEqual( node.getCounter(), 2 )
Пример #4
0
    def test_included( self ):
        node = HeaderNode( "file.hpp" )
        self.assertFalse( node.isIncluded() )

        node.setIncluded( True )
        self.assertTrue( node.isIncluded() )

        node.setIncluded( False )
        self.assertFalse( node.isIncluded() )
Пример #5
0
    def test_init(self):
        node = HeaderNode("file.hpp")

        self.assertEqual(node.getData(), "file.hpp")
        self.assertEqual(len(node.getChildren()), 0)
        self.assertEqual(len(node.getParents()), 0)

        self.assertFalse(node.isIncluded())
        self.assertEqual(node.getCounter(), 0)
Пример #6
0
    def test_threshold_5( self ):
        options = processArgv( [ "-t", "80", "-p", "/project", "test.cpp", "test.cpp", "test.cpp" ] )

        inPCH = ShouldBeInPCH( options )

        parent = HeaderNode( "root" )
        
        node = HeaderNode( "test.hpp" )
        node.addParent( parent )
        node.setCounter( 2 )
        
        self.assertEqual( inPCH( node ), True )
Пример #7
0
    def test_application_header_2( self ):
        options = processArgv( [ "-p", "/project", "test.cpp" ] )

        inPCH = ShouldBeInPCH( options )

        parent = HeaderNode( "root" )

        node = HeaderNode( "/project/main.hpp" )
        node.addParent( parent )
        node.setCounter( 1 )

        self.assertEqual( inPCH( node ), False )
Пример #8
0
    def test_init( self ):
        node = HeaderNode( "file.hpp" )

        self.assertEqual( node.getData(), "file.hpp" )
        self.assertEqual( len( node.getChildren() ), 0 )
        self.assertEqual( len( node.getParents() ), 0 )

        self.assertFalse( node.isIncluded() )
        self.assertEqual( node.getCounter(), 0 )
Пример #9
0
    def test_exclude_except( self ):
        options = processArgv( [ "-e", "boost", "-x", "thread", "shared_ptr", "-p", "/project", "--", "test.cpp" ] )

        inPCH = ShouldBeInPCH( options )

        parent = HeaderNode( "root" )
        
        node1 = HeaderNode( "boost/tokenizer" )
        node1.addParent( parent )
        node1.setCounter( 1 )

        self.assertEqual( inPCH( node1 ), False )
        
        node2 = HeaderNode( "/boost/thread" )
        node2.addParent( parent )
        node2.setCounter( 1 )

        self.assertEqual( inPCH( node2 ), True )
        
        node3 = HeaderNode( "/boost/shared_ptr" )
        node3.addParent( parent )
        
        self.assertEqual( inPCH( node3 ), True )
        
        node4 = HeaderNode( "/stl/..." )
        node4.addParent( parent )
        
        self.assertEqual( inPCH( node4 ), True )
Пример #10
0
    def test_exclude( self ):
        options = processArgv( [ "-e", "boost", "-p", "/project", "--", "test.cpp" ] )

        inPCH = ShouldBeInPCH( options )

        parent = HeaderNode( "root" )
        
        node1 = HeaderNode( "boost/..." )
        node1.addParent( parent )
        node1.setCounter( 1 )

        self.assertEqual( inPCH( node1 ), False )
        
        node2 = HeaderNode( ".../boost/..." )
        node2.addParent( parent )
        node2.setCounter( 1 )

        self.assertEqual( inPCH( node2 ), False )
        
        node3 = HeaderNode( "/stl/..." )
        node3.addParent( parent )
        
        self.assertEqual( inPCH( node3 ), True )
Пример #11
0
    def test_application_header_3( self ):
        options = processArgv( [ "-p", "test", "test.cpp" ] )

        inPCH = ShouldBeInPCH( options )

        parent = HeaderNode( "root" )

        node = HeaderNode( "test.hpp" )
        node.addParent( parent )
        node.setCounter( 1 )

        deepNode = HeaderNode( "test.impl.hpp" )
        deepNode.addParent( node )
        deepNode.setCounter( 1 )

        self.assertEqual( inPCH( deepNode ), False )