• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- DirIteratorTest.cpp ------------------------------------------------===//
2 //
3 //                     The MCLinker Project
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 #include "mcld/Support/Directory.h"
10 #include "DirIteratorTest.h"
11 #include "errno.h"
12 
13 using namespace mcld;
14 using namespace mcld::sys::fs;
15 using namespace mcldtest;
16 
17 
18 // Constructor can do set-up work for all test here.
DirIteratorTest()19 DirIteratorTest::DirIteratorTest()
20 {
21   //FIXME:Some bugs modifies the global value "errno" to non-zero.
22   //      This makes readir() failed when daily build system runs unittest
23   //      Remove this after fixing those bugs
24   errno = 0;
25 
26   // create testee. modify it if need
27   m_pDir = new mcld::sys::fs::Directory(".");
28 }
29 
30 // Destructor can do clean-up work that doesn't throw exceptions here.
~DirIteratorTest()31 DirIteratorTest::~DirIteratorTest()
32 {
33   delete m_pDir;
34 }
35 
36 // SetUp() will be called immediately before each test.
SetUp()37 void DirIteratorTest::SetUp()
38 {
39 }
40 
41 // TearDown() will be called immediately after each test.
TearDown()42 void DirIteratorTest::TearDown()
43 {
44 }
45 
46 //==========================================================================//
47 // Testcases
48 //
TEST_F(DirIteratorTest,open_dir)49 TEST_F( DirIteratorTest, open_dir ) {
50 	ASSERT_TRUE( m_pDir->isGood() );
51 
52   Directory::iterator entry = m_pDir->begin();
53   Directory::iterator enEnd = m_pDir->end();
54 
55   size_t size = 0;
56   while( entry!=enEnd ) {
57     if (0 != entry.path())
58       size = entry.path()->native().size();
59 
60     ++entry;
61   }
62 }
63 
64 
65