summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2014-11-26 18:48:20 -0800
committerStephen Hines <srhines@google.com>2014-11-26 18:49:58 -0800
commit37b74a387bb3993387029859c2d9d051c41c724e (patch)
treea2a5b611b47a82624fe31dc457d12533a3aaaed6 /unittests
parentdfd6c08c66b4b3d58fd28b5376478381e1a5647a (diff)
downloadmclinker-37b74a387bb3993387029859c2d9d051c41c724e.tar.gz
Update mclinker for LLVM rebase to r222494.
This corresponds to the following upstream mclinker change: commit b2f1691276052c4215abf36715d43248d6337cf8 Author: Diana Chen <mysekki@gmail.com> Date: Tue Nov 25 14:03:29 2014 +0800 option: Allow `-hash-style' can be specified zero or more times Change-Id: I332546680bb45cf9692adfa2c2d3dcdc84361afc
Diffstat (limited to 'unittests')
-rw-r--r--unittests/BinTreeTest.cpp192
-rw-r--r--unittests/BinTreeTest.h39
-rw-r--r--unittests/DirIteratorTest.cpp25
-rw-r--r--unittests/DirIteratorTest.h40
-rw-r--r--unittests/ELFBinaryReaderTest.cpp32
-rw-r--r--unittests/ELFBinaryReaderTest.h10
-rw-r--r--unittests/ELFReaderTest.cpp101
-rw-r--r--unittests/ELFReaderTest.h32
-rw-r--r--unittests/FactoriesTest.cpp338
-rw-r--r--unittests/FactoriesTest.h48
-rw-r--r--unittests/FileHandleTest.cpp23
-rw-r--r--unittests/FileHandleTest.h18
-rw-r--r--unittests/FragmentRefTest.cpp45
-rw-r--r--unittests/FragmentRefTest.h16
-rw-r--r--unittests/FragmentTest.cpp35
-rw-r--r--unittests/FragmentTest.h18
-rw-r--r--unittests/GCFactoryListTraitsTest.cpp72
-rw-r--r--unittests/GCFactoryListTraitsTest.h76
-rw-r--r--unittests/GraphTest.cpp85
-rw-r--r--unittests/GraphTest.h11
-rw-r--r--unittests/HashTableTest.cpp183
-rw-r--r--unittests/HashTableTest.h27
-rw-r--r--unittests/InputTreeTest.cpp68
-rw-r--r--unittests/InputTreeTest.h16
-rw-r--r--unittests/LDSymbolTest.cpp18
-rw-r--r--unittests/LDSymbolTest.h17
-rw-r--r--unittests/LEB128Test.cpp66
-rw-r--r--unittests/LEB128Test.h27
-rw-r--r--unittests/LinearAllocatorTest.cpp182
-rw-r--r--unittests/LinearAllocatorTest.h86
-rw-r--r--unittests/LinkerTest.cpp234
-rw-r--r--unittests/LinkerTest.h10
-rw-r--r--unittests/MCRegionFragmentTest.cpp28
-rw-r--r--unittests/MCRegionFragmentTest.h36
-rw-r--r--unittests/NamePoolTest.cpp157
-rw-r--r--unittests/NamePoolTest.h36
-rw-r--r--unittests/PathSetTest.cpp22
-rw-r--r--unittests/PathSetTest.h36
-rw-r--r--unittests/PathTest.cpp60
-rw-r--r--unittests/PathTest.h31
-rw-r--r--unittests/RTLinearAllocatorTest.cpp178
-rw-r--r--unittests/RTLinearAllocatorTest.h78
-rw-r--r--unittests/SectionDataTest.cpp30
-rw-r--r--unittests/SectionDataTest.h13
-rw-r--r--unittests/StaticResolverTest.cpp414
-rw-r--r--unittests/StaticResolverTest.h17
-rw-r--r--unittests/StringTableTest.cpp15
-rw-r--r--unittests/StringTableTest.h18
-rw-r--r--unittests/SymbolCategoryTest.cpp19
-rw-r--r--unittests/SymbolCategoryTest.h18
-rw-r--r--unittests/SymbolTableTest.cpp15
-rw-r--r--unittests/SymbolTableTest.h21
-rw-r--r--unittests/SystemUtilsTest.cpp18
-rw-r--r--unittests/SystemUtilsTest.h10
-rw-r--r--unittests/TargetMachineTest.cpp18
-rw-r--r--unittests/TargetMachineTest.h27
-rw-r--r--unittests/UniqueGCFactoryBaseTest.cpp113
-rw-r--r--unittests/UniqueGCFactoryBaseTest.h19
58 files changed, 1661 insertions, 1976 deletions
diff --git a/unittests/BinTreeTest.cpp b/unittests/BinTreeTest.cpp
index e436752..adad138 100644
--- a/unittests/BinTreeTest.cpp
+++ b/unittests/BinTreeTest.cpp
@@ -8,132 +8,121 @@
//===----------------------------------------------------------------------===//
#include "BinTreeTest.h"
-#include <mcld/ADT/TypeTraits.h>
-#include <mcld/InputTree.h>
+#include "mcld/ADT/TypeTraits.h"
+#include "mcld/InputTree.h"
#include <string>
using namespace mcld;
using namespace mcldtest;
-
// Constructor can do set-up work for all test here.
-BinTreeTest::BinTreeTest()
-{
- // create testee. modify it if need
- m_pTestee = new BinaryTree<int>();
+BinTreeTest::BinTreeTest() {
+ // create testee. modify it if need
+ m_pTestee = new BinaryTree<int>();
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-BinTreeTest::~BinTreeTest()
-{
- delete m_pTestee;
+BinTreeTest::~BinTreeTest() {
+ delete m_pTestee;
}
// SetUp() will be called immediately before each test.
-void BinTreeTest::SetUp()
-{
+void BinTreeTest::SetUp() {
}
// TearDown() will be called immediately after each test.
-void BinTreeTest::TearDown()
-{
+void BinTreeTest::TearDown() {
}
//==========================================================================//
// Testcases
//
-
/// General
-TEST_F( BinTreeTest,Two_non_null_tree_merge)
-{
+TEST_F(BinTreeTest, Two_non_null_tree_merge) {
BinaryTree<int>::iterator pos = m_pTestee->root();
- m_pTestee->join<TreeIteratorBase::Rightward>(pos,0);
+ m_pTestee->join<TreeIteratorBase::Rightward>(pos, 0);
--pos;
- m_pTestee->join<TreeIteratorBase::Rightward>(pos,1);
- m_pTestee->join<TreeIteratorBase::Leftward>(pos,1);
+ m_pTestee->join<TreeIteratorBase::Rightward>(pos, 1);
+ m_pTestee->join<TreeIteratorBase::Leftward>(pos, 1);
--pos;
- m_pTestee->join<TreeIteratorBase::Rightward>(pos,2);
- m_pTestee->join<TreeIteratorBase::Leftward>(pos,2);
+ m_pTestee->join<TreeIteratorBase::Rightward>(pos, 2);
+ m_pTestee->join<TreeIteratorBase::Leftward>(pos, 2);
- BinaryTree<int> *mergeTree = new BinaryTree<int>;
+ BinaryTree<int>* mergeTree = new BinaryTree<int>;
BinaryTree<int>::iterator pos2 = mergeTree->root();
- mergeTree->join<TreeIteratorBase::Rightward>(pos2,1);
+ mergeTree->join<TreeIteratorBase::Rightward>(pos2, 1);
--pos2;
- mergeTree->join<TreeIteratorBase::Rightward>(pos2,1);
- mergeTree->join<TreeIteratorBase::Leftward>(pos2,1);
+ mergeTree->join<TreeIteratorBase::Rightward>(pos2, 1);
+ mergeTree->join<TreeIteratorBase::Leftward>(pos2, 1);
- m_pTestee->merge<TreeIteratorBase::Rightward>(pos,*mergeTree);
+ m_pTestee->merge<TreeIteratorBase::Rightward>(pos, *mergeTree);
delete mergeTree;
- EXPECT_TRUE(m_pTestee->size()==8);
+ EXPECT_TRUE(m_pTestee->size() == 8);
}
/// ---- TEST - 2 ----
-TEST_F( BinTreeTest, A_null_tree_merge_a_non_null_tree)
-{
+TEST_F(BinTreeTest, A_null_tree_merge_a_non_null_tree) {
BinaryTree<int>::iterator pos = m_pTestee->root();
- BinaryTree<int> *mergeTree = new BinaryTree<int>;
- mergeTree->join<TreeIteratorBase::Rightward>(pos,0);
+ BinaryTree<int>* mergeTree = new BinaryTree<int>;
+ mergeTree->join<TreeIteratorBase::Rightward>(pos, 0);
--pos;
- mergeTree->join<TreeIteratorBase::Rightward>(pos,1);
- mergeTree->join<TreeIteratorBase::Leftward>(pos,1);
+ mergeTree->join<TreeIteratorBase::Rightward>(pos, 1);
+ mergeTree->join<TreeIteratorBase::Leftward>(pos, 1);
--pos;
- mergeTree->join<TreeIteratorBase::Rightward>(pos,2);
- mergeTree->join<TreeIteratorBase::Leftward>(pos,2);
+ mergeTree->join<TreeIteratorBase::Rightward>(pos, 2);
+ mergeTree->join<TreeIteratorBase::Leftward>(pos, 2);
- m_pTestee->merge<TreeIteratorBase::Rightward>(pos,*mergeTree);
+ m_pTestee->merge<TreeIteratorBase::Rightward>(pos, *mergeTree);
delete mergeTree;
- EXPECT_TRUE(m_pTestee->size()==5);
+ EXPECT_TRUE(m_pTestee->size() == 5);
}
-TEST_F( BinTreeTest, A_non_null_tree_merge_a_null_tree)
-{
+TEST_F(BinTreeTest, A_non_null_tree_merge_a_null_tree) {
BinaryTree<int>::iterator pos = m_pTestee->root();
- m_pTestee->join<TreeIteratorBase::Rightward>(pos,0);
+ m_pTestee->join<TreeIteratorBase::Rightward>(pos, 0);
--pos;
- m_pTestee->join<TreeIteratorBase::Rightward>(pos,1);
- m_pTestee->join<TreeIteratorBase::Leftward>(pos,1);
+ m_pTestee->join<TreeIteratorBase::Rightward>(pos, 1);
+ m_pTestee->join<TreeIteratorBase::Leftward>(pos, 1);
--pos;
- m_pTestee->join<TreeIteratorBase::Rightward>(pos,2);
- m_pTestee->join<TreeIteratorBase::Leftward>(pos,2);
+ m_pTestee->join<TreeIteratorBase::Rightward>(pos, 2);
+ m_pTestee->join<TreeIteratorBase::Leftward>(pos, 2);
- BinaryTree<int> *mergeTree = new BinaryTree<int>;
+ BinaryTree<int>* mergeTree = new BinaryTree<int>;
BinaryTree<int>::iterator pos2 = mergeTree->root();
- mergeTree->merge<TreeIteratorBase::Rightward>(pos2,*m_pTestee);
+ mergeTree->merge<TreeIteratorBase::Rightward>(pos2, *m_pTestee);
- //delete m_pTestee;
- EXPECT_TRUE(mergeTree->size()==5);
+ // delete m_pTestee;
+ EXPECT_TRUE(mergeTree->size() == 5);
delete mergeTree;
}
-TEST_F( BinTreeTest, Two_null_tree_merge)
-{
+TEST_F(BinTreeTest, Two_null_tree_merge) {
BinaryTree<int>::iterator pos = m_pTestee->root();
- BinaryTree<int> *mergeTree = new BinaryTree<int>;
+ BinaryTree<int>* mergeTree = new BinaryTree<int>;
BinaryTree<int>::iterator pos2 = mergeTree->root();
- mergeTree->merge<TreeIteratorBase::Rightward>(pos2,*m_pTestee);
+ mergeTree->merge<TreeIteratorBase::Rightward>(pos2, *m_pTestee);
- //delete m_pTestee;
- EXPECT_TRUE(mergeTree->size()==0);
+ // delete m_pTestee;
+ EXPECT_TRUE(mergeTree->size() == 0);
delete mergeTree;
}
-TEST_F( BinTreeTest, DFSIterator_BasicTraversal)
-{
+TEST_F(BinTreeTest, DFSIterator_BasicTraversal) {
int a = 111, b = 10, c = 9, d = 8, e = 7;
BinaryTree<int>::iterator pos = m_pTestee->root();
- m_pTestee->join<InputTree::Inclusive>(pos,a);
+ m_pTestee->join<InputTree::Inclusive>(pos, a);
pos.move<InputTree::Inclusive>();
- m_pTestee->join<InputTree::Positional>(pos,b);
- m_pTestee->join<InputTree::Inclusive>(pos,c);
+ m_pTestee->join<InputTree::Positional>(pos, b);
+ m_pTestee->join<InputTree::Inclusive>(pos, c);
pos.move<InputTree::Inclusive>();
- m_pTestee->join<InputTree::Positional>(pos,d);
- m_pTestee->join<InputTree::Inclusive>(pos,e);
+ m_pTestee->join<InputTree::Positional>(pos, d);
+ m_pTestee->join<InputTree::Inclusive>(pos, e);
BinaryTree<int>::dfs_iterator dfs_it = m_pTestee->dfs_begin();
BinaryTree<int>::dfs_iterator dfs_end = m_pTestee->dfs_end();
@@ -148,22 +137,21 @@ TEST_F( BinTreeTest, DFSIterator_BasicTraversal)
++dfs_it;
EXPECT_EQ(10, **dfs_it);
++dfs_it;
- EXPECT_TRUE( dfs_it == dfs_end);
+ EXPECT_TRUE(dfs_it == dfs_end);
}
-TEST_F( BinTreeTest, DFSIterator_RightMostTree)
-{
+TEST_F(BinTreeTest, DFSIterator_RightMostTree) {
int a = 0, b = 1, c = 2, d = 3, e = 4;
BinaryTree<int>::iterator pos = m_pTestee->root();
- m_pTestee->join<InputTree::Inclusive>(pos,a);
+ m_pTestee->join<InputTree::Inclusive>(pos, a);
pos.move<InputTree::Inclusive>();
- m_pTestee->join<InputTree::Positional>(pos,b);
+ m_pTestee->join<InputTree::Positional>(pos, b);
pos.move<InputTree::Positional>();
- m_pTestee->join<InputTree::Positional>(pos,c);
+ m_pTestee->join<InputTree::Positional>(pos, c);
pos.move<InputTree::Positional>();
- m_pTestee->join<InputTree::Positional>(pos,d);
+ m_pTestee->join<InputTree::Positional>(pos, d);
pos.move<InputTree::Positional>();
- m_pTestee->join<InputTree::Positional>(pos,e);
+ m_pTestee->join<InputTree::Positional>(pos, e);
BinaryTree<int>::dfs_iterator dfs_it = m_pTestee->dfs_begin();
BinaryTree<int>::dfs_iterator dfs_end = m_pTestee->dfs_end();
@@ -178,36 +166,33 @@ TEST_F( BinTreeTest, DFSIterator_RightMostTree)
++dfs_it;
ASSERT_EQ(4, **dfs_it);
++dfs_it;
- ASSERT_TRUE( dfs_it == dfs_end);
+ ASSERT_TRUE(dfs_it == dfs_end);
}
-
-TEST_F( BinTreeTest, DFSIterator_SingleNode)
-{
+TEST_F(BinTreeTest, DFSIterator_SingleNode) {
BinaryTree<int>::iterator pos = m_pTestee->root();
- m_pTestee->join<InputTree::Inclusive>(pos,0);
+ m_pTestee->join<InputTree::Inclusive>(pos, 0);
BinaryTree<int>::dfs_iterator dfs_it = m_pTestee->dfs_begin();
BinaryTree<int>::dfs_iterator dfs_end = m_pTestee->dfs_end();
int counter = 0;
- while( dfs_it != dfs_end ) {
+ while (dfs_it != dfs_end) {
++counter;
++dfs_it;
}
ASSERT_EQ(1, counter);
}
-TEST_F( BinTreeTest, BFSIterator_BasicTraversal)
-{
+TEST_F(BinTreeTest, BFSIterator_BasicTraversal) {
int a = 111, b = 10, c = 9, d = 8, e = 7;
BinaryTree<int>::iterator pos = m_pTestee->root();
- m_pTestee->join<InputTree::Inclusive>(pos,a);
+ m_pTestee->join<InputTree::Inclusive>(pos, a);
pos.move<InputTree::Inclusive>();
- m_pTestee->join<InputTree::Positional>(pos,b);
- m_pTestee->join<InputTree::Inclusive>(pos,c);
+ m_pTestee->join<InputTree::Positional>(pos, b);
+ m_pTestee->join<InputTree::Inclusive>(pos, c);
pos.move<InputTree::Inclusive>();
- m_pTestee->join<InputTree::Positional>(pos,d);
- m_pTestee->join<InputTree::Inclusive>(pos,e);
+ m_pTestee->join<InputTree::Positional>(pos, d);
+ m_pTestee->join<InputTree::Inclusive>(pos, e);
BinaryTree<int>::bfs_iterator bfs_it = m_pTestee->bfs_begin();
BinaryTree<int>::bfs_iterator bfs_end = m_pTestee->bfs_end();
@@ -222,24 +207,23 @@ TEST_F( BinTreeTest, BFSIterator_BasicTraversal)
++bfs_it;
ASSERT_EQ(7, **bfs_it);
++bfs_it;
- ASSERT_TRUE(bfs_it == bfs_end);
+ ASSERT_TRUE(bfs_it == bfs_end);
bfs_it = m_pTestee->bfs_begin();
bfs_end = m_pTestee->bfs_end();
}
-TEST_F( BinTreeTest, BFSIterator_RightMostTree)
-{
+TEST_F(BinTreeTest, BFSIterator_RightMostTree) {
int a = 0, b = 1, c = 2, d = 3, e = 4;
BinaryTree<int>::iterator pos = m_pTestee->root();
- m_pTestee->join<InputTree::Inclusive>(pos,a);
+ m_pTestee->join<InputTree::Inclusive>(pos, a);
pos.move<InputTree::Inclusive>();
- m_pTestee->join<InputTree::Positional>(pos,b);
+ m_pTestee->join<InputTree::Positional>(pos, b);
pos.move<InputTree::Positional>();
- m_pTestee->join<InputTree::Positional>(pos,c);
+ m_pTestee->join<InputTree::Positional>(pos, c);
pos.move<InputTree::Positional>();
- m_pTestee->join<InputTree::Positional>(pos,d);
+ m_pTestee->join<InputTree::Positional>(pos, d);
pos.move<InputTree::Positional>();
- m_pTestee->join<InputTree::Positional>(pos,e);
+ m_pTestee->join<InputTree::Positional>(pos, e);
BinaryTree<int>::bfs_iterator bfs_it = m_pTestee->bfs_begin();
BinaryTree<int>::bfs_iterator bfs_end = m_pTestee->bfs_end();
@@ -254,38 +238,35 @@ TEST_F( BinTreeTest, BFSIterator_RightMostTree)
++bfs_it;
ASSERT_EQ(4, **bfs_it);
++bfs_it;
- ASSERT_TRUE( bfs_it == bfs_end);
+ ASSERT_TRUE(bfs_it == bfs_end);
}
-
-TEST_F( BinTreeTest, BFSIterator_SingleNode)
-{
+TEST_F(BinTreeTest, BFSIterator_SingleNode) {
BinaryTree<int>::iterator pos = m_pTestee->root();
- m_pTestee->join<InputTree::Inclusive>(pos,0);
+ m_pTestee->join<InputTree::Inclusive>(pos, 0);
BinaryTree<int>::bfs_iterator bfs_it = m_pTestee->bfs_begin();
BinaryTree<int>::bfs_iterator bfs_end = m_pTestee->bfs_end();
int counter = 0;
- while( bfs_it != bfs_end ) {
+ while (bfs_it != bfs_end) {
++counter;
++bfs_it;
}
ASSERT_EQ(1, counter);
}
-TEST_F( BinTreeTest, TreeIterator)
-{
+TEST_F(BinTreeTest, TreeIterator) {
int a = 0, b = 1, c = 2, d = 3, e = 4, f = 5;
BinaryTree<int>::iterator pos = m_pTestee->root();
- m_pTestee->join<InputTree::Inclusive>(pos,a);
+ m_pTestee->join<InputTree::Inclusive>(pos, a);
pos.move<InputTree::Inclusive>();
- m_pTestee->join<InputTree::Positional>(pos,b);
+ m_pTestee->join<InputTree::Positional>(pos, b);
pos.move<InputTree::Positional>();
- m_pTestee->join<InputTree::Inclusive>(pos,c);
- m_pTestee->join<InputTree::Positional>(pos,f);
+ m_pTestee->join<InputTree::Inclusive>(pos, c);
+ m_pTestee->join<InputTree::Positional>(pos, f);
pos.move<InputTree::Inclusive>();
- m_pTestee->join<InputTree::Positional>(pos,d);
+ m_pTestee->join<InputTree::Positional>(pos, d);
pos.move<InputTree::Positional>();
- m_pTestee->join<InputTree::Positional>(pos,e);
+ m_pTestee->join<InputTree::Positional>(pos, e);
BinaryTree<int>::iterator it = m_pTestee->begin();
BinaryTree<int>::iterator end = m_pTestee->end();
@@ -309,4 +290,3 @@ TEST_F( BinTreeTest, TreeIterator)
++it;
ASSERT_TRUE(it == end);
}
-
diff --git a/unittests/BinTreeTest.h b/unittests/BinTreeTest.h
index 7f4a7f7..0f4b26f 100644
--- a/unittests/BinTreeTest.h
+++ b/unittests/BinTreeTest.h
@@ -13,40 +13,37 @@
#include <gtest.h>
-namespace mcld
-{
+namespace mcld {
class BinTree;
-} // namespace for mcld
+} // namespace for mcld
-namespace mcldtest
-{
+namespace mcldtest {
/** \class BinTreeTest
- * \brief Make sure the interface of BinTree , such as insert , traversal , etc..
+ * \brief Make sure the interface of BinTree , such as insert , traversal ,
+ *etc..
*
* \see BinTree
*/
-class BinTreeTest : public ::testing::Test
-{
-public:
- // Constructor can do set-up work for all test here.
- BinTreeTest();
+class BinTreeTest : public ::testing::Test {
+ public:
+ // Constructor can do set-up work for all test here.
+ BinTreeTest();
- // Destructor can do clean-up work that doesn't throw exceptions here.
- virtual ~BinTreeTest();
+ // Destructor can do clean-up work that doesn't throw exceptions here.
+ virtual ~BinTreeTest();
- // SetUp() will be called immediately before each test.
- virtual void SetUp();
+ // SetUp() will be called immediately before each test.
+ virtual void SetUp();
- // TearDown() will be called immediately after each test.
- virtual void TearDown();
+ // TearDown() will be called immediately after each test.
+ virtual void TearDown();
-protected:
- mcld::BinaryTree<int>* m_pTestee;
+ protected:
+ mcld::BinaryTree<int>* m_pTestee;
};
-} // namespace of mcldtest
+} // namespace of mcldtest
#endif
-
diff --git a/unittests/DirIteratorTest.cpp b/unittests/DirIteratorTest.cpp
index 13472ac..2684466 100644
--- a/unittests/DirIteratorTest.cpp
+++ b/unittests/DirIteratorTest.cpp
@@ -6,7 +6,7 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#include <mcld/Support/Directory.h>
+#include "mcld/Support/Directory.h"
#include "DirIteratorTest.h"
#include <errno.h>
@@ -14,11 +14,9 @@ using namespace mcld;
using namespace mcld::sys::fs;
using namespace mcldtest;
-
// Constructor can do set-up work for all test here.
-DirIteratorTest::DirIteratorTest()
-{
- //FIXME:Some bugs modifies the global value "errno" to non-zero.
+DirIteratorTest::DirIteratorTest() {
+ // FIXME:Some bugs modifies the global value "errno" to non-zero.
// This makes readir() failed when daily build system runs unittest
// Remove this after fixing those bugs
errno = 0;
@@ -28,37 +26,32 @@ DirIteratorTest::DirIteratorTest()
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-DirIteratorTest::~DirIteratorTest()
-{
+DirIteratorTest::~DirIteratorTest() {
delete m_pDir;
}
// SetUp() will be called immediately before each test.
-void DirIteratorTest::SetUp()
-{
+void DirIteratorTest::SetUp() {
}
// TearDown() will be called immediately after each test.
-void DirIteratorTest::TearDown()
-{
+void DirIteratorTest::TearDown() {
}
//==========================================================================//
// Testcases
//
-TEST_F( DirIteratorTest, open_dir ) {
- ASSERT_TRUE( m_pDir->isGood() );
+TEST_F(DirIteratorTest, open_dir) {
+ ASSERT_TRUE(m_pDir->isGood());
Directory::iterator entry = m_pDir->begin();
Directory::iterator enEnd = m_pDir->end();
size_t size = 0;
- while( entry!=enEnd ) {
+ while (entry != enEnd) {
if (0 != entry.path())
size = entry.path()->native().size();
++entry;
}
}
-
-
diff --git a/unittests/DirIteratorTest.h b/unittests/DirIteratorTest.h
index ea6aaf7..20bf208 100644
--- a/unittests/DirIteratorTest.h
+++ b/unittests/DirIteratorTest.h
@@ -18,35 +18,33 @@ class Directory;
class DirIterator;
}
}
-} // namespace for mcld
+} // namespace for mcld
-namespace mcldtest
-{
+namespace mcldtest {
/** \class DirIteratorTest
* \brief
*
* \see DirIterator
*/
-class DirIteratorTest : public ::testing::Test
-{
-public:
- // Constructor can do set-up work for all test here.
- DirIteratorTest();
-
- // Destructor can do clean-up work that doesn't throw exceptions here.
- virtual ~DirIteratorTest();
-
- // SetUp() will be called immediately before each test.
- virtual void SetUp();
-
- // TearDown() will be called immediately after each test.
- virtual void TearDown();
-protected:
- mcld::sys::fs::Directory *m_pDir;
+class DirIteratorTest : public ::testing::Test {
+ public:
+ // Constructor can do set-up work for all test here.
+ DirIteratorTest();
+
+ // Destructor can do clean-up work that doesn't throw exceptions here.
+ virtual ~DirIteratorTest();
+
+ // SetUp() will be called immediately before each test.
+ virtual void SetUp();
+
+ // TearDown() will be called immediately after each test.
+ virtual void TearDown();
+
+ protected:
+ mcld::sys::fs::Directory* m_pDir;
};
-} // namespace of mcldtest
+} // namespace of mcldtest
#endif
-
diff --git a/unittests/ELFBinaryReaderTest.cpp b/unittests/ELFBinaryReaderTest.cpp
index 7792717..3fe9f3f 100644
--- a/unittests/ELFBinaryReaderTest.cpp
+++ b/unittests/ELFBinaryReaderTest.cpp
@@ -6,49 +6,44 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#include <mcld/LD/ELFBinaryReader.h>
-#include <mcld/Module.h>
-#include <mcld/LinkerScript.h>
-#include <mcld/LinkerConfig.h>
-#include <mcld/IRBuilder.h>
-#include <mcld/GeneralOptions.h>
-#include <mcld/MC/Input.h>
+#include "mcld/LD/ELFBinaryReader.h"
+#include "mcld/Module.h"
+#include "mcld/LinkerScript.h"
+#include "mcld/LinkerConfig.h"
+#include "mcld/IRBuilder.h"
+#include "mcld/GeneralOptions.h"
+#include "mcld/MC/Input.h"
#include "ELFBinaryReaderTest.h"
using namespace mcld;
using namespace mcld::test;
-
// Constructor can do set-up work for all test here.
-ELFBinaryReaderTest::ELFBinaryReaderTest()
-{
+ELFBinaryReaderTest::ELFBinaryReaderTest() {
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-ELFBinaryReaderTest::~ELFBinaryReaderTest()
-{
+ELFBinaryReaderTest::~ELFBinaryReaderTest() {
}
// SetUp() will be called immediately before each test.
-void ELFBinaryReaderTest::SetUp()
-{
+void ELFBinaryReaderTest::SetUp() {
}
// TearDown() will be called immediately after each test.
-void ELFBinaryReaderTest::TearDown()
-{
+void ELFBinaryReaderTest::TearDown() {
}
//===----------------------------------------------------------------------===//
// Testcases
//===----------------------------------------------------------------------===//
-TEST_F( ELFBinaryReaderTest, is_myformat) {
+TEST_F(ELFBinaryReaderTest, is_myformat) {
LinkerScript script;
Module module("test", script);
LinkerConfig config;
IRBuilder builder(module, config);
- ELFBinaryReader *reader = new ELFBinaryReader(builder, config);
+ ELFBinaryReader* reader = new ELFBinaryReader(builder, config);
Input input("test.bin");
@@ -61,4 +56,3 @@ TEST_F( ELFBinaryReaderTest, is_myformat) {
delete reader;
}
-
diff --git a/unittests/ELFBinaryReaderTest.h b/unittests/ELFBinaryReaderTest.h
index a9ea042..bc8ee71 100644
--- a/unittests/ELFBinaryReaderTest.h
+++ b/unittests/ELFBinaryReaderTest.h
@@ -16,9 +16,8 @@ class ELFBinaryReader;
namespace test {
-class ELFBinaryReaderTest : public ::testing::Test
-{
-public:
+class ELFBinaryReaderTest : public ::testing::Test {
+ public:
// Constructor can do set-up work for all test here.
ELFBinaryReaderTest();
@@ -32,8 +31,7 @@ public:
virtual void TearDown();
};
-} // namespace of test
-} // namespace of mcld
+} // namespace of test
+} // namespace of mcld
#endif
-
diff --git a/unittests/ELFReaderTest.cpp b/unittests/ELFReaderTest.cpp
index 1ff2a31..bacddce 100644
--- a/unittests/ELFReaderTest.cpp
+++ b/unittests/ELFReaderTest.cpp
@@ -6,48 +6,46 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#include <cstdio>
+#include "ELFReaderTest.h"
-#include <llvm/ADT/StringRef.h>
-#include <llvm/Support/ELF.h>
-#include <mcld/IRBuilder.h>
-#include <mcld/TargetOptions.h>
-#include <mcld/LD/ELFReader.h>
-#include <mcld/MC/Input.h>
-#include <mcld/Support/Path.h>
-#include <mcld/Support/MemoryArea.h>
+#include "mcld/IRBuilder.h"
+#include "mcld/TargetOptions.h"
+#include "mcld/LD/ELFReader.h"
+#include "mcld/LD/LDContext.h"
+#include "mcld/MC/Input.h"
+#include "mcld/Support/Path.h"
+#include "mcld/Support/MemoryArea.h"
#include <../lib/Target/X86/X86LDBackend.h>
#include <../lib/Target/X86/X86GNUInfo.h>
-#include "ELFReaderTest.h"
+#include <llvm/ADT/StringRef.h>
+#include <llvm/Support/ELF.h>
+
+#include <cstdio>
using namespace mcld;
using namespace mcld::sys::fs;
using namespace mcldtest;
// Constructor can do set-up work for all test here.
-ELFReaderTest::ELFReaderTest()
- : m_pInput(NULL)
-{
+ELFReaderTest::ELFReaderTest() : m_pInput(NULL) {
m_pConfig = new LinkerConfig("x86_64-linux-gnueabi");
- m_pConfig->targets().setEndian( TargetOptions::Little );
- m_pConfig->targets().setBitClass( 64 );
- Relocation::SetUp( *m_pConfig );
+ m_pConfig->targets().setEndian(TargetOptions::Little);
+ m_pConfig->targets().setBitClass(64);
+ Relocation::SetUp(*m_pConfig);
m_pScript = new LinkerScript();
- m_pInfo = new X86_64GNUInfo( m_pConfig->targets().triple() );
- m_pLDBackend = new X86_64GNULDBackend( *m_pConfig, m_pInfo );
- m_pELFReader = new ELFReader<64, true>( *m_pLDBackend );
+ m_pInfo = new X86_64GNUInfo(m_pConfig->targets().triple());
+ m_pLDBackend = new X86_64GNULDBackend(*m_pConfig, m_pInfo);
+ m_pELFReader = new ELFReader<64, true>(*m_pLDBackend);
m_pModule = new Module(*m_pScript);
- m_pIRBuilder = new IRBuilder( *m_pModule, *m_pConfig);
- m_pELFObjReader = new ELFObjectReader(*m_pLDBackend,
- *m_pIRBuilder,
- *m_pConfig);
+ m_pIRBuilder = new IRBuilder(*m_pModule, *m_pConfig);
+ m_pELFObjReader =
+ new ELFObjectReader(*m_pLDBackend, *m_pIRBuilder, *m_pConfig);
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-ELFReaderTest::~ELFReaderTest()
-{
+ELFReaderTest::~ELFReaderTest() {
delete m_pConfig;
delete m_pLDBackend;
delete m_pELFReader;
@@ -58,57 +56,54 @@ ELFReaderTest::~ELFReaderTest()
}
// SetUp() will be called immediately before each test.
-void ELFReaderTest::SetUp()
-{
+void ELFReaderTest::SetUp() {
Path path(TOPDIR);
path.append("unittests/test_x86_64.o");
m_pInput = m_pIRBuilder->ReadInput("test_x86_64", path);
- ASSERT_TRUE(NULL!=m_pInput);
+ ASSERT_TRUE(NULL != m_pInput);
ASSERT_TRUE(m_pInput->hasMemArea());
size_t hdr_size = m_pELFReader->getELFHeaderSize();
- llvm::StringRef region = m_pInput->memArea()->request(m_pInput->fileOffset(),
- hdr_size);
+ llvm::StringRef region =
+ m_pInput->memArea()->request(m_pInput->fileOffset(), hdr_size);
const char* ELF_hdr = region.begin();
bool shdr_result = m_pELFReader->readSectionHeaders(*m_pInput, ELF_hdr);
ASSERT_TRUE(shdr_result);
}
// TearDown() will be called immediately after each test.
-void ELFReaderTest::TearDown()
-{
+void ELFReaderTest::TearDown() {
}
//===----------------------------------------------------------------------===//
// Testcases
//===----------------------------------------------------------------------===//
-TEST_F( ELFReaderTest, read_section_headers ) {
+TEST_F(ELFReaderTest, read_section_headers) {
ASSERT_EQ(m_pInput->context()->numOfSections(), 13);
LDContext::const_sect_iterator iter = m_pInput->context()->sectBegin();
- ++iter; /// test section[1]
+ ++iter; /// test section[1]
ASSERT_EQ(".text", (*iter)->name());
ASSERT_EQ(llvm::ELF::SHT_PROGBITS, (*iter)->type());
ASSERT_EQ(0x40, (*iter)->offset());
ASSERT_EQ(0x15, (*iter)->size());
- ASSERT_TRUE(llvm::ELF::SHF_ALLOC & (*iter)->flag()); //AX
+ ASSERT_TRUE(llvm::ELF::SHF_ALLOC & (*iter)->flag()); // AX
ASSERT_EQ(0x4, (*iter)->align());
ASSERT_EQ(NULL, (*iter)->getLink());
ASSERT_EQ(0, (*iter)->getInfo());
}
-TEST_F( ELFReaderTest, read_symbol_and_rela )
-{
+TEST_F(ELFReaderTest, read_symbol_and_rela) {
ASSERT_TRUE(m_pInput->hasMemArea());
ASSERT_TRUE(m_pInput->hasContext());
m_pInput->setType(Input::Object);
// -- read symbols
LDSection* symtab_shdr = m_pInput->context()->getSection(".symtab");
- ASSERT_TRUE(NULL!=symtab_shdr);
+ ASSERT_TRUE(NULL != symtab_shdr);
LDSection* strtab_shdr = symtab_shdr->getLink();
- ASSERT_TRUE(NULL!=strtab_shdr);
+ ASSERT_TRUE(NULL != strtab_shdr);
llvm::StringRef symtab_region = m_pInput->memArea()->request(
m_pInput->fileOffset() + symtab_shdr->offset(), symtab_shdr->size());
@@ -116,46 +111,44 @@ TEST_F( ELFReaderTest, read_symbol_and_rela )
llvm::StringRef strtab_region = m_pInput->memArea()->request(
m_pInput->fileOffset() + strtab_shdr->offset(), strtab_shdr->size());
const char* strtab = strtab_region.begin();
- bool result = m_pELFReader->readSymbols(*m_pInput, *m_pIRBuilder,
- symtab_region, strtab);
+ bool result = m_pELFReader->readSymbols(
+ *m_pInput, *m_pIRBuilder, symtab_region, strtab);
ASSERT_TRUE(result);
ASSERT_EQ("hello.c", std::string(m_pInput->context()->getSymbol(1)->name()));
ASSERT_EQ("puts", std::string(m_pInput->context()->getSymbol(10)->name()));
- ASSERT_TRUE(NULL==m_pInput->context()->getSymbol(11));
+ ASSERT_TRUE(NULL == m_pInput->context()->getSymbol(11));
// -- read relocations
MemoryArea* mem = m_pInput->memArea();
LDContext::sect_iterator rs = m_pInput->context()->relocSectBegin();
- ASSERT_TRUE(rs!=m_pInput->context()->relocSectEnd());
+ ASSERT_TRUE(rs != m_pInput->context()->relocSectEnd());
ASSERT_EQ(".rela.text", (*rs)->name());
uint64_t offset = m_pInput->fileOffset() + (*rs)->offset();
uint64_t size = (*rs)->size();
llvm::StringRef region = mem->request(offset, size);
- IRBuilder::CreateRelocData(**rs); /// create relocation data for the header
+ IRBuilder::CreateRelocData(**rs); /// create relocation data for the header
ASSERT_EQ(llvm::ELF::SHT_RELA, (*rs)->type());
ASSERT_TRUE(m_pELFReader->readRela(*m_pInput, **rs, region));
- const RelocData::RelocationListType &rRelocs =
- (*rs)->getRelocData()->getRelocationList();
+ const RelocData::RelocationListType& rRelocs =
+ (*rs)->getRelocData()->getRelocationList();
RelocData::const_iterator rReloc = rRelocs.begin();
ASSERT_EQ(2, rRelocs.size());
- ASSERT_TRUE(rRelocs.end()!=rReloc);
- ++rReloc; /// test rRelocs[1]
+ ASSERT_TRUE(rRelocs.end() != rReloc);
+ ++rReloc; /// test rRelocs[1]
ASSERT_EQ("puts", std::string(rReloc->symInfo()->name()));
ASSERT_EQ(llvm::ELF::R_X86_64_PC32, rReloc->type());
ASSERT_EQ(0x0, rReloc->symValue());
ASSERT_EQ(-0x4, rReloc->addend());
}
-TEST_F( ELFReaderTest, read_regular_sections ) {
- ASSERT_TRUE( m_pELFObjReader->readSections(*m_pInput) );
+TEST_F(ELFReaderTest, read_regular_sections) {
+ ASSERT_TRUE(m_pELFObjReader->readSections(*m_pInput));
}
-TEST_F( ELFReaderTest, is_my_format ) {
+TEST_F(ELFReaderTest, is_my_format) {
bool doContinue;
- ASSERT_TRUE( m_pELFObjReader->isMyFormat(*m_pInput, doContinue) );
+ ASSERT_TRUE(m_pELFObjReader->isMyFormat(*m_pInput, doContinue));
}
-
-
diff --git a/unittests/ELFReaderTest.h b/unittests/ELFReaderTest.h
index abe99b1..b36eede 100644
--- a/unittests/ELFReaderTest.h
+++ b/unittests/ELFReaderTest.h
@@ -10,24 +10,23 @@
#define MCLD_ELFREADER_TEST_H
#include <gtest.h>
-#include <mcld/LinkerConfig.h>
-#include <mcld/LinkerScript.h>
-#include <mcld/LD/ELFReaderIf.h>
-#include <mcld/LD/ELFReader.h>
-#include <mcld/LD/ELFObjectReader.h>
-#include <mcld/Target/GNULDBackend.h>
-#include <mcld/MC/InputBuilder.h>
+#include "mcld/LinkerConfig.h"
+#include "mcld/LinkerScript.h"
+#include "mcld/LD/ELFReaderIf.h"
+#include "mcld/LD/ELFReader.h"
+#include "mcld/LD/ELFObjectReader.h"
+#include "mcld/Target/GNULDBackend.h"
+#include "mcld/MC/InputBuilder.h"
namespace mcld {
- template<> class ELFReader<64, true>;
-} // namespace for mcld
+template <>
+class ELFReader<64, true>;
+} // namespace for mcld
-namespace mcldtest
-{
+namespace mcldtest {
-class ELFReaderTest : public ::testing::Test
-{
-public:
+class ELFReaderTest : public ::testing::Test {
+ public:
// Constructor can do set-up work for all test here.
ELFReaderTest();
@@ -40,7 +39,7 @@ public:
// TearDown() will be called immediately after each test.
virtual void TearDown();
-protected:
+ protected:
mcld::Input* m_pInput;
mcld::LinkerConfig* m_pConfig;
mcld::LinkerScript* m_pScript;
@@ -52,7 +51,6 @@ protected:
mcld::ELFObjectReader* m_pELFObjReader;
};
-} // namespace of mcldtest
+} // namespace of mcldtest
#endif
-
diff --git a/unittests/FactoriesTest.cpp b/unittests/FactoriesTest.cpp
index 9301fb9..fdc7109 100644
--- a/unittests/FactoriesTest.cpp
+++ b/unittests/FactoriesTest.cpp
@@ -13,208 +13,200 @@
using namespace mcld;
using namespace mcldtest;
-
// Constructor can do set-up work for all test here.
-FactoriesTest::FactoriesTest()
-{
- m_pNodeAlloc = new NodeAlloc();
- m_pFileAlloc = new FileAlloc();
+FactoriesTest::FactoriesTest() {
+ m_pNodeAlloc = new NodeAlloc();
+ m_pFileAlloc = new FileAlloc();
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-FactoriesTest::~FactoriesTest()
-{
- delete m_pNodeAlloc;
- delete m_pFileAlloc;
+FactoriesTest::~FactoriesTest() {
+ delete m_pNodeAlloc;
+ delete m_pFileAlloc;
}
// SetUp() will be called immediately before each test.
-void FactoriesTest::SetUp()
-{
+void FactoriesTest::SetUp() {
}
// TearDown() will be called immediately after each test.
-void FactoriesTest::TearDown()
-{
+void FactoriesTest::TearDown() {
}
//==========================================================================//
// Testcases
//
-TEST_F( FactoriesTest, node_produce ) {
- NodeAlloc::NodeType* node = m_pNodeAlloc->produce();
- ASSERT_EQ(1, m_pNodeAlloc->size());
- ASSERT_FALSE(m_pNodeAlloc->empty());
- node = m_pNodeAlloc->produce();
- ASSERT_EQ(2, m_pNodeAlloc->size());
- ASSERT_FALSE(m_pNodeAlloc->empty());
- node = m_pNodeAlloc->produce();
- ASSERT_EQ(3, m_pNodeAlloc->size());
- ASSERT_FALSE(m_pNodeAlloc->empty());
+TEST_F(FactoriesTest, node_produce) {
+ NodeAlloc::NodeType* node = m_pNodeAlloc->produce();
+ ASSERT_EQ(1, m_pNodeAlloc->size());
+ ASSERT_FALSE(m_pNodeAlloc->empty());
+ node = m_pNodeAlloc->produce();
+ ASSERT_EQ(2, m_pNodeAlloc->size());
+ ASSERT_FALSE(m_pNodeAlloc->empty());
+ node = m_pNodeAlloc->produce();
+ ASSERT_EQ(3, m_pNodeAlloc->size());
+ ASSERT_FALSE(m_pNodeAlloc->empty());
}
-TEST_F( FactoriesTest, node_iterate ) {
- NodeAlloc::NodeType* node = 0;
- for (int i=0 ; i<100; ++i) {
- node = m_pNodeAlloc->produce();
- node->data = (int*)malloc(sizeof(int));
- *(node->data) = i;
- }
-
- int counter = 0;
- NodeAlloc::iterator data = m_pNodeAlloc->begin();
- NodeAlloc::iterator dEnd = m_pNodeAlloc->end();
- for (; data!=dEnd; ++data) {
- ASSERT_EQ(counter, *(*data).data );
- free((*data).data);
- (*data).data = 0;
- ++counter;
- }
+TEST_F(FactoriesTest, node_iterate) {
+ NodeAlloc::NodeType* node = 0;
+ for (int i = 0; i < 100; ++i) {
+ node = m_pNodeAlloc->produce();
+ node->data = (int*)malloc(sizeof(int));
+ *(node->data) = i;
+ }
+
+ int counter = 0;
+ NodeAlloc::iterator data = m_pNodeAlloc->begin();
+ NodeAlloc::iterator dEnd = m_pNodeAlloc->end();
+ for (; data != dEnd; ++data) {
+ ASSERT_EQ(counter, *(*data).data);
+ free((*data).data);
+ (*data).data = 0;
+ ++counter;
+ }
}
-TEST_F( FactoriesTest, node_delegate_empty ) {
- NodeAlloc::NodeType* node = 0;
- for (int i=0 ; i<100; ++i) {
- node = m_pNodeAlloc->produce();
- node->data = (int*)malloc(sizeof(int));
- *(node->data) = i;
- }
- NodeAlloc* delegatee = new NodeAlloc();
- m_pNodeAlloc->delegate(*delegatee);
- ASSERT_EQ(100, m_pNodeAlloc->size());
- int counter = 0;
- NodeAlloc::iterator data = m_pNodeAlloc->begin();
- NodeAlloc::iterator dEnd = m_pNodeAlloc->end();
- for (; data!=dEnd; ++data) {
- ASSERT_EQ(counter, *(*data).data );
- free((*data).data);
- (*data).data = 0;
- ++counter;
- }
- delete delegatee;
+TEST_F(FactoriesTest, node_delegate_empty) {
+ NodeAlloc::NodeType* node = 0;
+ for (int i = 0; i < 100; ++i) {
+ node = m_pNodeAlloc->produce();
+ node->data = (int*)malloc(sizeof(int));
+ *(node->data) = i;
+ }
+ NodeAlloc* delegatee = new NodeAlloc();
+ m_pNodeAlloc->delegate(*delegatee);
+ ASSERT_EQ(100, m_pNodeAlloc->size());
+ int counter = 0;
+ NodeAlloc::iterator data = m_pNodeAlloc->begin();
+ NodeAlloc::iterator dEnd = m_pNodeAlloc->end();
+ for (; data != dEnd; ++data) {
+ ASSERT_EQ(counter, *(*data).data);
+ free((*data).data);
+ (*data).data = 0;
+ ++counter;
+ }
+ delete delegatee;
}
-TEST_F( FactoriesTest, node_empty_delegate ) {
- NodeAlloc::NodeType* node = 0;
- NodeAlloc* delegatee = new NodeAlloc();
- for (int i=0 ; i<100; ++i) {
- node = delegatee->produce();
- node->data = (int*)malloc(sizeof(int));
- *(node->data) = i;
- }
- m_pNodeAlloc->delegate(*delegatee);
- ASSERT_EQ(100, m_pNodeAlloc->size());
- int counter = 0;
- NodeAlloc::iterator data = m_pNodeAlloc->begin();
- NodeAlloc::iterator dEnd = m_pNodeAlloc->end();
- for (; data!=dEnd; ++data) {
- ASSERT_EQ(counter, *(*data).data );
- free((*data).data);
- (*data).data = 0;
- ++counter;
- }
- ASSERT_EQ(0, delegatee->size());
- ASSERT_TRUE(delegatee->empty());
- delete delegatee;
+TEST_F(FactoriesTest, node_empty_delegate) {
+ NodeAlloc::NodeType* node = 0;
+ NodeAlloc* delegatee = new NodeAlloc();
+ for (int i = 0; i < 100; ++i) {
+ node = delegatee->produce();
+ node->data = (int*)malloc(sizeof(int));
+ *(node->data) = i;
+ }
+ m_pNodeAlloc->delegate(*delegatee);
+ ASSERT_EQ(100, m_pNodeAlloc->size());
+ int counter = 0;
+ NodeAlloc::iterator data = m_pNodeAlloc->begin();
+ NodeAlloc::iterator dEnd = m_pNodeAlloc->end();
+ for (; data != dEnd; ++data) {
+ ASSERT_EQ(counter, *(*data).data);
+ free((*data).data);
+ (*data).data = 0;
+ ++counter;
+ }
+ ASSERT_EQ(0, delegatee->size());
+ ASSERT_TRUE(delegatee->empty());
+ delete delegatee;
}
-TEST_F( FactoriesTest, node_delegate ) {
- NodeAlloc::NodeType* node = 0;
- NodeAlloc* delegatee = new NodeAlloc();
- int counter = 0;
- // produce agent
- for (int i=0 ; i<100; ++i) {
- node = m_pNodeAlloc->produce();
- node->data = (int*)malloc(sizeof(int));
- *(node->data) = counter;
- ++counter;
- }
-
- // produce delegatee
- for (int i=0 ; i<100; ++i) {
- node = delegatee->produce();
- node->data = (int*)malloc(sizeof(int));
- *(node->data) = counter;
- ++counter;
- }
-
- m_pNodeAlloc->delegate(*delegatee);
- ASSERT_EQ(200, m_pNodeAlloc->size());
- ASSERT_FALSE(m_pNodeAlloc->empty());
- NodeAlloc::iterator data = m_pNodeAlloc->begin();
- NodeAlloc::iterator dEnd = m_pNodeAlloc->end();
- for ( counter = 0; data!=dEnd; ++data) {
- ASSERT_EQ(counter, *(*data).data );
- free((*data).data);
- (*data).data = 0;
- ++counter;
- }
- ASSERT_EQ(0, delegatee->size());
- ASSERT_TRUE(delegatee->empty());
- delete delegatee;
+TEST_F(FactoriesTest, node_delegate) {
+ NodeAlloc::NodeType* node = 0;
+ NodeAlloc* delegatee = new NodeAlloc();
+ int counter = 0;
+ // produce agent
+ for (int i = 0; i < 100; ++i) {
+ node = m_pNodeAlloc->produce();
+ node->data = (int*)malloc(sizeof(int));
+ *(node->data) = counter;
+ ++counter;
+ }
+
+ // produce delegatee
+ for (int i = 0; i < 100; ++i) {
+ node = delegatee->produce();
+ node->data = (int*)malloc(sizeof(int));
+ *(node->data) = counter;
+ ++counter;
+ }
+
+ m_pNodeAlloc->delegate(*delegatee);
+ ASSERT_EQ(200, m_pNodeAlloc->size());
+ ASSERT_FALSE(m_pNodeAlloc->empty());
+ NodeAlloc::iterator data = m_pNodeAlloc->begin();
+ NodeAlloc::iterator dEnd = m_pNodeAlloc->end();
+ for (counter = 0; data != dEnd; ++data) {
+ ASSERT_EQ(counter, *(*data).data);
+ free((*data).data);
+ (*data).data = 0;
+ ++counter;
+ }
+ ASSERT_EQ(0, delegatee->size());
+ ASSERT_TRUE(delegatee->empty());
+ delete delegatee;
}
-TEST_F( FactoriesTest, node_delegate_self ) {
- NodeAlloc::NodeType* node = 0;
- for (int i=0 ; i<100; ++i) {
- node = m_pNodeAlloc->produce();
- node->data = (int*)malloc(sizeof(int));
- *(node->data) = i;
- }
- ASSERT_EQ(100, m_pNodeAlloc->size());
- m_pNodeAlloc->delegate(*m_pNodeAlloc);
- ASSERT_EQ(100, m_pNodeAlloc->size());
- ASSERT_FALSE(m_pNodeAlloc->empty());
+TEST_F(FactoriesTest, node_delegate_self) {
+ NodeAlloc::NodeType* node = 0;
+ for (int i = 0; i < 100; ++i) {
+ node = m_pNodeAlloc->produce();
+ node->data = (int*)malloc(sizeof(int));
+ *(node->data) = i;
+ }
+ ASSERT_EQ(100, m_pNodeAlloc->size());
+ m_pNodeAlloc->delegate(*m_pNodeAlloc);
+ ASSERT_EQ(100, m_pNodeAlloc->size());
+ ASSERT_FALSE(m_pNodeAlloc->empty());
}
-TEST_F( FactoriesTest, file_produce ) {
- int counter = 0;
- for (counter=1; counter<1000; ++counter) {
- MCLDFile* file = m_pFileAlloc->produce();
- ASSERT_EQ(counter, m_pFileAlloc->size());
- ASSERT_FALSE(m_pFileAlloc->empty());
- }
+TEST_F(FactoriesTest, file_produce) {
+ int counter = 0;
+ for (counter = 1; counter < 1000; ++counter) {
+ MCLDFile* file = m_pFileAlloc->produce();
+ ASSERT_EQ(counter, m_pFileAlloc->size());
+ ASSERT_FALSE(m_pFileAlloc->empty());
+ }
}
-TEST_F( FactoriesTest, file_produce_by_params ) {
- int counter = 0;
- for (counter=1; counter<1000; ++counter) {
- char name[100];
- sprintf(name, "file %d", counter);
- char path_name[100];
- sprintf(path_name, "/proj/mtk%d", counter);
- MCLDFile* file = m_pFileAlloc->produce( string(name),
- sys::fs::Path(string(path_name)),
- MCLDFile::Archive);
- ASSERT_EQ(counter, m_pFileAlloc->size());
- ASSERT_FALSE(m_pFileAlloc->empty());
- ASSERT_TRUE(file->isRecognized());
- ASSERT_STREQ(name, file->name().data());
- }
+TEST_F(FactoriesTest, file_produce_by_params) {
+ int counter = 0;
+ for (counter = 1; counter < 1000; ++counter) {
+ char name[100];
+ sprintf(name, "file %d", counter);
+ char path_name[100];
+ sprintf(path_name, "/proj/mtk%d", counter);
+ MCLDFile* file = m_pFileAlloc->produce(
+ string(name), sys::fs::Path(string(path_name)), MCLDFile::Archive);
+ ASSERT_EQ(counter, m_pFileAlloc->size());
+ ASSERT_FALSE(m_pFileAlloc->empty());
+ ASSERT_TRUE(file->isRecognized());
+ ASSERT_STREQ(name, file->name().data());
+ }
}
-TEST_F( FactoriesTest, file_iterate ) {
- int counter = 0;
- for (counter=1; counter<1000; ++counter) {
- char name[100];
- sprintf(name, "file %d", counter);
- char path_name[100];
- sprintf(path_name, "/proj/mtk%d", counter);
- MCLDFile* file = m_pFileAlloc->produce( string(name),
- sys::fs::Path(string(path_name)),
- MCLDFile::Archive);
- }
-
- ASSERT_EQ(counter-1, m_pFileAlloc->size());
- ASSERT_FALSE(m_pFileAlloc->empty());
-
- MCLDFileFactory::iterator file = m_pFileAlloc->begin();
- MCLDFileFactory::iterator fEnd = m_pFileAlloc->end();
-
- while (file!=fEnd) {
- ASSERT_TRUE((*file).isRecognized());
- ASSERT_FALSE((*file).name().empty());
- ++file;
- }
+TEST_F(FactoriesTest, file_iterate) {
+ int counter = 0;
+ for (counter = 1; counter < 1000; ++counter) {
+ char name[100];
+ sprintf(name, "file %d", counter);
+ char path_name[100];
+ sprintf(path_name, "/proj/mtk%d", counter);
+ MCLDFile* file = m_pFileAlloc->produce(
+ string(name), sys::fs::Path(string(path_name)), MCLDFile::Archive);
+ }
+
+ ASSERT_EQ(counter - 1, m_pFileAlloc->size());
+ ASSERT_FALSE(m_pFileAlloc->empty());
+
+ MCLDFileFactory::iterator file = m_pFileAlloc->begin();
+ MCLDFileFactory::iterator fEnd = m_pFileAlloc->end();
+
+ while (file != fEnd) {
+ ASSERT_TRUE((*file).isRecognized());
+ ASSERT_FALSE((*file).name().empty());
+ ++file;
+ }
}
-
diff --git a/unittests/FactoriesTest.h b/unittests/FactoriesTest.h
index 484b801..e89732e 100644
--- a/unittests/FactoriesTest.h
+++ b/unittests/FactoriesTest.h
@@ -12,38 +12,36 @@
#include "mcld/ADT/TreeAllocator.h"
#include "mcld/MC/MCLDFile.h"
-namespace mcldtest
-{
+namespace mcldtest {
/** \class FactoriesTest
* \brief Test cases for factories - NodeFactory and MCLDFileFactory.
*
* \see Factories
*/
-class FactoriesTest : public ::testing::Test
-{
-public:
- // Constructor can do set-up work for all test here.
- FactoriesTest();
-
- // Destructor can do clean-up work that doesn't throw exceptions here.
- virtual ~FactoriesTest();
-
- // SetUp() will be called immediately before each test.
- virtual void SetUp();
-
- // TearDown() will be called immediately after each test.
- virtual void TearDown();
-
-protected:
- typedef mcld::NodeFactory<int> NodeAlloc;
- typedef mcld::MCLDFileFactory FileAlloc;
-protected:
- NodeAlloc* m_pNodeAlloc;
- FileAlloc *m_pFileAlloc;
+class FactoriesTest : public ::testing::Test {
+ public:
+ // Constructor can do set-up work for all test here.
+ FactoriesTest();
+
+ // Destructor can do clean-up work that doesn't throw exceptions here.
+ virtual ~FactoriesTest();
+
+ // SetUp() will be called immediately before each test.
+ virtual void SetUp();
+
+ // TearDown() will be called immediately after each test.
+ virtual void TearDown();
+
+ protected:
+ typedef mcld::NodeFactory<int> NodeAlloc;
+ typedef mcld::MCLDFileFactory FileAlloc;
+
+ protected:
+ NodeAlloc* m_pNodeAlloc;
+ FileAlloc* m_pFileAlloc;
};
-} // namespace of mcldtest
+} // namespace of mcldtest
#endif
-
diff --git a/unittests/FileHandleTest.cpp b/unittests/FileHandleTest.cpp
index dc9ecdd..e810430 100644
--- a/unittests/FileHandleTest.cpp
+++ b/unittests/FileHandleTest.cpp
@@ -6,8 +6,8 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#include <mcld/Support/FileHandle.h>
-#include <mcld/Support/Path.h>
+#include "mcld/Support/FileHandle.h"
+#include "mcld/Support/Path.h"
#include <fcntl.h>
#include <errno.h>
#include "FileHandleTest.h"
@@ -15,28 +15,23 @@
using namespace mcld;
using namespace mcldtest;
-
// Constructor can do set-up work for all test here.
-FileHandleTest::FileHandleTest()
-{
+FileHandleTest::FileHandleTest() {
// create testee. modify it if need
m_pTestee = new FileHandle();
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-FileHandleTest::~FileHandleTest()
-{
+FileHandleTest::~FileHandleTest() {
delete m_pTestee;
}
// SetUp() will be called immediately before each test.
-void FileHandleTest::SetUp()
-{
+void FileHandleTest::SetUp() {
}
// TearDown() will be called immediately after each test.
-void FileHandleTest::TearDown()
-{
+void FileHandleTest::TearDown() {
}
//===----------------------------------------------------------------------===//
@@ -45,7 +40,8 @@ void FileHandleTest::TearDown()
TEST_F(FileHandleTest, open_close) {
mcld::sys::fs::Path path(TOPDIR);
path.append("unittests/test.txt");
- ASSERT_TRUE(m_pTestee->open(path, FileHandle::ReadOnly));
+ ASSERT_TRUE(m_pTestee->open(path, FileHandle::OpenMode(FileHandle::ReadOnly),
+ FileHandle::Permission(FileHandle::System)));
ASSERT_TRUE(m_pTestee->isOpened());
ASSERT_TRUE(m_pTestee->isGood());
ASSERT_TRUE(m_pTestee->isOwned());
@@ -86,7 +82,8 @@ TEST_F(FileHandleTest, delegate_close) {
TEST_F(FileHandleTest, fail_close) {
mcld::sys::fs::Path path(TOPDIR);
path.append("unittests/test.txt");
- ASSERT_TRUE(m_pTestee->open(path, FileHandle::ReadOnly));
+ ASSERT_TRUE(m_pTestee->open(path, FileHandle::OpenMode(FileHandle::ReadOnly),
+ FileHandle::Permission(FileHandle::System)));
ASSERT_TRUE(m_pTestee->isOpened());
ASSERT_TRUE(m_pTestee->isGood());
diff --git a/unittests/FileHandleTest.h b/unittests/FileHandleTest.h
index 45d4ab1..650c97d 100644
--- a/unittests/FileHandleTest.h
+++ b/unittests/FileHandleTest.h
@@ -11,23 +11,20 @@
#include <gtest.h>
-namespace mcld
-{
+namespace mcld {
class FileHandle;
-} // namespace for mcld
+} // namespace for mcld
-namespace mcldtest
-{
+namespace mcldtest {
/** \class FileHandleTest
* \brief
*
* \see FileHandle
*/
-class FileHandleTest : public ::testing::Test
-{
-public:
+class FileHandleTest : public ::testing::Test {
+ public:
// Constructor can do set-up work for all test here.
FileHandleTest();
@@ -40,11 +37,10 @@ public:
// TearDown() will be called immediately after each test.
virtual void TearDown();
-protected:
+ protected:
mcld::FileHandle* m_pTestee;
};
-} // namespace of mcldtest
+} // namespace of mcldtest
#endif
-
diff --git a/unittests/FragmentRefTest.cpp b/unittests/FragmentRefTest.cpp
index 881cdb8..a067542 100644
--- a/unittests/FragmentRefTest.cpp
+++ b/unittests/FragmentRefTest.cpp
@@ -8,12 +8,12 @@
//===----------------------------------------------------------------------===//
#include "FragmentRefTest.h"
-#include <mcld/Fragment/FragmentRef.h>
-#include <mcld/Fragment/RegionFragment.h>
-#include <mcld/Support/MemoryAreaFactory.h>
-#include <mcld/Support/FileHandle.h>
-#include <mcld/Support/MemoryRegion.h>
-#include <mcld/Support/Path.h>
+#include "mcld/Fragment/FragmentRef.h"
+#include "mcld/Fragment/RegionFragment.h"
+#include "mcld/Support/MemoryAreaFactory.h"
+#include "mcld/Support/FileHandle.h"
+#include "mcld/Support/MemoryRegion.h"
+#include "mcld/Support/Path.h"
#include <llvm/ADT/StringRef.h>
using namespace mcld;
@@ -21,50 +21,49 @@ using namespace mcld::sys::fs;
using namespace mcldtest;
// Constructor can do set-up work for all test here.
-FragmentRefTest::FragmentRefTest()
-{
+FragmentRefTest::FragmentRefTest() {
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-FragmentRefTest::~FragmentRefTest()
-{
+FragmentRefTest::~FragmentRefTest() {
}
// SetUp() will be called immediately before each test.
-void FragmentRefTest::SetUp()
-{
+void FragmentRefTest::SetUp() {
}
// TearDown() will be called immediately after each test.
-void FragmentRefTest::TearDown()
-{
+void FragmentRefTest::TearDown() {
}
-//==========================================================================//
+//============================================================================//
// Testcases
//
-TEST_F( FragmentRefTest, ) {
+TEST_F(FragmentRefTest, ) {
Path path(TOPDIR);
path.append("unittests/test3.txt");
MemoryAreaFactory* areaFactory = new MemoryAreaFactory(1);
- MemoryArea* area = areaFactory->produce(path, FileHandle::ReadWrite);
+ MemoryArea* area =
+ areaFactory->produce(path, FileHandle::OpenMode(FileHandle::ReadWrite),
+ FileHandle::Permission(FileHandle::System));
llvm::StringRef region = area->request(0, 4096);
- RegionFragment *frag = new RegionFragment(region);
- FragmentRef *ref = FragmentRef::Create(*frag, 0x0);
+ RegionFragment* frag = new RegionFragment(region);
+ FragmentRef* ref = FragmentRef::Create(*frag, 0x0);
ASSERT_EQ('H', region.data()[0]);
ASSERT_TRUE(4096 == region.size());
ASSERT_EQ('H', frag->getRegion().data()[0]);
ASSERT_TRUE(4096 == frag->getRegion().size());
ASSERT_EQ(frag, ref->frag());
- ASSERT_EQ('H', static_cast<RegionFragment*>(ref->frag())->getRegion().data()[0]);
- ASSERT_TRUE(4096 == static_cast<RegionFragment*>(ref->frag())->getRegion().size());
- //ASSERT_EQ('H', ref->deref()[0]);
+ ASSERT_EQ('H',
+ static_cast<RegionFragment*>(ref->frag())->getRegion().data()[0]);
+ ASSERT_TRUE(4096 ==
+ static_cast<RegionFragment*>(ref->frag())->getRegion().size());
+ // ASSERT_EQ('H', ref->deref()[0]);
ASSERT_TRUE(RegionFragment::classof(frag));
delete frag;
delete areaFactory;
}
-
diff --git a/unittests/FragmentRefTest.h b/unittests/FragmentRefTest.h
index 17de587..c5e8d91 100644
--- a/unittests/FragmentRefTest.h
+++ b/unittests/FragmentRefTest.h
@@ -12,23 +12,20 @@
#include <gtest.h>
-namespace mcld
-{
+namespace mcld {
class FragmentRef;
-} // namespace for mcld
+} // namespace for mcld
-namespace mcldtest
-{
+namespace mcldtest {
/** \class FragmentRefTest
* \brief Reference Test
*
* \see FragmentRef
*/
-class FragmentRefTest : public ::testing::Test
-{
-public:
+class FragmentRefTest : public ::testing::Test {
+ public:
// Constructor can do set-up work for all test here.
FragmentRefTest();
@@ -42,7 +39,6 @@ public:
virtual void TearDown();
};
-} // namespace of mcldtest
+} // namespace of mcldtest
#endif
-
diff --git a/unittests/FragmentTest.cpp b/unittests/FragmentTest.cpp
index 273c98d..ae93015 100644
--- a/unittests/FragmentTest.cpp
+++ b/unittests/FragmentTest.cpp
@@ -1,4 +1,4 @@
-//===- FragmentTest.cpp -------------------------------------------------------===//
+//===- FragmentTest.cpp ---------------------------------------------------===//
//
// The MCLinker Project
//
@@ -8,38 +8,33 @@
//===----------------------------------------------------------------------===//
#include "FragmentTest.h"
-#include <mcld/Fragment/Fragment.h>
-#include <mcld/LD/SectionData.h>
-#include <mcld/LD/LDSection.h>
+#include "mcld/Fragment/Fragment.h"
+#include "mcld/LD/SectionData.h"
+#include "mcld/LD/LDSection.h"
using namespace mcld;
using namespace mcldtest;
-
// Constructor can do set-up work for all test here.
-FragmentTest::FragmentTest()
-{
+FragmentTest::FragmentTest() {
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-FragmentTest::~FragmentTest()
-{
+FragmentTest::~FragmentTest() {
}
// SetUp() will be called immediately before each test.
-void FragmentTest::SetUp()
-{
+void FragmentTest::SetUp() {
}
// TearDown() will be called immediately after each test.
-void FragmentTest::TearDown()
-{
+void FragmentTest::TearDown() {
}
//===----------------------------------------------------------------------===//
// Testcases
-TEST_F( FragmentTest, Fragment_constructor ) {
+TEST_F(FragmentTest, Fragment_constructor) {
LDSection* test = LDSection::Create("test", LDFileFormat::Null, 0, 0);
SectionData* s = SectionData::Create(*test);
new Fragment(Fragment::Alignment, s);
@@ -51,10 +46,10 @@ TEST_F( FragmentTest, Fragment_constructor ) {
EXPECT_TRUE(5 == s->size());
LDSection::Destroy(test);
-// SectionData::Destroy(s);
+ // SectionData::Destroy(s);
}
-TEST_F( FragmentTest, Fragment_trivial_function ) {
+TEST_F(FragmentTest, Fragment_trivial_function) {
LDSection* test = LDSection::Create("test", LDFileFormat::Null, 0, 0);
SectionData* s = SectionData::Create(*test);
Fragment* f = new Fragment(Fragment::Alignment, s);
@@ -64,11 +59,9 @@ TEST_F( FragmentTest, Fragment_trivial_function ) {
f->setOffset(5566);
EXPECT_TRUE(5566 == f->getOffset());
- //always return true
- EXPECT_TRUE(f->classof(new Fragment(Fragment::Region, s)) );
+ // always return true
+ EXPECT_TRUE(f->classof(new Fragment(Fragment::Region, s)));
LDSection::Destroy(test);
-// SectionData::Destroy(s);
+ // SectionData::Destroy(s);
}
-
-
diff --git a/unittests/FragmentTest.h b/unittests/FragmentTest.h
index 8c1489c..938cd9a 100644
--- a/unittests/FragmentTest.h
+++ b/unittests/FragmentTest.h
@@ -11,23 +11,20 @@
#include <gtest.h>
-namespace mcld
-{
+namespace mcld {
class Fragment;
-} // namespace for mcld
+} // namespace for mcld
-namespace mcldtest
-{
+namespace mcldtest {
/** \class FragmentTest
* \brief Unit test for mcld::Fragment.
*
* \see Fragment
*/
-class FragmentTest : public ::testing::Test
-{
-public:
+class FragmentTest : public ::testing::Test {
+ public:
// Constructor can do set-up work for all test here.
FragmentTest();
@@ -40,11 +37,10 @@ public:
// TearDown() will be called immediately after each test.
virtual void TearDown();
-protected:
+ protected:
mcld::Fragment* m_pTestee;
};
-} // namespace of mcldtest
+} // namespace of mcldtest
#endif
-
diff --git a/unittests/GCFactoryListTraitsTest.cpp b/unittests/GCFactoryListTraitsTest.cpp
index db8842c..7fecb26 100644
--- a/unittests/GCFactoryListTraitsTest.cpp
+++ b/unittests/GCFactoryListTraitsTest.cpp
@@ -12,8 +12,7 @@ using namespace mcld;
using namespace mcldtest;
// Constructor can do set-up work for all test here.
-GCFactoryListTraitsTest::GCFactoryListTraitsTest()
-{
+GCFactoryListTraitsTest::GCFactoryListTraitsTest() {
// Allocate the nodes.
m_pNodesAlloc = new Node* [10];
#define ALLOCATE_NODE(i) m_pNodesAlloc[(i)] = m_NodeFactory.produce(i);
@@ -31,13 +30,11 @@ GCFactoryListTraitsTest::GCFactoryListTraitsTest()
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-GCFactoryListTraitsTest::~GCFactoryListTraitsTest()
-{
+GCFactoryListTraitsTest::~GCFactoryListTraitsTest() {
}
// SetUp() will be called immediately before each test.
-void GCFactoryListTraitsTest::SetUp()
-{
+void GCFactoryListTraitsTest::SetUp() {
// Reset the node value and (re)insert into the iplist.
for (unsigned i = 0; i < 10; i++) {
m_pNodesAlloc[i]->setValue(m_pNodesAlloc[i]->getInitialValue());
@@ -46,8 +43,7 @@ void GCFactoryListTraitsTest::SetUp()
}
// TearDown() will be called immediately after each test.
-void GCFactoryListTraitsTest::TearDown()
-{
+void GCFactoryListTraitsTest::TearDown() {
// Erasing of llvm::iplist won't destroy the allocation of the nodes managed
// by the GCFactory (i.e., NodeFactory.)
m_pNodeList.clear();
@@ -57,62 +53,66 @@ void GCFactoryListTraitsTest::TearDown()
// Testcases
//
-#define CHECK_NODE_VALUE(v_) do { \
- ASSERT_TRUE(v_ == it->getValue()); \
- it++; \
-} while (false)
-
-#define CHECK_LIST_VALUE(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) do { \
- llvm::iplist<Node>::const_iterator it = m_pNodeList.begin(); \
- CHECK_NODE_VALUE(v1); \
- CHECK_NODE_VALUE(v2); \
- CHECK_NODE_VALUE(v3); \
- CHECK_NODE_VALUE(v4); \
- CHECK_NODE_VALUE(v5); \
- CHECK_NODE_VALUE(v6); \
- CHECK_NODE_VALUE(v7); \
- CHECK_NODE_VALUE(v8); \
- CHECK_NODE_VALUE(v9); \
- CHECK_NODE_VALUE(v10); \
-} while (false)
-
-TEST_F( GCFactoryListTraitsTest, Basic) {
+#define CHECK_NODE_VALUE(v_) \
+ do { \
+ ASSERT_TRUE(v_ == it->getValue()); \
+ it++; \
+ } while (false)
+
+#define CHECK_LIST_VALUE(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) \
+ do { \
+ llvm::iplist<Node>::const_iterator it = m_pNodeList.begin(); \
+ CHECK_NODE_VALUE(v1); \
+ CHECK_NODE_VALUE(v2); \
+ CHECK_NODE_VALUE(v3); \
+ CHECK_NODE_VALUE(v4); \
+ CHECK_NODE_VALUE(v5); \
+ CHECK_NODE_VALUE(v6); \
+ CHECK_NODE_VALUE(v7); \
+ CHECK_NODE_VALUE(v8); \
+ CHECK_NODE_VALUE(v9); \
+ CHECK_NODE_VALUE(v10); \
+ } while (false)
+
+TEST_F(GCFactoryListTraitsTest, Basic) {
ASSERT_TRUE(10 == m_pNodeList.size());
CHECK_LIST_VALUE(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
}
-TEST_F( GCFactoryListTraitsTest, BasicAgain) {
+TEST_F(GCFactoryListTraitsTest, BasicAgain) {
ASSERT_TRUE(10 == m_pNodeList.size());
CHECK_LIST_VALUE(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
}
-TEST_F( GCFactoryListTraitsTest, Clear) {
+TEST_F(GCFactoryListTraitsTest, Clear) {
m_pNodeList.clear();
ASSERT_TRUE(0 == m_pNodeList.size());
}
-TEST_F( GCFactoryListTraitsTest, PushThenPop) {
- Node *NewNode = m_NodeFactory.produce(11);
+TEST_F(GCFactoryListTraitsTest, PushThenPop) {
+ Node* NewNode = m_NodeFactory.produce(11);
m_pNodeList.push_back(NewNode);
ASSERT_TRUE(11 == m_pNodeList.size());
m_pNodeList.pop_back();
ASSERT_TRUE(10 == m_pNodeList.size());
}
-TEST_F( GCFactoryListTraitsTest, CodeIterator) {
+TEST_F(GCFactoryListTraitsTest, CodeIterator) {
// to test whether there's compilation error for const template
for (llvm::iplist<Node>::const_iterator I = m_pNodeList.begin(),
- E = m_pNodeList.end(); I != E; I++)
+ E = m_pNodeList.end();
+ I != E;
+ I++)
I->getValue();
}
-TEST_F( GCFactoryListTraitsTest, Empty) {
+TEST_F(GCFactoryListTraitsTest, Empty) {
ASSERT_FALSE(m_pNodeList.empty());
m_pNodeList.clear();
ASSERT_TRUE(m_pNodeList.empty());
}
-TEST_F( GCFactoryListTraitsTest, EraseAndSize) {
+TEST_F(GCFactoryListTraitsTest, EraseAndSize) {
ASSERT_FALSE(m_pNodeList.empty());
m_pNodeList.erase(m_pNodeList.begin());
m_pNodeList.erase(m_pNodeList.begin());
diff --git a/unittests/GCFactoryListTraitsTest.h b/unittests/GCFactoryListTraitsTest.h
index a551848..9326b5b 100644
--- a/unittests/GCFactoryListTraitsTest.h
+++ b/unittests/GCFactoryListTraitsTest.h
@@ -11,89 +11,85 @@
#include <gtest.h>
-#include <mcld/Support/GCFactoryListTraits.h>
+#include "mcld/Support/GCFactoryListTraits.h"
#include <llvm/ADT/ilist_node.h>
-#include <mcld/Support/GCFactory.h>
+#include "mcld/Support/GCFactory.h"
-namespace mcldtest
-{
+namespace mcldtest {
/** \class GCFactoryListTraitsTest
* \brief
*
* \see GCFactoryListTraits
*/
-class GCFactoryListTraitsTest : public ::testing::Test
-{
-public:
+class GCFactoryListTraitsTest : public ::testing::Test {
+ public:
/** \class GCFactoryListTraitsTest
* \brief Node used in the test
*
*/
class NodeFactory;
- class Node : public llvm::ilist_node<Node>
- {
+ class Node : public llvm::ilist_node<Node> {
friend class NodeFactory;
- private:
+
+ private:
unsigned m_Init;
unsigned m_Value;
- public:
- Node() : m_Init(0), m_Value(0) { }
+ public:
+ Node() : m_Init(0), m_Value(0) {}
- Node(unsigned pInit) : m_Init(pInit), m_Value(pInit) { }
+ Node(unsigned pInit) : m_Init(pInit), m_Value(pInit) {}
- unsigned getInitialValue() const {
- return m_Init;
- }
+ unsigned getInitialValue() const { return m_Init; }
- inline unsigned getValue() const
- { return m_Value; }
+ inline unsigned getValue() const { return m_Value; }
- inline void setValue(unsigned pValue)
- { m_Value = pValue; }
+ inline void setValue(unsigned pValue) { m_Value = pValue; }
};
class NodeFactory : public mcld::GCFactory<Node, 0> {
- public:
- NodeFactory() : mcld::GCFactory<Node, 0>(16) { }
+ public:
+ NodeFactory() : mcld::GCFactory<Node, 0>(16) {}
- Node *produce(unsigned pInit) {
- Node *result = allocate();
+ Node* produce(unsigned pInit) {
+ Node* result = allocate();
new (result) Node(pInit);
return result;
}
};
- // Constructor can do set-up work for all test here.
- GCFactoryListTraitsTest();
+ // Constructor can do set-up work for all test here.
+ GCFactoryListTraitsTest();
- // Destructor can do clean-up work that doesn't throw exceptions here.
- virtual ~GCFactoryListTraitsTest();
+ // Destructor can do clean-up work that doesn't throw exceptions here.
+ virtual ~GCFactoryListTraitsTest();
- // SetUp() will be called immediately before each test.
- virtual void SetUp();
+ // SetUp() will be called immediately before each test.
+ virtual void SetUp();
- // TearDown() will be called immediately after each test.
- virtual void TearDown();
+ // TearDown() will be called immediately after each test.
+ virtual void TearDown();
- const llvm::iplist<Node, mcld::GCFactoryListTraits<Node> > &getNodeList() const
- { return m_pNodeList; }
+ const llvm::iplist<Node, mcld::GCFactoryListTraits<Node> >& getNodeList()
+ const {
+ return m_pNodeList;
+ }
- llvm::iplist<Node, mcld::GCFactoryListTraits<Node> > &getNodeList()
- { return m_pNodeList; }
+ llvm::iplist<Node, mcld::GCFactoryListTraits<Node> >& getNodeList() {
+ return m_pNodeList;
+ }
-protected:
+ protected:
NodeFactory m_NodeFactory;
- Node **m_pNodesAlloc;
+ Node** m_pNodesAlloc;
llvm::iplist<Node, mcld::GCFactoryListTraits<Node> > m_pNodeList;
};
-} // namespace of mcldtest
+} // namespace of mcldtest
#endif
-
diff --git a/unittests/GraphTest.cpp b/unittests/GraphTest.cpp
index 0c97567..bd25707 100644
--- a/unittests/GraphTest.cpp
+++ b/unittests/GraphTest.cpp
@@ -7,38 +7,33 @@
//
//===----------------------------------------------------------------------===//
#include "GraphTest.h"
-#include <mcld/ADT/GraphLite/Digraph.h>
-#include <mcld/ADT/GraphLite/ListDigraph.h>
+#include "mcld/ADT/GraphLite/Digraph.h"
+#include "mcld/ADT/GraphLite/ListDigraph.h"
using namespace mcld;
using namespace mcld::test;
using namespace mcld::graph;
// Constructor can do set-up work for all test here.
-GraphTest::GraphTest()
-{
+GraphTest::GraphTest() {
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-GraphTest::~GraphTest()
-{
+GraphTest::~GraphTest() {
}
// SetUp() will be called immediately before each test.
-void GraphTest::SetUp()
-{
+void GraphTest::SetUp() {
}
// TearDown() will be called immediately after each test.
-void GraphTest::TearDown()
-{
+void GraphTest::TearDown() {
}
//===----------------------------------------------------------------------===//
// Testcases
//===----------------------------------------------------------------------===//
-TEST_F(GraphTest, list_digraph_add_n_erase_nodes_1)
-{
+TEST_F(GraphTest, list_digraph_add_n_erase_nodes_1) {
ListDigraph graph;
ListDigraph::Node* u1 = graph.addNode();
@@ -47,17 +42,17 @@ TEST_F(GraphTest, list_digraph_add_n_erase_nodes_1)
ASSERT_TRUE(NULL == u1->first_in);
ASSERT_TRUE(NULL == u1->first_out);
- ASSERT_TRUE(u2 == u1->prev);
+ ASSERT_TRUE(u2 == u1->prev);
ASSERT_TRUE(NULL == u1->next);
ASSERT_TRUE(NULL == u2->first_in);
ASSERT_TRUE(NULL == u2->first_out);
- ASSERT_TRUE(u3 == u2->prev);
- ASSERT_TRUE(u1 == u2->next);
+ ASSERT_TRUE(u3 == u2->prev);
+ ASSERT_TRUE(u1 == u2->next);
ASSERT_TRUE(NULL == u3->first_in);
ASSERT_TRUE(NULL == u3->first_out);
- ASSERT_TRUE(u2 == u3->next);
+ ASSERT_TRUE(u2 == u3->next);
ASSERT_TRUE(NULL == u3->prev);
ListDigraph::Node* head = NULL;
@@ -68,12 +63,12 @@ TEST_F(GraphTest, list_digraph_add_n_erase_nodes_1)
ASSERT_TRUE(NULL == u1->first_in);
ASSERT_TRUE(NULL == u1->first_out);
- ASSERT_TRUE(u3 == u1->prev);
+ ASSERT_TRUE(u3 == u1->prev);
ASSERT_TRUE(NULL == u1->next);
ASSERT_TRUE(NULL == u3->first_in);
ASSERT_TRUE(NULL == u3->first_out);
- ASSERT_TRUE(u1 == u3->next);
+ ASSERT_TRUE(u1 == u3->next);
ASSERT_TRUE(NULL == u3->prev);
ASSERT_TRUE(NULL == u2->first_in);
@@ -85,8 +80,7 @@ TEST_F(GraphTest, list_digraph_add_n_erase_nodes_1)
ASSERT_TRUE(head == u3);
}
-TEST_F(GraphTest, list_digraph_add_n_erase_nodes_2)
-{
+TEST_F(GraphTest, list_digraph_add_n_erase_nodes_2) {
ListDigraph graph;
ListDigraph::Node* u1 = graph.addNode();
@@ -95,17 +89,17 @@ TEST_F(GraphTest, list_digraph_add_n_erase_nodes_2)
ASSERT_TRUE(NULL == u1->first_in);
ASSERT_TRUE(NULL == u1->first_out);
- ASSERT_TRUE(u2 == u1->prev);
+ ASSERT_TRUE(u2 == u1->prev);
ASSERT_TRUE(NULL == u1->next);
ASSERT_TRUE(NULL == u2->first_in);
ASSERT_TRUE(NULL == u2->first_out);
- ASSERT_TRUE(u3 == u2->prev);
- ASSERT_TRUE(u1 == u2->next);
+ ASSERT_TRUE(u3 == u2->prev);
+ ASSERT_TRUE(u1 == u2->next);
ASSERT_TRUE(NULL == u3->first_in);
ASSERT_TRUE(NULL == u3->first_out);
- ASSERT_TRUE(u2 == u3->next);
+ ASSERT_TRUE(u2 == u3->next);
ASSERT_TRUE(NULL == u3->prev);
ListDigraph::Node* head = NULL;
@@ -121,20 +115,19 @@ TEST_F(GraphTest, list_digraph_add_n_erase_nodes_2)
ASSERT_TRUE(NULL == u2->first_in);
ASSERT_TRUE(NULL == u2->first_out);
- ASSERT_TRUE(u3 == u2->prev);
+ ASSERT_TRUE(u3 == u2->prev);
ASSERT_TRUE(NULL == u2->next);
ASSERT_TRUE(NULL == u3->first_in);
ASSERT_TRUE(NULL == u3->first_out);
- ASSERT_TRUE(u2 == u3->next);
+ ASSERT_TRUE(u2 == u3->next);
ASSERT_TRUE(NULL == u3->prev);
graph.getHead(head);
ASSERT_TRUE(head == u3);
}
-TEST_F(GraphTest, list_digraph_add_n_erase_nodes_3)
-{
+TEST_F(GraphTest, list_digraph_add_n_erase_nodes_3) {
ListDigraph graph;
ListDigraph::Node* u1 = graph.addNode();
@@ -143,17 +136,17 @@ TEST_F(GraphTest, list_digraph_add_n_erase_nodes_3)
ASSERT_TRUE(NULL == u1->first_in);
ASSERT_TRUE(NULL == u1->first_out);
- ASSERT_TRUE(u2 == u1->prev);
+ ASSERT_TRUE(u2 == u1->prev);
ASSERT_TRUE(NULL == u1->next);
ASSERT_TRUE(NULL == u2->first_in);
ASSERT_TRUE(NULL == u2->first_out);
- ASSERT_TRUE(u3 == u2->prev);
- ASSERT_TRUE(u1 == u2->next);
+ ASSERT_TRUE(u3 == u2->prev);
+ ASSERT_TRUE(u1 == u2->next);
ASSERT_TRUE(NULL == u3->first_in);
ASSERT_TRUE(NULL == u3->first_out);
- ASSERT_TRUE(u2 == u3->next);
+ ASSERT_TRUE(u2 == u3->next);
ASSERT_TRUE(NULL == u3->prev);
ListDigraph::Node* head = NULL;
@@ -169,21 +162,19 @@ TEST_F(GraphTest, list_digraph_add_n_erase_nodes_3)
ASSERT_TRUE(NULL == u1->first_in);
ASSERT_TRUE(NULL == u1->first_out);
- ASSERT_TRUE(u2 == u1->prev);
+ ASSERT_TRUE(u2 == u1->prev);
ASSERT_TRUE(NULL == u1->next);
ASSERT_TRUE(NULL == u2->first_in);
ASSERT_TRUE(NULL == u2->first_out);
- ASSERT_TRUE(u1 == u2->next);
+ ASSERT_TRUE(u1 == u2->next);
ASSERT_TRUE(NULL == u2->prev);
graph.getHead(head);
ASSERT_TRUE(head == u2);
-
}
-TEST_F(GraphTest, list_digraph_add_arcs_1)
-{
+TEST_F(GraphTest, list_digraph_add_arcs_1) {
ListDigraph graph;
ListDigraph::Node* u1 = graph.addNode();
@@ -203,8 +194,7 @@ TEST_F(GraphTest, list_digraph_add_arcs_1)
ASSERT_TRUE(u3->first_in == a2 && u3->first_out == a3);
}
-TEST_F(GraphTest, list_digraph_add_arcs_2)
-{
+TEST_F(GraphTest, list_digraph_add_arcs_2) {
ListDigraph graph;
ListDigraph::Node* u1 = graph.addNode();
@@ -224,8 +214,7 @@ TEST_F(GraphTest, list_digraph_add_arcs_2)
ASSERT_TRUE(u3->first_in == a3 && u3->first_out == NULL);
}
-TEST_F(GraphTest, list_digraph_add_n_erase_arcs_1)
-{
+TEST_F(GraphTest, list_digraph_add_n_erase_arcs_1) {
ListDigraph graph;
ListDigraph::Node* u1 = graph.addNode();
@@ -251,9 +240,7 @@ TEST_F(GraphTest, list_digraph_add_n_erase_arcs_1)
ASSERT_TRUE(NULL == a2->next_in);
}
-
-TEST_F(GraphTest, list_digraph_add_n_erase_arcs_2)
-{
+TEST_F(GraphTest, list_digraph_add_n_erase_arcs_2) {
ListDigraph graph;
ListDigraph::Node* u1 = graph.addNode();
@@ -279,8 +266,7 @@ TEST_F(GraphTest, list_digraph_add_n_erase_arcs_2)
ASSERT_TRUE(NULL == a1->next_in);
}
-TEST_F(GraphTest, list_digraph_add_n_erase_arcs_3)
-{
+TEST_F(GraphTest, list_digraph_add_n_erase_arcs_3) {
ListDigraph graph;
ListDigraph::Node* u1 = graph.addNode();
@@ -306,8 +292,7 @@ TEST_F(GraphTest, list_digraph_add_n_erase_arcs_3)
ASSERT_TRUE(NULL == a3->next_in);
}
-TEST_F(GraphTest, list_digraph_add_n_erase_arcs_4)
-{
+TEST_F(GraphTest, list_digraph_add_n_erase_arcs_4) {
ListDigraph graph;
ListDigraph::Node* u1 = graph.addNode();
@@ -323,11 +308,9 @@ TEST_F(GraphTest, list_digraph_add_n_erase_arcs_4)
ASSERT_TRUE(u2->first_in == NULL);
ASSERT_TRUE(u3->first_in == NULL);
ASSERT_TRUE(a1->next_in == NULL);
-
}
-TEST_F(GraphTest, api_test)
-{
+TEST_F(GraphTest, api_test) {
Digraph graph;
Digraph::Node node = graph.addNode();
diff --git a/unittests/GraphTest.h b/unittests/GraphTest.h
index a71276b..0e18b74 100644
--- a/unittests/GraphTest.h
+++ b/unittests/GraphTest.h
@@ -11,13 +11,11 @@
#include <gtest.h>
-
namespace mcld {
namespace test {
-class GraphTest : public ::testing::Test
-{
-public:
+class GraphTest : public ::testing::Test {
+ public:
// Constructor can do set-up work for all test here.
GraphTest();
@@ -31,8 +29,7 @@ public:
virtual void TearDown();
};
-} // namespace of test
-} // namespace of mcld
+} // namespace of test
+} // namespace of mcld
#endif
-
diff --git a/unittests/HashTableTest.cpp b/unittests/HashTableTest.cpp
index fe67e95..595b1e1 100644
--- a/unittests/HashTableTest.cpp
+++ b/unittests/HashTableTest.cpp
@@ -8,78 +8,63 @@
//===----------------------------------------------------------------------===//
#include "HashTableTest.h"
-#include <mcld/ADT/HashEntry.h>
-#include <mcld/ADT/HashTable.h>
+#include "mcld/ADT/HashEntry.h"
+#include "mcld/ADT/HashTable.h"
#include <cstdlib>
using namespace std;
using namespace mcld;
using namespace mcldtest;
-
// Constructor can do set-up work for all test here.
-HashTableTest::HashTableTest()
-{
+HashTableTest::HashTableTest() {
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-HashTableTest::~HashTableTest()
-{
+HashTableTest::~HashTableTest() {
}
// SetUp() will be called immediately before each test.
-void HashTableTest::SetUp()
-{
+void HashTableTest::SetUp() {
}
// TearDown() will be called immediately after each test.
-void HashTableTest::TearDown()
-{
+void HashTableTest::TearDown() {
}
//==========================================================================//
// Testcases
//
-struct IntCompare
-{
- bool operator()(int X, int Y) const
- { return (X==Y); }
+struct IntCompare {
+ bool operator()(int X, int Y) const { return (X == Y); }
};
-struct PtrCompare
-{
- bool operator()(const int* X, const int* Y) const
- { return (X==Y); }
+struct PtrCompare {
+ bool operator()(const int* X, const int* Y) const { return (X == Y); }
};
-struct PtrHash
-{
- size_t operator()(const int* pKey) const
- {
- return (unsigned((uintptr_t)pKey) >> 4) ^
- (unsigned((uintptr_t)pKey) >> 9);
+struct PtrHash {
+ size_t operator()(const int* pKey) const {
+ return (unsigned((uintptr_t)pKey) >> 4) ^ (unsigned((uintptr_t)pKey) >> 9);
}
};
-struct IntHash
-{
- size_t operator()(int pKey) const
- { return pKey; }
+struct IntHash {
+ size_t operator()(int pKey) const { return pKey; }
};
-struct IntMod3Hash
-{
- size_t operator()(int pKey) const
- { return pKey % 3; }
+struct IntMod3Hash {
+ size_t operator()(int pKey) const { return pKey % 3; }
};
-TEST_F( HashTableTest, ptr_entry ) {
+TEST_F(HashTableTest, ptr_entry) {
int A = 1;
int* pA = &A;
typedef HashEntry<int*, int, PtrCompare> HashEntryType;
- typedef HashTable<HashEntryType, PtrHash, EntryFactory<HashEntryType> > HashTableTy;
- HashTableTy *hashTable = new HashTableTy(0);
+ typedef HashTable<HashEntryType, PtrHash, EntryFactory<HashEntryType> >
+ HashTableTy;
+ HashTableTy* hashTable = new HashTableTy(0);
bool exist;
HashTableTy::entry_type* entry = 0;
@@ -90,11 +75,11 @@ TEST_F( HashTableTest, ptr_entry ) {
HashTableTy::iterator iter;
iter = hashTable->find(NULL);
- EXPECT_TRUE(iter==hashTable->end());
+ EXPECT_TRUE(iter == hashTable->end());
delete hashTable;
}
-TEST_F( HashTableTest, constructor ) {
+TEST_F(HashTableTest, constructor) {
typedef HashEntry<int, int, IntCompare> HashEntryType;
HashTable<HashEntryType, IntHash, EntryFactory<HashEntryType> > hashTable(16);
EXPECT_TRUE(17 == hashTable.numOfBuckets());
@@ -102,10 +87,11 @@ TEST_F( HashTableTest, constructor ) {
EXPECT_TRUE(0 == hashTable.numOfEntries());
}
-TEST_F( HashTableTest, allocattion ) {
+TEST_F(HashTableTest, allocattion) {
typedef HashEntry<int, int, IntCompare> HashEntryType;
- typedef HashTable<HashEntryType, IntHash, EntryFactory<HashEntryType> > HashTableTy;
- HashTableTy *hashTable = new HashTableTy(22);
+ typedef HashTable<HashEntryType, IntHash, EntryFactory<HashEntryType> >
+ HashTableTy;
+ HashTableTy* hashTable = new HashTableTy(22);
bool exist;
int key = 100;
@@ -119,20 +105,21 @@ TEST_F( HashTableTest, allocattion ) {
delete hashTable;
}
-TEST_F( HashTableTest, alloc100 ) {
+TEST_F(HashTableTest, alloc100) {
typedef HashEntry<int, int, IntCompare> HashEntryType;
- typedef HashTable<HashEntryType, IntHash, EntryFactory<HashEntryType> > HashTableTy;
- HashTableTy *hashTable = new HashTableTy(22);
+ typedef HashTable<HashEntryType, IntHash, EntryFactory<HashEntryType> >
+ HashTableTy;
+ HashTableTy* hashTable = new HashTableTy(22);
bool exist;
HashTableTy::entry_type* entry = 0;
- for (int key=0; key<100; ++key) {
+ for (int key = 0; key < 100; ++key) {
entry = hashTable->insert(key, exist);
EXPECT_FALSE(hashTable->empty());
EXPECT_FALSE(exist);
EXPECT_FALSE(NULL == entry);
EXPECT_TRUE(key == entry->key());
- entry->setValue(key+10);
+ entry->setValue(key + 10);
}
EXPECT_FALSE(hashTable->empty());
@@ -141,21 +128,22 @@ TEST_F( HashTableTest, alloc100 ) {
delete hashTable;
}
-TEST_F( HashTableTest, erase100 ) {
+TEST_F(HashTableTest, erase100) {
typedef HashEntry<int, int, IntCompare> HashEntryType;
- typedef HashTable<HashEntryType, IntHash, EntryFactory<HashEntryType> > HashTableTy;
- HashTableTy *hashTable = new HashTableTy(0);
+ typedef HashTable<HashEntryType, IntHash, EntryFactory<HashEntryType> >
+ HashTableTy;
+ HashTableTy* hashTable = new HashTableTy(0);
bool exist;
HashTableTy::entry_type* entry = 0;
- for (unsigned int key=0; key<100; ++key)
+ for (unsigned int key = 0; key < 100; ++key)
entry = hashTable->insert(key, exist);
EXPECT_FALSE(hashTable->empty());
int count;
HashTableTy::iterator iter;
- for (unsigned int key=0; key<100; ++key) {
+ for (unsigned int key = 0; key < 100; ++key) {
count = hashTable->erase(key);
EXPECT_EQ(1, count);
iter = hashTable->find(key);
@@ -166,21 +154,22 @@ TEST_F( HashTableTest, erase100 ) {
delete hashTable;
}
-TEST_F( HashTableTest, clear) {
+TEST_F(HashTableTest, clear) {
typedef HashEntry<int, int, IntCompare> HashEntryType;
- typedef HashTable<HashEntryType, IntHash, EntryFactory<HashEntryType> > HashTableTy;
- HashTableTy *hashTable = new HashTableTy(22);
+ typedef HashTable<HashEntryType, IntHash, EntryFactory<HashEntryType> >
+ HashTableTy;
+ HashTableTy* hashTable = new HashTableTy(22);
bool exist;
HashTableTy::entry_type* entry = 0;
- for (unsigned int key=0; key<100; ++key) {
+ for (unsigned int key = 0; key < 100; ++key) {
entry = hashTable->insert(key, exist);
}
hashTable->clear();
HashTableTy::iterator iter;
- for (unsigned int key=0; key<100; ++key) {
+ for (unsigned int key = 0; key < 100; ++key) {
iter = hashTable->find(key);
EXPECT_TRUE(iter == hashTable->end());
}
@@ -189,21 +178,22 @@ TEST_F( HashTableTest, clear) {
delete hashTable;
}
-TEST_F( HashTableTest, tombstone ) {
+TEST_F(HashTableTest, tombstone) {
typedef HashEntry<int, int, IntCompare> HashEntryType;
- typedef HashTable<HashEntryType, IntMod3Hash, EntryFactory<HashEntryType> > HashTableTy;
- HashTableTy *hashTable = new HashTableTy();
+ typedef HashTable<HashEntryType, IntMod3Hash, EntryFactory<HashEntryType> >
+ HashTableTy;
+ HashTableTy* hashTable = new HashTableTy();
bool exist;
HashTableTy::entry_type* entry = 0;
- for (unsigned int key=0; key<100; ++key) {
+ for (unsigned int key = 0; key < 100; ++key) {
entry = hashTable->insert(key, exist);
}
EXPECT_FALSE(hashTable->empty());
int count;
HashTableTy::iterator iter;
- for (unsigned int key=0; key<20; ++key) {
+ for (unsigned int key = 0; key < 20; ++key) {
count = hashTable->erase(key);
EXPECT_EQ(1, count);
iter = hashTable->find(key);
@@ -211,12 +201,12 @@ TEST_F( HashTableTest, tombstone ) {
}
EXPECT_TRUE(80 == hashTable->numOfEntries());
- for (unsigned int key=20; key<100; ++key) {
+ for (unsigned int key = 20; key < 100; ++key) {
iter = hashTable->find(key);
EXPECT_TRUE(iter != hashTable->end());
}
- for (unsigned int key=0; key<20; ++key) {
+ for (unsigned int key = 0; key < 20; ++key) {
entry = hashTable->insert(key, exist);
}
EXPECT_TRUE(100 == hashTable->numOfEntries());
@@ -225,66 +215,68 @@ TEST_F( HashTableTest, tombstone ) {
delete hashTable;
}
-TEST_F( HashTableTest, rehash_test ) {
+TEST_F(HashTableTest, rehash_test) {
typedef HashEntry<int, int, IntCompare> HashEntryType;
- typedef HashTable<HashEntryType, IntHash, EntryFactory<HashEntryType> > HashTableTy;
- HashTableTy *hashTable = new HashTableTy(0);
+ typedef HashTable<HashEntryType, IntHash, EntryFactory<HashEntryType> >
+ HashTableTy;
+ HashTableTy* hashTable = new HashTableTy(0);
bool exist;
HashTableTy::entry_type* entry = 0;
- for (unsigned int key=0; key<400000; ++key) {
+ for (unsigned int key = 0; key < 400000; ++key) {
entry = hashTable->insert(key, exist);
- entry->setValue(key+10);
+ entry->setValue(key + 10);
}
HashTableTy::iterator iter;
- for (int key=0; key<400000; ++key) {
+ for (int key = 0; key < 400000; ++key) {
iter = hashTable->find(key);
- EXPECT_EQ((key+10), iter.getEntry()->value());
+ EXPECT_EQ((key + 10), iter.getEntry()->value());
}
delete hashTable;
}
-TEST_F( HashTableTest, bucket_iterator ) {
+TEST_F(HashTableTest, bucket_iterator) {
typedef HashEntry<int, int, IntCompare> HashEntryType;
- typedef HashTable<HashEntryType, IntHash, EntryFactory<HashEntryType> > HashTableTy;
- HashTableTy *hashTable = new HashTableTy(0);
+ typedef HashTable<HashEntryType, IntHash, EntryFactory<HashEntryType> >
+ HashTableTy;
+ HashTableTy* hashTable = new HashTableTy(0);
bool exist;
HashTableTy::entry_type* entry = 0;
- for (unsigned int key=0; key<400000; ++key) {
+ for (unsigned int key = 0; key < 400000; ++key) {
entry = hashTable->insert(key, exist);
- entry->setValue(key+10);
+ entry->setValue(key + 10);
}
HashTableTy::iterator iter, iEnd = hashTable->end();
int counter = 0;
for (iter = hashTable->begin(); iter != iEnd; ++iter) {
- EXPECT_EQ(iter.getEntry()->key()+10, iter.getEntry()->value());
+ EXPECT_EQ(iter.getEntry()->key() + 10, iter.getEntry()->value());
++counter;
}
EXPECT_EQ(400000, counter);
delete hashTable;
}
-
-TEST_F( HashTableTest, chain_iterator_single ) {
+TEST_F(HashTableTest, chain_iterator_single) {
typedef HashEntry<int, int, IntCompare> HashEntryType;
- typedef HashTable<HashEntryType, IntHash, EntryFactory<HashEntryType> > HashTableTy;
- HashTableTy *hashTable = new HashTableTy();
+ typedef HashTable<HashEntryType, IntHash, EntryFactory<HashEntryType> >
+ HashTableTy;
+ HashTableTy* hashTable = new HashTableTy();
bool exist;
HashTableTy::entry_type* entry = 0;
- for (int key=0; key<16; ++key) {
- entry = hashTable->insert(key*37, exist);
- entry->setValue(key+10);
+ for (int key = 0; key < 16; ++key) {
+ entry = hashTable->insert(key * 37, exist);
+ entry->setValue(key + 10);
}
- for (int key=0; key<16; ++key) {
+ for (int key = 0; key < 16; ++key) {
int counter = 0;
- HashTableTy::chain_iterator iter, iEnd = hashTable->end(key*37);
- for (iter = hashTable->begin(key*37); iter != iEnd; ++iter) {
- EXPECT_EQ(key+10, iter.getEntry()->value());
+ HashTableTy::chain_iterator iter, iEnd = hashTable->end(key * 37);
+ for (iter = hashTable->begin(key * 37); iter != iEnd; ++iter) {
+ EXPECT_EQ(key + 10, iter.getEntry()->value());
++counter;
}
EXPECT_EQ(1, counter);
@@ -292,22 +284,19 @@ TEST_F( HashTableTest, chain_iterator_single ) {
delete hashTable;
}
-struct FixHash
-{
- size_t operator()(int pKey) const {
- return 10;
- }
+struct FixHash {
+ size_t operator()(int pKey) const { return 10; }
};
-
-TEST_F( HashTableTest, chain_iterator_list ) {
+TEST_F(HashTableTest, chain_iterator_list) {
typedef HashEntry<int, int, IntCompare> HashEntryType;
- typedef HashTable<HashEntryType, FixHash, EntryFactory<HashEntryType> > HashTableTy;
- HashTableTy *hashTable = new HashTableTy();
+ typedef HashTable<HashEntryType, FixHash, EntryFactory<HashEntryType> >
+ HashTableTy;
+ HashTableTy* hashTable = new HashTableTy();
bool exist;
HashTableTy::entry_type* entry = 0;
- for (unsigned int key=0; key<16; ++key) {
+ for (unsigned int key = 0; key < 16; ++key) {
entry = hashTable->insert(key, exist);
ASSERT_FALSE(exist);
entry->setValue(key);
diff --git a/unittests/HashTableTest.h b/unittests/HashTableTest.h
index c07c991..dd4739a 100644
--- a/unittests/HashTableTest.h
+++ b/unittests/HashTableTest.h
@@ -12,31 +12,28 @@
#include <gtest.h>
-namespace mcldtest
-{
+namespace mcldtest {
/** \class HashTableTest
* \brief Testcase for HashTable
*
* \see HashTable
*/
-class HashTableTest : public ::testing::Test
-{
-public:
- // Constructor can do set-up work for all test here.
- HashTableTest();
+class HashTableTest : public ::testing::Test {
+ public:
+ // Constructor can do set-up work for all test here.
+ HashTableTest();
- // Destructor can do clean-up work that doesn't throw exceptions here.
- virtual ~HashTableTest();
+ // Destructor can do clean-up work that doesn't throw exceptions here.
+ virtual ~HashTableTest();
- // SetUp() will be called immediately before each test.
- virtual void SetUp();
+ // SetUp() will be called immediately before each test.
+ virtual void SetUp();
- // TearDown() will be called immediately after each test.
- virtual void TearDown();
+ // TearDown() will be called immediately after each test.
+ virtual void TearDown();
};
-} // namespace of mcldtest
+} // namespace of mcldtest
#endif
-
diff --git a/unittests/InputTreeTest.cpp b/unittests/InputTreeTest.cpp
index 6af81d8..d8951b9 100644
--- a/unittests/InputTreeTest.cpp
+++ b/unittests/InputTreeTest.cpp
@@ -11,36 +11,29 @@
#include <vector>
#include <iostream>
-#include <mcld/InputTree.h>
-#include <mcld/MC/InputFactory.h>
-#include <mcld/LinkerConfig.h>
-#include <mcld/MC/InputBuilder.h>
-#include <mcld/MC/FileAction.h>
-#include <mcld/MC/CommandAction.h>
+#include "mcld/InputTree.h"
+#include "mcld/MC/InputFactory.h"
+#include "mcld/LinkerConfig.h"
+#include "mcld/MC/InputBuilder.h"
+#include "mcld/MC/FileAction.h"
+#include "mcld/MC/CommandAction.h"
using namespace mcld;
using namespace mcld::test;
-
// Constructor can do set-up work for all test here.
-InputTreeTest::InputTreeTest()
- : m_MemFactory(10), m_ContextFactory(4) {
-
+InputTreeTest::InputTreeTest() : m_MemFactory(10), m_ContextFactory(4) {
// create testee. modify it if need
m_pConfig = new mcld::LinkerConfig("arm-none-linux-gnueabi");
- m_pAlloc = new mcld::InputFactory(10, *m_pConfig);
- m_pBuilder = new mcld::InputBuilder(*m_pConfig,
- *m_pAlloc,
- m_ContextFactory,
- m_MemFactory,
- false);
+ m_pAlloc = new mcld::InputFactory(10, *m_pConfig);
+ m_pBuilder = new mcld::InputBuilder(
+ *m_pConfig, *m_pAlloc, m_ContextFactory, m_MemFactory, false);
m_pTestee = new mcld::InputTree();
m_pBuilder->setCurrentTree(*m_pTestee);
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-InputTreeTest::~InputTreeTest()
-{
+InputTreeTest::~InputTreeTest() {
delete m_pTestee;
delete m_pAlloc;
delete m_pBuilder;
@@ -48,20 +41,17 @@ InputTreeTest::~InputTreeTest()
}
// SetUp() will be called immediately before each test.
-void InputTreeTest::SetUp()
-{
+void InputTreeTest::SetUp() {
}
// TearDown() will be called immediately after each test.
-void InputTreeTest::TearDown()
-{
+void InputTreeTest::TearDown() {
}
//===----------------------------------------------------------------------===//
// Testcases
//
-TEST_F( InputTreeTest, Basic_operation ) {
-
+TEST_F(InputTreeTest, Basic_operation) {
std::vector<InputAction*> actions;
size_t position = 0;
@@ -96,22 +86,20 @@ TEST_F( InputTreeTest, Basic_operation ) {
ASSERT_FALSE(isGroup(node));
ASSERT_FALSE(isGroup(const_node2));
ASSERT_FALSE(m_pAlloc->empty());
- ASSERT_FALSE(m_pAlloc->size()==0);
+ ASSERT_FALSE(m_pAlloc->size() == 0);
- ASSERT_TRUE(m_pTestee->size()==3);
+ ASSERT_TRUE(m_pTestee->size() == 3);
}
-TEST_F( InputTreeTest, forLoop_TEST ) {
+TEST_F(InputTreeTest, forLoop_TEST) {
InputTree::iterator node = m_pTestee->root();
-
Input* input = m_pAlloc->produce("FileSpec", "path1");
m_pTestee->insert<InputTree::Inclusive>(node, *input);
InputTree::const_iterator const_node = node;
--node;
- for(int i=0 ; i<100 ; ++i)
- {
+ for (int i = 0; i < 100; ++i) {
Input* input = m_pAlloc->produce("FileSpec", "path1");
m_pTestee->insert<InputTree::Inclusive>(node, *input);
++node;
@@ -123,16 +111,15 @@ TEST_F( InputTreeTest, forLoop_TEST ) {
ASSERT_FALSE(node.isRoot());
ASSERT_TRUE(isGroup(node));
ASSERT_FALSE(m_pAlloc->empty());
- ASSERT_FALSE(m_pAlloc->size()==100);
+ ASSERT_FALSE(m_pAlloc->size() == 100);
- ASSERT_TRUE(m_pTestee->size()==102);
+ ASSERT_TRUE(m_pTestee->size() == 102);
}
-TEST_F( InputTreeTest, Nesting_Case ) {
+TEST_F(InputTreeTest, Nesting_Case) {
InputTree::iterator node = m_pTestee->root();
- for(int i=0 ; i<50 ; ++i)
- {
+ for (int i = 0; i < 50; ++i) {
m_pTestee->enterGroup(node, InputTree::Downward);
--node;
@@ -144,13 +131,11 @@ TEST_F( InputTreeTest, Nesting_Case ) {
ASSERT_FALSE(node.isRoot());
ASSERT_FALSE(isGroup(node));
ASSERT_FALSE(m_pAlloc->empty());
- ASSERT_TRUE(m_pAlloc->size()==50);
- ASSERT_TRUE(m_pTestee->size()==100);
+ ASSERT_TRUE(m_pAlloc->size() == 50);
+ ASSERT_TRUE(m_pTestee->size() == 100);
}
-TEST_F( InputTreeTest, DFSIterator_BasicTraversal)
-{
-
+TEST_F(InputTreeTest, DFSIterator_BasicTraversal) {
InputTree::iterator node = m_pTestee->root();
Input* input = m_pAlloc->produce("111", "/");
m_pTestee->insert<InputTree::Inclusive>(node, *input);
@@ -176,6 +161,5 @@ TEST_F( InputTreeTest, DFSIterator_BasicTraversal)
++dfs_it;
ASSERT_STREQ("10", (**dfs_it).name().c_str());
++dfs_it;
- ASSERT_TRUE(dfs_it == dfs_end);
+ ASSERT_TRUE(dfs_it == dfs_end);
}
-
diff --git a/unittests/InputTreeTest.h b/unittests/InputTreeTest.h
index 31be6fd..dc522d8 100644
--- a/unittests/InputTreeTest.h
+++ b/unittests/InputTreeTest.h
@@ -10,8 +10,8 @@
#define UNITTESTS_INPUTTREE_TEST_H
#include <gtest.h>
-#include <mcld/MC/ContextFactory.h>
-#include <mcld/Support/MemoryAreaFactory.h>
+#include "mcld/MC/ContextFactory.h"
+#include "mcld/Support/MemoryAreaFactory.h"
namespace mcld {
@@ -27,9 +27,8 @@ namespace test {
*
* \see InputTree
*/
-class InputTreeTest : public ::testing::Test
-{
-public:
+class InputTreeTest : public ::testing::Test {
+ public:
// Constructor can do set-up work for all test here.
InputTreeTest();
@@ -42,7 +41,7 @@ public:
// TearDown() will be called immediately after each test.
virtual void TearDown();
-protected:
+ protected:
mcld::LinkerConfig* m_pConfig;
mcld::InputFactory* m_pAlloc;
@@ -53,8 +52,7 @@ protected:
mcld::InputTree* m_pTestee;
};
-} // namespace of test
-} // namespace of mcld
+} // namespace of test
+} // namespace of mcld
#endif
-
diff --git a/unittests/LDSymbolTest.cpp b/unittests/LDSymbolTest.cpp
index e0e681d..e2479e7 100644
--- a/unittests/LDSymbolTest.cpp
+++ b/unittests/LDSymbolTest.cpp
@@ -7,36 +7,30 @@
//
//===----------------------------------------------------------------------===//
-#include <mcld/LD/LDSymbol.h>
+#include "mcld/LD/LDSymbol.h"
#include "LDSymbolTest.h"
using namespace mcld;
using namespace mcldtest;
-
// Constructor can do set-up work for all test here.
-LDSymbolTest::LDSymbolTest()
-{
+LDSymbolTest::LDSymbolTest() {
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-LDSymbolTest::~LDSymbolTest()
-{
+LDSymbolTest::~LDSymbolTest() {
}
// SetUp() will be called immediately before each test.
-void LDSymbolTest::SetUp()
-{
+void LDSymbolTest::SetUp() {
}
// TearDown() will be called immediately after each test.
-void LDSymbolTest::TearDown()
-{
+void LDSymbolTest::TearDown() {
}
//==========================================================================//
// Testcases
//
-TEST_F( LDSymbolTest, produce ) {
+TEST_F(LDSymbolTest, produce) {
}
-
diff --git a/unittests/LDSymbolTest.h b/unittests/LDSymbolTest.h
index 43d6b8a..42d7fb0 100644
--- a/unittests/LDSymbolTest.h
+++ b/unittests/LDSymbolTest.h
@@ -12,20 +12,17 @@
#include <gtest.h>
-namespace mcld
-{
+namespace mcld {
class LDSymbol;
-} // namespace for mcld
+} // namespace for mcld
-namespace mcldtest
-{
+namespace mcldtest {
/** \class LDSymbolTest
*/
-class LDSymbolTest : public ::testing::Test
-{
-public:
+class LDSymbolTest : public ::testing::Test {
+ public:
// Constructor can do set-up work for all test here.
LDSymbolTest();
@@ -37,10 +34,8 @@ public:
// TearDown() will be called immediately after each test.
virtual void TearDown();
-
};
-} // namespace of mcldtest
+} // namespace of mcldtest
#endif
-
diff --git a/unittests/LEB128Test.cpp b/unittests/LEB128Test.cpp
index b310262..97aa7d9 100644
--- a/unittests/LEB128Test.cpp
+++ b/unittests/LEB128Test.cpp
@@ -6,46 +6,41 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#include <mcld/Support/LEB128.h>
+#include "mcld/Support/LEB128.h"
#include "LEB128Test.h"
-#include <mcld/Support/SystemUtils.h>
+#include "mcld/Support/SystemUtils.h"
#include <ctime>
#include <cstdlib>
using namespace mcld;
using namespace mcldtest;
-
// Constructor can do set-up work for all test here.
-LEB128Test::LEB128Test()
-{
- // Initialize the seed for random number generator using during the tests.
+LEB128Test::LEB128Test() {
+ // Initialize the seed for random number generator using during the tests.
sys::SetRandomSeed(::time(NULL));
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-LEB128Test::~LEB128Test()
-{
+LEB128Test::~LEB128Test() {
}
// SetUp() will be called immediately before each test.
-void LEB128Test::SetUp()
-{
+void LEB128Test::SetUp() {
}
// TearDown() will be called immediately after each test.
-void LEB128Test::TearDown()
-{
+void LEB128Test::TearDown() {
}
//==========================================================================//
// Testcases
//
-TEST_F( LEB128Test, EncodeULEB_Example_from_Dwarf3_Figure22_Using_32bits) {
+TEST_F(LEB128Test, EncodeULEB_Example_from_Dwarf3_Figure22_Using_32bits) {
leb128::ByteType buffer[2];
- leb128::ByteType *result;
+ leb128::ByteType* result;
size_t size;
result = buffer;
@@ -89,9 +84,9 @@ TEST_F( LEB128Test, EncodeULEB_Example_from_Dwarf3_Figure22_Using_32bits) {
ASSERT_TRUE(size == 2);
}
-TEST_F( LEB128Test, EncodeULEB_Example_from_Dwarf3_Figure22_Using_64bits) {
+TEST_F(LEB128Test, EncodeULEB_Example_from_Dwarf3_Figure22_Using_64bits) {
leb128::ByteType buffer[2];
- leb128::ByteType *result;
+ leb128::ByteType* result;
size_t size;
result = buffer;
@@ -135,9 +130,9 @@ TEST_F( LEB128Test, EncodeULEB_Example_from_Dwarf3_Figure22_Using_64bits) {
ASSERT_TRUE(size == 2);
}
-TEST_F( LEB128Test, EncodeSLEB_Example_from_Dwarf3_Figure22) {
+TEST_F(LEB128Test, EncodeSLEB_Example_from_Dwarf3_Figure22) {
leb128::ByteType buffer[2];
- leb128::ByteType *result;
+ leb128::ByteType* result;
size_t size;
result = buffer;
@@ -195,7 +190,7 @@ TEST_F( LEB128Test, EncodeSLEB_Example_from_Dwarf3_Figure22) {
ASSERT_TRUE(size == 2);
}
-TEST_F( LEB128Test, DecodeULEB_Example_from_Dwarf3_Figure22) {
+TEST_F(LEB128Test, DecodeULEB_Example_from_Dwarf3_Figure22) {
leb128::ByteType buffer[2];
size_t size;
@@ -228,10 +223,9 @@ TEST_F( LEB128Test, DecodeULEB_Example_from_Dwarf3_Figure22) {
buffer[1] = 100;
ASSERT_TRUE(leb128::decode<uint64_t>(buffer, size) == 12857);
ASSERT_TRUE(size == 2);
-
}
-TEST_F( LEB128Test, DecodeSLEB_Example_from_Dwarf3_Figure22) {
+TEST_F(LEB128Test, DecodeSLEB_Example_from_Dwarf3_Figure22) {
leb128::ByteType buffer[2];
size_t size;
@@ -276,9 +270,9 @@ TEST_F( LEB128Test, DecodeSLEB_Example_from_Dwarf3_Figure22) {
ASSERT_TRUE(size == 2);
}
-TEST_F( LEB128Test, DecodeULEB_Tests_Found_in_Android_dalvik_dx) {
+TEST_F(LEB128Test, DecodeULEB_Tests_Found_in_Android_dalvik_dx) {
leb128::ByteType content[2];
- const leb128::ByteType *p;
+ const leb128::ByteType* p;
content[0] = 0;
p = content;
@@ -297,9 +291,9 @@ TEST_F( LEB128Test, DecodeULEB_Tests_Found_in_Android_dalvik_dx) {
ASSERT_EQ(p, content + 2);
}
-TEST_F( LEB128Test, EncodeULEB_Tests_Found_in_Android_dalvik_dx) {
+TEST_F(LEB128Test, EncodeULEB_Tests_Found_in_Android_dalvik_dx) {
leb128::ByteType buffer[5];
- leb128::ByteType *result;
+ leb128::ByteType* result;
size_t size;
result = buffer;
@@ -389,9 +383,9 @@ TEST_F( LEB128Test, EncodeULEB_Tests_Found_in_Android_dalvik_dx) {
ASSERT_TRUE(size == 5);
}
-TEST_F( LEB128Test, DecodeSLEB_Tests_Found_in_Android_dalvik_dx) {
+TEST_F(LEB128Test, DecodeSLEB_Tests_Found_in_Android_dalvik_dx) {
leb128::ByteType content[2];
- const leb128::ByteType *p;
+ const leb128::ByteType* p;
content[0] = 0;
p = content;
@@ -414,9 +408,9 @@ TEST_F( LEB128Test, DecodeSLEB_Tests_Found_in_Android_dalvik_dx) {
ASSERT_EQ(p, content + 1);
}
-TEST_F( LEB128Test, EncodeSLEB_Tests_Found_in_Android_dalvik_dx) {
+TEST_F(LEB128Test, EncodeSLEB_Tests_Found_in_Android_dalvik_dx) {
leb128::ByteType buffer[5];
- leb128::ByteType *result;
+ leb128::ByteType* result;
size_t size;
result = buffer;
@@ -456,14 +450,14 @@ TEST_F( LEB128Test, EncodeSLEB_Tests_Found_in_Android_dalvik_dx) {
ASSERT_TRUE(size == 1);
}
-TEST_F( LEB128Test, Random_Regression_Test) {
+TEST_F(LEB128Test, Random_Regression_Test) {
leb128::ByteType buffer[9];
for (int i = 0; i < 20; i++) {
unsigned long int value = sys::GetRandomNum();
uint64_t value2 = value * value;
int64_t value3 = value * value;
- leb128::ByteType *result;
+ leb128::ByteType* result;
size_t encode_size, decode_size;
// Test encode<uint32_t> and decode<uint64_t> on value
@@ -496,9 +490,9 @@ TEST_F( LEB128Test, Random_Regression_Test) {
}
}
-TEST_F( LEB128Test, Other_Test) {
+TEST_F(LEB128Test, Other_Test) {
leb128::ByteType buffer[5];
- leb128::ByteType *result;
+ leb128::ByteType* result;
size_t size;
result = buffer;
@@ -512,9 +506,9 @@ TEST_F( LEB128Test, Other_Test) {
ASSERT_TRUE(size == 3);
}
-TEST_F( LEB128Test, Type_Conversion_Test) {
+TEST_F(LEB128Test, Type_Conversion_Test) {
char buffer[5];
- char *result;
+ char* result;
size_t size;
result = buffer;
@@ -527,7 +521,7 @@ TEST_F( LEB128Test, Type_Conversion_Test) {
ASSERT_TRUE(leb128::decode<uint64_t>(buffer, size) == 154452);
ASSERT_TRUE(size == 3);
- const char *p = buffer;
+ const char* p = buffer;
ASSERT_TRUE(leb128::decode<uint64_t>(p) == 154452);
ASSERT_TRUE(p == (buffer + 3));
}
diff --git a/unittests/LEB128Test.h b/unittests/LEB128Test.h
index f0a87e3..07febff 100644
--- a/unittests/LEB128Test.h
+++ b/unittests/LEB128Test.h
@@ -11,31 +11,28 @@
#include <gtest.h>
-namespace mcldtest
-{
+namespace mcldtest {
/** \class LEB128Test
* \brief
*
* \see LEB
*/
-class LEB128Test : public ::testing::Test
-{
-public:
- // Constructor can do set-up work for all test here.
- LEB128Test();
+class LEB128Test : public ::testing::Test {
+ public:
+ // Constructor can do set-up work for all test here.
+ LEB128Test();
- // Destructor can do clean-up work that doesn't throw exceptions here.
- virtual ~LEB128Test();
+ // Destructor can do clean-up work that doesn't throw exceptions here.
+ virtual ~LEB128Test();
- // SetUp() will be called immediately before each test.
- virtual void SetUp();
+ // SetUp() will be called immediately before each test.
+ virtual void SetUp();
- // TearDown() will be called immediately after each test.
- virtual void TearDown();
+ // TearDown() will be called immediately after each test.
+ virtual void TearDown();
};
-} // namespace of mcldtest
+} // namespace of mcldtest
#endif
-
diff --git a/unittests/LinearAllocatorTest.cpp b/unittests/LinearAllocatorTest.cpp
index d38684a..bc8092e 100644
--- a/unittests/LinearAllocatorTest.cpp
+++ b/unittests/LinearAllocatorTest.cpp
@@ -7,133 +7,127 @@
//
//===----------------------------------------------------------------------===//
#include "LinearAllocatorTest.h"
-#include <mcld/Support/Allocators.h>
+#include "mcld/Support/Allocators.h"
using namespace mcld;
using namespace mcldtest;
-
// Constructor can do set-up work for all test here.
-LinearAllocatorTest::LinearAllocatorTest()
-{
- // create testee. modify it if need
- m_pTestee = new LinearAllocator<Data, CHUNK_SIZE>();
+LinearAllocatorTest::LinearAllocatorTest() {
+ // create testee. modify it if need
+ m_pTestee = new LinearAllocator<Data, CHUNK_SIZE>();
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-LinearAllocatorTest::~LinearAllocatorTest()
-{
- delete m_pTestee;
+LinearAllocatorTest::~LinearAllocatorTest() {
+ delete m_pTestee;
}
// SetUp() will be called immediately before each test.
-void LinearAllocatorTest::SetUp()
-{
+void LinearAllocatorTest::SetUp() {
}
// TearDown() will be called immediately after each test.
-void LinearAllocatorTest::TearDown()
-{
+void LinearAllocatorTest::TearDown() {
}
//==========================================================================//
// Testcases
//
-TEST_F( LinearAllocatorTest, allocateN ) {
- Data* pointer = m_pTestee->allocate(10);
- ASSERT_FALSE(0 == pointer);
- ASSERT_EQ(CHUNK_SIZE, m_pTestee->max_size());
- ASSERT_FALSE(m_pTestee->empty());
+TEST_F(LinearAllocatorTest, allocateN) {
+ Data* pointer = m_pTestee->allocate(10);
+ ASSERT_FALSE(0 == pointer);
+ ASSERT_EQ(CHUNK_SIZE, m_pTestee->max_size());
+ ASSERT_FALSE(m_pTestee->empty());
}
-TEST_F( LinearAllocatorTest, allocate ) {
- Data* pointer = m_pTestee->allocate();
- ASSERT_FALSE(0 == pointer);
- ASSERT_EQ(CHUNK_SIZE, m_pTestee->max_size());
- ASSERT_FALSE(m_pTestee->empty());
+TEST_F(LinearAllocatorTest, allocate) {
+ Data* pointer = m_pTestee->allocate();
+ ASSERT_FALSE(0 == pointer);
+ ASSERT_EQ(CHUNK_SIZE, m_pTestee->max_size());
+ ASSERT_FALSE(m_pTestee->empty());
}
-TEST_F( LinearAllocatorTest, allocateOver ) {
- Data* pointer = m_pTestee->allocate(CHUNK_SIZE+1);
- ASSERT_TRUE(0 == pointer);
- ASSERT_TRUE(0 == m_pTestee->max_size());
- ASSERT_TRUE(m_pTestee->empty());
+TEST_F(LinearAllocatorTest, allocateOver) {
+ Data* pointer = m_pTestee->allocate(CHUNK_SIZE + 1);
+ ASSERT_TRUE(0 == pointer);
+ ASSERT_TRUE(0 == m_pTestee->max_size());
+ ASSERT_TRUE(m_pTestee->empty());
}
-TEST_F( LinearAllocatorTest, alloc_construct ) {
- Data* pointer = m_pTestee->allocate();
- m_pTestee->construct(pointer);
- ASSERT_TRUE(1 == pointer->one);
- ASSERT_TRUE(2 == pointer->two);
- ASSERT_TRUE(3 == pointer->three);
- ASSERT_TRUE(4 == pointer->four);
+TEST_F(LinearAllocatorTest, alloc_construct) {
+ Data* pointer = m_pTestee->allocate();
+ m_pTestee->construct(pointer);
+ ASSERT_TRUE(1 == pointer->one);
+ ASSERT_TRUE(2 == pointer->two);
+ ASSERT_TRUE(3 == pointer->three);
+ ASSERT_TRUE(4 == pointer->four);
}
-TEST_F( LinearAllocatorTest, alloc_constructCopy ) {
- Data* pointer = m_pTestee->allocate();
- Data data(7, 7, 7, 7);
- m_pTestee->construct(pointer, data);
-
- ASSERT_TRUE(7 == pointer->one);
- ASSERT_TRUE(7 == pointer->two);
- ASSERT_TRUE(7 == pointer->three);
- ASSERT_TRUE(7 == pointer->four);
-}
+TEST_F(LinearAllocatorTest, alloc_constructCopy) {
+ Data* pointer = m_pTestee->allocate();
+ Data data(7, 7, 7, 7);
+ m_pTestee->construct(pointer, data);
-TEST_F( LinearAllocatorTest, allocN_construct ) {
- Data* pointer = m_pTestee->allocate(10);
- m_pTestee->construct(pointer);
- ASSERT_TRUE(1 == pointer->one);
- ASSERT_TRUE(2 == pointer->two);
- ASSERT_TRUE(3 == pointer->three);
- ASSERT_TRUE(4 == pointer->four);
+ ASSERT_TRUE(7 == pointer->one);
+ ASSERT_TRUE(7 == pointer->two);
+ ASSERT_TRUE(7 == pointer->three);
+ ASSERT_TRUE(7 == pointer->four);
}
-TEST_F( LinearAllocatorTest, allocN_constructCopy ) {
- Data* pointer = m_pTestee->allocate(10);
- Data data(7, 7, 7, 7);
- m_pTestee->construct(pointer, data);
-
- ASSERT_TRUE(7 == pointer->one);
- ASSERT_TRUE(7 == pointer->two);
- ASSERT_TRUE(7 == pointer->three);
- ASSERT_TRUE(7 == pointer->four);
+TEST_F(LinearAllocatorTest, allocN_construct) {
+ Data* pointer = m_pTestee->allocate(10);
+ m_pTestee->construct(pointer);
+ ASSERT_TRUE(1 == pointer->one);
+ ASSERT_TRUE(2 == pointer->two);
+ ASSERT_TRUE(3 == pointer->three);
+ ASSERT_TRUE(4 == pointer->four);
}
-TEST_F( LinearAllocatorTest, multi_alloc_ctor_iterate ) {
- for (int i=0; i<101; ++i) {
- Data* pointer = m_pTestee->allocate();
- m_pTestee->construct(pointer);
- pointer->one = i;
- }
-/**
- Alloc::iterator data, dEnd = m_pTestee->end();
- int counter = 0;
- for (data=m_pTestee->begin(); data!=dEnd; ++data) {
- ASSERT_EQ(counter, (*data).one);
- ++counter;
- }
-**/
+TEST_F(LinearAllocatorTest, allocN_constructCopy) {
+ Data* pointer = m_pTestee->allocate(10);
+ Data data(7, 7, 7, 7);
+ m_pTestee->construct(pointer, data);
+
+ ASSERT_TRUE(7 == pointer->one);
+ ASSERT_TRUE(7 == pointer->two);
+ ASSERT_TRUE(7 == pointer->three);
+ ASSERT_TRUE(7 == pointer->four);
}
-TEST_F( LinearAllocatorTest, multi_allocN_ctor_iterate ) {
- int counter = 0;
- for (int i=0; i<10000; ++i) {
- Data* pointer = m_pTestee->allocate(10);
- for (int j=0; j<10; ++j) {
- m_pTestee->construct(pointer);
- pointer->one = counter;
- ++pointer;
- ++counter;
- }
- }
-/**
- Alloc::iterator data, dEnd = m_pTestee->end();
- counter = 0;
- for (data=m_pTestee->begin(); data!=dEnd; ++data) {
- ASSERT_EQ(counter, (*data).one);
- ++counter;
- }
-**/
+TEST_F(LinearAllocatorTest, multi_alloc_ctor_iterate) {
+ for (int i = 0; i < 101; ++i) {
+ Data* pointer = m_pTestee->allocate();
+ m_pTestee->construct(pointer);
+ pointer->one = i;
+ }
+ /**
+ Alloc::iterator data, dEnd = m_pTestee->end();
+ int counter = 0;
+ for (data=m_pTestee->begin(); data!=dEnd; ++data) {
+ ASSERT_EQ(counter, (*data).one);
+ ++counter;
+ }
+ **/
}
+TEST_F(LinearAllocatorTest, multi_allocN_ctor_iterate) {
+ int counter = 0;
+ for (int i = 0; i < 10000; ++i) {
+ Data* pointer = m_pTestee->allocate(10);
+ for (int j = 0; j < 10; ++j) {
+ m_pTestee->construct(pointer);
+ pointer->one = counter;
+ ++pointer;
+ ++counter;
+ }
+ }
+ /**
+ Alloc::iterator data, dEnd = m_pTestee->end();
+ counter = 0;
+ for (data=m_pTestee->begin(); data!=dEnd; ++data) {
+ ASSERT_EQ(counter, (*data).one);
+ ++counter;
+ }
+ **/
+}
diff --git a/unittests/LinearAllocatorTest.h b/unittests/LinearAllocatorTest.h
index 24b8715..fd9db10 100644
--- a/unittests/LinearAllocatorTest.h
+++ b/unittests/LinearAllocatorTest.h
@@ -12,64 +12,62 @@
#include <gtest.h>
#include "mcld/Support/Allocators.h"
-namespace mcldtest
-{
+namespace mcldtest {
/** \class LinearAllocatorTest
* \brief The testcase for LinearAllocator
*
* \see LinearAllocator
*/
-class LinearAllocatorTest : public ::testing::Test
-{
-public:
- struct Data {
- Data()
- : one(1), two(2), three(3), four(4)
- { }
+class LinearAllocatorTest : public ::testing::Test {
+ public:
+ struct Data {
+ Data() : one(1), two(2), three(3), four(4) {}
- Data( unsigned int pOne, unsigned int pTwo, unsigned char pThree, unsigned char pFour)
- {
- one = pOne;
- two = pTwo;
- three = pThree;
- four = pFour;
- }
+ Data(unsigned int pOne,
+ unsigned int pTwo,
+ unsigned char pThree,
+ unsigned char pFour) {
+ one = pOne;
+ two = pTwo;
+ three = pThree;
+ four = pFour;
+ }
- ~Data()
- {
- one = -1;
- two = -2;
- three = -3;
- four = -4;
- }
+ ~Data() {
+ one = -1;
+ two = -2;
+ three = -3;
+ four = -4;
+ }
- unsigned int one;
- unsigned int two;
- unsigned char three;
- unsigned char four;
- };
-public:
- // Constructor can do set-up work for all test here.
- LinearAllocatorTest();
+ unsigned int one;
+ unsigned int two;
+ unsigned char three;
+ unsigned char four;
+ };
- // Destructor can do clean-up work that doesn't throw exceptions here.
- virtual ~LinearAllocatorTest();
+ public:
+ // Constructor can do set-up work for all test here.
+ LinearAllocatorTest();
- // SetUp() will be called immediately before each test.
- virtual void SetUp();
+ // Destructor can do clean-up work that doesn't throw exceptions here.
+ virtual ~LinearAllocatorTest();
- // TearDown() will be called immediately after each test.
- virtual void TearDown();
+ // SetUp() will be called immediately before each test.
+ virtual void SetUp();
-protected:
- enum TemplateArgsType { CHUNK_SIZE = 32 };
- typedef mcld::LinearAllocator<Data, CHUNK_SIZE> Alloc;
-protected:
- Alloc* m_pTestee;
+ // TearDown() will be called immediately after each test.
+ virtual void TearDown();
+
+ protected:
+ enum TemplateArgsType { CHUNK_SIZE = 32 };
+ typedef mcld::LinearAllocator<Data, CHUNK_SIZE> Alloc;
+
+ protected:
+ Alloc* m_pTestee;
};
-} // namespace of mcldtest
+} // namespace of mcldtest
#endif
-
diff --git a/unittests/LinkerTest.cpp b/unittests/LinkerTest.cpp
index f9d3224..2af4913 100644
--- a/unittests/LinkerTest.cpp
+++ b/unittests/LinkerTest.cpp
@@ -8,15 +8,15 @@
//===----------------------------------------------------------------------===//
#include "LinkerTest.h"
-#include <mcld/Environment.h>
-#include <mcld/Module.h>
-#include <mcld/InputTree.h>
-#include <mcld/IRBuilder.h>
-#include <mcld/Linker.h>
-#include <mcld/LinkerConfig.h>
-#include <mcld/LinkerScript.h>
+#include "mcld/Environment.h"
+#include "mcld/Module.h"
+#include "mcld/InputTree.h"
+#include "mcld/IRBuilder.h"
+#include "mcld/Linker.h"
+#include "mcld/LinkerConfig.h"
+#include "mcld/LinkerScript.h"
-#include <mcld/Support/Path.h>
+#include "mcld/Support/Path.h"
#include <llvm/Support/ELF.h>
@@ -24,32 +24,26 @@ using namespace mcld;
using namespace mcld::test;
using namespace mcld::sys::fs;
-
// Constructor can do set-up work for all test here.
-LinkerTest::LinkerTest()
-{
+LinkerTest::LinkerTest() {
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-LinkerTest::~LinkerTest()
-{
+LinkerTest::~LinkerTest() {
}
// SetUp() will be called immediately before each test.
-void LinkerTest::SetUp()
-{
+void LinkerTest::SetUp() {
}
// TearDown() will be called immediately after each test.
-void LinkerTest::TearDown()
-{
+void LinkerTest::TearDown() {
}
//===----------------------------------------------------------------------===//
// Testcases
//===----------------------------------------------------------------------===//
-TEST_F( LinkerTest, set_up_n_clean_up) {
-
+TEST_F(LinkerTest, set_up_n_clean_up) {
Initialize();
LinkerConfig config("arm-none-linux-gnueabi");
LinkerScript script;
@@ -77,8 +71,7 @@ TEST_F( LinkerTest, set_up_n_clean_up) {
// -lm -llog -ljnigraphics -lc
// %p/../../../libs/ARM/Android/android-14/crtend_so.o
// -o libplasma.so
-TEST_F( LinkerTest, plasma) {
-
+TEST_F(LinkerTest, plasma) {
Initialize();
Linker linker;
LinkerScript script;
@@ -124,7 +117,7 @@ TEST_F( LinkerTest, plasma) {
builder.ReadInput("crtend", crtend);
if (linker.link(module, builder)) {
- linker.emit(module, "libplasma.so"); ///< -o libplasma.so
+ linker.emit(module, "libplasma.so"); ///< -o libplasma.so
}
Finalize();
@@ -132,11 +125,11 @@ TEST_F( LinkerTest, plasma) {
// The outputs generated without -Bsymbolic usually have more relocation
// entries than the outputs generated with -Bsymbolic. This testcase generates
-// output with -Bsymbolic first, then generate the same output without -Bsymbolic.
+// output with -Bsymbolic first, then generate the same output without
+// -Bsymbolic.
// By this way, we can make sure symbols and relocations are cleaned between
// two linkings.
-TEST_F( LinkerTest, plasma_twice) {
-
+TEST_F(LinkerTest, plasma_twice) {
Initialize();
Linker linker;
@@ -154,8 +147,9 @@ TEST_F( LinkerTest, plasma_twice) {
linker.emulate(script1, config1);
config1.setCodeGenType(LinkerConfig::DynObj); ///< --shared
- config1.options().setSOName("libplasma.once.so"); ///< --soname=libplasma.twice.so
- config1.options().setBsymbolic(false); ///< -Bsymbolic
+ config1.options().setSOName(
+ "libplasma.once.so"); ///< --soname=libplasma.twice.so
+ config1.options().setBsymbolic(false); ///< -Bsymbolic
Module module1("libplasma.once.so", script1);
IRBuilder builder1(module1, config1);
@@ -182,7 +176,7 @@ TEST_F( LinkerTest, plasma_twice) {
builder1.ReadInput("crtend", crtend);
if (linker.link(module1, builder1)) {
- linker.emit(module1, "libplasma.once.so"); ///< -o libplasma.so
+ linker.emit(module1, "libplasma.once.so"); ///< -o libplasma.so
}
Finalize();
@@ -203,8 +197,9 @@ TEST_F( LinkerTest, plasma_twice) {
linker.emulate(script2, config2);
config2.setCodeGenType(LinkerConfig::DynObj); ///< --shared
- config2.options().setSOName("libplasma.twice.so"); ///< --soname=libplasma.twice.exe
- config2.options().setBsymbolic(); ///< -Bsymbolic
+ config2.options().setSOName(
+ "libplasma.twice.so"); ///< --soname=libplasma.twice.exe
+ config2.options().setBsymbolic(); ///< -Bsymbolic
Module module2("libplasma.so", script2);
IRBuilder builder2(module2, config2);
@@ -225,15 +220,14 @@ TEST_F( LinkerTest, plasma_twice) {
builder2.ReadInput("crtend", crtend);
if (linker.link(module2, builder2)) {
- linker.emit(module2, "libplasma.twice.so"); ///< -o libplasma.exe
+ linker.emit(module2, "libplasma.twice.so"); ///< -o libplasma.exe
}
Finalize();
}
// This testcase put IRBuilder in the heap
-TEST_F( LinkerTest, plasma_twice_irbuilder_heap) {
-
+TEST_F(LinkerTest, plasma_twice_irbuilder_heap) {
Initialize();
Linker linker;
@@ -251,11 +245,12 @@ TEST_F( LinkerTest, plasma_twice_irbuilder_heap) {
linker.emulate(script1, config1);
config1.setCodeGenType(LinkerConfig::DynObj); ///< --shared
- config1.options().setSOName("libplasma.once.so"); ///< --soname=libplasma.twice.so
- config1.options().setBsymbolic(false); ///< -Bsymbolic
+ config1.options().setSOName(
+ "libplasma.once.so"); ///< --soname=libplasma.twice.so
+ config1.options().setBsymbolic(false); ///< -Bsymbolic
Module module1("libplasma.once.so", script1);
- IRBuilder *builder1 = new IRBuilder(module1, config1);
+ IRBuilder* builder1 = new IRBuilder(module1, config1);
/// ${TOPDIR}/test/libs/ARM/Android/android-14/crtbegin_so.o
Path crtbegin(search_dir);
@@ -279,7 +274,7 @@ TEST_F( LinkerTest, plasma_twice_irbuilder_heap) {
builder1->ReadInput("crtend", crtend);
if (linker.link(module1, *builder1)) {
- linker.emit(module1, "libplasma.once.so"); ///< -o libplasma.so
+ linker.emit(module1, "libplasma.once.so"); ///< -o libplasma.so
}
// Can not delete builder until emit the output. Dynamic string table
@@ -305,8 +300,9 @@ TEST_F( LinkerTest, plasma_twice_irbuilder_heap) {
linker.emulate(script2, config2);
config2.setCodeGenType(LinkerConfig::DynObj); ///< --shared
- config2.options().setSOName("libplasma.twice.so"); ///< --soname=libplasma.twice.exe
- config2.options().setBsymbolic(); ///< -Bsymbolic
+ config2.options().setSOName(
+ "libplasma.twice.so"); ///< --soname=libplasma.twice.exe
+ config2.options().setBsymbolic(); ///< -Bsymbolic
Module module2("libplasma.so", script2);
IRBuilder* builder2 = new IRBuilder(module2, config2);
@@ -327,7 +323,7 @@ TEST_F( LinkerTest, plasma_twice_irbuilder_heap) {
builder2->ReadInput("crtend", crtend);
if (linker.link(module2, *builder2)) {
- linker.emit(module2, "libplasma.twice.so"); ///< -o libplasma.exe
+ linker.emit(module2, "libplasma.twice.so"); ///< -o libplasma.exe
}
delete builder2;
@@ -336,8 +332,7 @@ TEST_F( LinkerTest, plasma_twice_irbuilder_heap) {
// %MCLinker --shared -soname=libgotplt.so -mtriple arm-none-linux-gnueabi
// gotplt.o -o libgotplt.so
-TEST_F( LinkerTest, plasma_object) {
-
+TEST_F(LinkerTest, plasma_object) {
Initialize();
Linker linker;
@@ -360,96 +355,127 @@ TEST_F( LinkerTest, plasma_object) {
Input* input = builder.CreateInput("gotplt.o", gotplt_o, Input::Object);
/// Sections
- /// [ 0] NULL 00000000 000000 000000 00 0 0 0
- builder.CreateELFHeader(*input,
- "",
- LDFileFormat::Null,
- llvm::ELF::SHT_NULL,
- 0x0);
-
- /// [ 1] .text PROGBITS 00000000 000034 000010 00 AX 0 0 4
- LDSection* text = builder.CreateELFHeader(*input,
+ /// [ 0] NULL 00000000 000000 000000 00 0
+ /// 0 0
+ builder.CreateELFHeader(
+ *input, "", LDFileFormat::Null, llvm::ELF::SHT_NULL, 0x0);
+
+ /// [ 1] .text PROGBITS 00000000 000034 000010 00 AX 0
+ /// 0 4
+ LDSection* text =
+ builder.CreateELFHeader(*input,
".text",
llvm::ELF::SHT_PROGBITS,
llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_EXECINSTR,
4);
SectionData* text_data = builder.CreateSectionData(*text);
- static uint8_t text_content[] = { 0x00, 0x48, 0x2d, 0xe9,
- 0xfe, 0xff, 0xff, 0xeb,
- 0x00, 0x48, 0xbd, 0xe8,
- 0x0e, 0xf0, 0xa0, 0xe1 };
+ static uint8_t text_content[] = {
+ 0x00, 0x48, 0x2d, 0xe9,
+ 0xfe, 0xff, 0xff, 0xeb,
+ 0x00, 0x48, 0xbd, 0xe8,
+ 0x0e, 0xf0, 0xa0, 0xe1
+ };
+
Fragment* text_frag = builder.CreateRegion(text_content, 0x10);
builder.AppendFragment(*text_frag, *text_data);
- /// [ 2] .rel.text REL 00000000 0002ac 000008 08 7 1 4
- LDSection* rel_text = builder.CreateELFHeader(*input,
- ".rel.text",
- llvm::ELF::SHT_REL,
- 0x0, 4);
+ /// [ 2] .rel.text REL 00000000 0002ac 000008 08 7
+ /// 1 4
+ LDSection* rel_text =
+ builder.CreateELFHeader(*input, ".rel.text", llvm::ELF::SHT_REL, 0x0, 4);
rel_text->setLink(text);
builder.CreateRelocData(*rel_text);
- /// [ 3] .data PROGBITS 00000000 000044 000000 00 WA 0 0 4
- LDSection* data = builder.CreateELFHeader(*input,
- ".data",
- llvm::ELF::SHT_PROGBITS,
- llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_WRITE,
- 4);
-
- /// [ 4] .bss NOBITS 00000000 000044 000000 00 WA 0 0 4
- LDSection* bss = builder.CreateELFHeader(*input,
- ".bss",
- llvm::ELF::SHT_NOBITS,
- llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_WRITE,
- 4);
+ /// [ 3] .data PROGBITS 00000000 000044 000000 00 WA 0
+ /// 0 4
+ LDSection* data =
+ builder.CreateELFHeader(*input,
+ ".data",
+ llvm::ELF::SHT_PROGBITS,
+ llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_WRITE,
+ 4);
+
+ /// [ 4] .bss NOBITS 00000000 000044 000000 00 WA 0
+ /// 0 4
+ LDSection* bss =
+ builder.CreateELFHeader(*input,
+ ".bss",
+ llvm::ELF::SHT_NOBITS,
+ llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_WRITE,
+ 4);
builder.CreateBSS(*bss);
- /// [ 5] .ARM.attributes ARM_ATTRIBUTES 00000000 000044 000020 00 0 0 1
- LDSection* attr = builder.CreateELFHeader(*input,
- ".ARM.attributes",
- llvm::ELF::SHT_ARM_ATTRIBUTES,
- 0x0,
- 1);
+ /// [ 5] .ARM.attributes ARM_ATTRIBUTES 00000000 000044 000020 00 0
+ /// 0 1
+ LDSection* attr = builder.CreateELFHeader(
+ *input, ".ARM.attributes", llvm::ELF::SHT_ARM_ATTRIBUTES, 0x0, 1);
SectionData* attr_data = builder.CreateSectionData(*attr);
static uint8_t attr_content[] = {
- 0x41, 0x1f, 0x00, 0x00,
- 0x00, 0x61, 0x65, 0x61,
- 0x62, 0x69, 0x00, 0x01,
- 0x15, 0x00, 0x00, 0x00,
- 0x06, 0x02, 0x08, 0x01,
- 0x09, 0x01, 0x14, 0x01,
- 0x15, 0x01, 0x17, 0x03,
- 0x18, 0x01, 0x19, 0x01 };
+ 0x41, 0x1f, 0x00, 0x00,
+ 0x00, 0x61, 0x65, 0x61,
+ 0x62, 0x69, 0x00, 0x01,
+ 0x15, 0x00, 0x00, 0x00,
+ 0x06, 0x02, 0x08, 0x01,
+ 0x09, 0x01, 0x14, 0x01,
+ 0x15, 0x01, 0x17, 0x03,
+ 0x18, 0x01, 0x19, 0x01
+ };
+
Fragment* attr_frag = builder.CreateRegion(attr_content, 0x20);
builder.AppendFragment(*attr_frag, *attr_data);
/// Symbols
/// 1: 00000000 0 FILE LOCAL DEFAULT ABS Output/gotplt.bc
builder.AddSymbol(*input,
- "Output/gotplt.bc", ResolveInfo::File,
- ResolveInfo::Define, ResolveInfo::Local, 0);
+ "Output/gotplt.bc",
+ ResolveInfo::File,
+ ResolveInfo::Define,
+ ResolveInfo::Local,
+ 0);
/// 2: 00000000 0 SECTION LOCAL DEFAULT 1
builder.AddSymbol(*input,
- ".text", ResolveInfo::Section,
- ResolveInfo::Define, ResolveInfo::Local, 0, 0x0, text);
+ ".text",
+ ResolveInfo::Section,
+ ResolveInfo::Define,
+ ResolveInfo::Local,
+ 0,
+ 0x0,
+ text);
/// 3: 00000000 0 SECTION LOCAL DEFAULT 3
builder.AddSymbol(*input,
- ".data", ResolveInfo::Section,
- ResolveInfo::Define, ResolveInfo::Local, 0, 0x0, data);
+ ".data",
+ ResolveInfo::Section,
+ ResolveInfo::Define,
+ ResolveInfo::Local,
+ 0,
+ 0x0,
+ data);
/// 4: 00000000 0 SECTION LOCAL DEFAULT 4
builder.AddSymbol(*input,
- ".bss", ResolveInfo::Section,
- ResolveInfo::Define, ResolveInfo::Local, 0, 0x0, bss);
+ ".bss",
+ ResolveInfo::Section,
+ ResolveInfo::Define,
+ ResolveInfo::Local,
+ 0,
+ 0x0,
+ bss);
/// 5: 00000000 0 SECTION LOCAL DEFAULT 5
builder.AddSymbol(*input,
- ".ARM.attributes", ResolveInfo::Section,
- ResolveInfo::Define, ResolveInfo::Local, 0, 0x0, attr);
+ ".ARM.attributes",
+ ResolveInfo::Section,
+ ResolveInfo::Define,
+ ResolveInfo::Local,
+ 0,
+ 0x0,
+ attr);
/// 6: 00000000 16 FUNC GLOBAL DEFAULT 1 _Z1fv
builder.AddSymbol(*input,
- "_Z1fv", ResolveInfo::Function,
- ResolveInfo::Define, ResolveInfo::Global,
+ "_Z1fv",
+ ResolveInfo::Function,
+ ResolveInfo::Define,
+ ResolveInfo::Global,
16,
0x0,
text);
@@ -462,13 +488,13 @@ TEST_F( LinkerTest, plasma_object) {
ResolveInfo::Global,
0);
- /// Relocations
- /// Offset Info Type Sym.Value Sym. Name
- /// 00000004 0000071b R_ARM_PLT32 00000000 _Z1gv
- builder.AddRelocation(*rel_text, llvm::ELF::R_ARM_PLT32, *z1gv, 0x4);
+ /// Relocations
+ /// Offset Info Type Sym.Value Sym. Name
+ /// 00000004 0000071b R_ARM_PLT32 00000000 _Z1gv
+ builder.AddRelocation(*rel_text, llvm::ELF::R_ARM_PLT32, *z1gv, 0x4);
if (linker.link(module, builder)) {
- linker.emit(module, "libgotplt.so"); ///< -o libgotplt.so
+ linker.emit(module, "libgotplt.so"); ///< -o libgotplt.so
}
Finalize();
diff --git a/unittests/LinkerTest.h b/unittests/LinkerTest.h
index cb60d40..f20fd62 100644
--- a/unittests/LinkerTest.h
+++ b/unittests/LinkerTest.h
@@ -17,9 +17,8 @@ class Linker;
namespace test {
-class LinkerTest : public ::testing::Test
-{
-public:
+class LinkerTest : public ::testing::Test {
+ public:
// Constructor can do set-up work for all test here.
LinkerTest();
@@ -33,8 +32,7 @@ public:
virtual void TearDown();
};
-} // namespace of test
-} // namespace for mcld
+} // namespace of test
+} // namespace for mcld
#endif
-
diff --git a/unittests/MCRegionFragmentTest.cpp b/unittests/MCRegionFragmentTest.cpp
index 7d6c3b9..0319845 100644
--- a/unittests/MCRegionFragmentTest.cpp
+++ b/unittests/MCRegionFragmentTest.cpp
@@ -9,47 +9,42 @@
#include "MCRegionFragmentTest.h"
-#include <mcld/MC/MCRegionFragment.h>
-#include <mcld/Support/MemoryAreaFactory.h>
-#include <mcld/Support/Path.h>
+#include "mcld/MC/MCRegionFragment.h"
+#include "mcld/Support/MemoryAreaFactory.h"
+#include "mcld/Support/Path.h"
using namespace mcld;
using namespace mcldtest;
using namespace mcld::sys::fs;
-
// Constructor can do set-up work for all test here.
-MCRegionFragmentTest::MCRegionFragmentTest()
-{
+MCRegionFragmentTest::MCRegionFragmentTest() {
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-MCRegionFragmentTest::~MCRegionFragmentTest()
-{
+MCRegionFragmentTest::~MCRegionFragmentTest() {
}
// SetUp() will be called immediately before each test.
-void MCRegionFragmentTest::SetUp()
-{
+void MCRegionFragmentTest::SetUp() {
}
// TearDown() will be called immediately after each test.
-void MCRegionFragmentTest::TearDown()
-{
+void MCRegionFragmentTest::TearDown() {
}
//==========================================================================//
// Testcases
//
-TEST_F( MCRegionFragmentTest, classof_explicit ) {
+TEST_F(MCRegionFragmentTest, classof_explicit) {
Path path(TOPDIR);
path.append("unittests/test3.txt");
MemoryAreaFactory* areaFactory = new MemoryAreaFactory(1);
MemoryArea* area = areaFactory->produce(path, MemoryArea::ReadWrite);
MemoryRegion* region = area->request(0, 4096);
- MCRegionFragment *frag = new MCRegionFragment(*region);
+ MCRegionFragment* frag = new MCRegionFragment(*region);
ASSERT_FALSE(llvm::MCDataFragment::classof(frag));
ASSERT_TRUE(MCRegionFragment::classof(frag));
@@ -57,18 +52,17 @@ TEST_F( MCRegionFragmentTest, classof_explicit ) {
delete areaFactory;
}
-TEST_F( MCRegionFragmentTest, classof_implicit ) {
+TEST_F(MCRegionFragmentTest, classof_implicit) {
Path path(TOPDIR);
path.append("unittests/test3.txt");
MemoryAreaFactory* areaFactory = new MemoryAreaFactory(1);
MemoryArea* area = areaFactory->produce(path, MemoryArea::ReadWrite);
MemoryRegion* region = area->request(0, 4096);
- llvm::MCFragment *frag = new MCRegionFragment(*region);
+ llvm::MCFragment* frag = new MCRegionFragment(*region);
ASSERT_FALSE(llvm::MCDataFragment::classof(frag));
ASSERT_TRUE(MCRegionFragment::classof(frag));
delete frag;
delete areaFactory;
}
-
diff --git a/unittests/MCRegionFragmentTest.h b/unittests/MCRegionFragmentTest.h
index 3d1dab8..5b9e00b 100644
--- a/unittests/MCRegionFragmentTest.h
+++ b/unittests/MCRegionFragmentTest.h
@@ -12,40 +12,36 @@
#include <gtest.h>
-namespace mcld
-{
+namespace mcld {
class MCRegionFragment;
-} // namespace for mcld
+} // namespace for mcld
-namespace mcldtest
-{
+namespace mcldtest {
/** \class MCRegionFragmentTest
* \brief The testcase of MCRegionFragment.
*
* \see MCRegionFragment
*/
-class MCRegionFragmentTest : public ::testing::Test
-{
-public:
- // Constructor can do set-up work for all test here.
- MCRegionFragmentTest();
+class MCRegionFragmentTest : public ::testing::Test {
+ public:
+ // Constructor can do set-up work for all test here.
+ MCRegionFragmentTest();
- // Destructor can do clean-up work that doesn't throw exceptions here.
- virtual ~MCRegionFragmentTest();
+ // Destructor can do clean-up work that doesn't throw exceptions here.
+ virtual ~MCRegionFragmentTest();
- // SetUp() will be called immediately before each test.
- virtual void SetUp();
+ // SetUp() will be called immediately before each test.
+ virtual void SetUp();
- // TearDown() will be called immediately after each test.
- virtual void TearDown();
+ // TearDown() will be called immediately after each test.
+ virtual void TearDown();
-protected:
- mcld::MCRegionFragment* m_pTestee;
+ protected:
+ mcld::MCRegionFragment* m_pTestee;
};
-} // namespace of mcldtest
+} // namespace of mcldtest
#endif
-
diff --git a/unittests/NamePoolTest.cpp b/unittests/NamePoolTest.cpp
index 614ee6a..57c78fe 100644
--- a/unittests/NamePoolTest.cpp
+++ b/unittests/NamePoolTest.cpp
@@ -7,11 +7,11 @@
//
//===----------------------------------------------------------------------===//
#include "NamePoolTest.h"
-#include <mcld/LD/NamePool.h>
-#include <mcld/LD/Resolver.h>
-#include <mcld/LD/StaticResolver.h>
-#include <mcld/LD/ResolveInfo.h>
-#include <mcld/LD/LDSymbol.h>
+#include "mcld/LD/NamePool.h"
+#include "mcld/LD/Resolver.h"
+#include "mcld/LD/StaticResolver.h"
+#include "mcld/LD/ResolveInfo.h"
+#include "mcld/LD/LDSymbol.h"
#include <llvm/ADT/StringRef.h>
#include <string>
#include <cstdio>
@@ -19,45 +19,39 @@
using namespace mcld;
using namespace mcldtest;
-
// Constructor can do set-up work for all test here.
-NamePoolTest::NamePoolTest()
-{
+NamePoolTest::NamePoolTest() {
// create testee. modify it if need
StaticResolver resolver;
m_pTestee = new NamePool(resolver, 10);
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-NamePoolTest::~NamePoolTest()
-{
+NamePoolTest::~NamePoolTest() {
delete m_pTestee;
}
// SetUp() will be called immediately before each test.
-void NamePoolTest::SetUp()
-{
+void NamePoolTest::SetUp() {
}
// TearDown() will be called immediately after each test.
-void NamePoolTest::TearDown()
-{
+void NamePoolTest::TearDown() {
}
//==========================================================================//
// Testcases
//
-
-TEST_F( NamePoolTest, insertString ) {
- const char *s1 = "Hello MCLinker";
+TEST_F(NamePoolTest, insertString) {
+ const char* s1 = "Hello MCLinker";
llvm::StringRef result1 = m_pTestee->insertString(s1);
EXPECT_NE(s1, result1.data());
EXPECT_STREQ(s1, result1.data());
}
-TEST_F( NamePoolTest, insertSameString ) {
- const char *s1 = "Hello MCLinker";
+TEST_F(NamePoolTest, insertSameString) {
+ const char* s1 = "Hello MCLinker";
std::string s2(s1);
llvm::StringRef result1 = m_pTestee->insertString(s1);
llvm::StringRef result2 = m_pTestee->insertString(s2.c_str());
@@ -66,8 +60,8 @@ TEST_F( NamePoolTest, insertSameString ) {
EXPECT_EQ(result1.data(), result2.data());
}
-TEST_F( NamePoolTest, insert_local_defined_Symbol ) {
- const char *name = "Hello MCLinker";
+TEST_F(NamePoolTest, insert_local_defined_Symbol) {
+ const char* name = "Hello MCLinker";
bool isDyn = false;
ResolveInfo::Type type = ResolveInfo::Function;
ResolveInfo::Desc desc = ResolveInfo::Define;
@@ -76,15 +70,8 @@ TEST_F( NamePoolTest, insert_local_defined_Symbol ) {
uint64_t size = 0;
ResolveInfo::Visibility other = ResolveInfo::Default;
Resolver::Result result1;
- m_pTestee->insertSymbol(name,
- isDyn,
- type,
- desc,
- binding,
- size,
- other,
- NULL,
- result1);
+ m_pTestee->insertSymbol(
+ name, isDyn, type, desc, binding, size, other, NULL, result1);
EXPECT_NE(name, result1.info->name());
EXPECT_STREQ(name, result1.info->name());
@@ -96,15 +83,8 @@ TEST_F( NamePoolTest, insert_local_defined_Symbol ) {
EXPECT_EQ(other, result1.info->visibility());
Resolver::Result result2;
- m_pTestee->insertSymbol(name,
- isDyn,
- type,
- desc,
- binding,
- size,
- other,
- NULL,
- result2);
+ m_pTestee->insertSymbol(
+ name, isDyn, type, desc, binding, size, other, NULL, result2);
EXPECT_NE(name, result1.info->name());
EXPECT_STREQ(name, result1.info->name());
@@ -118,8 +98,8 @@ TEST_F( NamePoolTest, insert_local_defined_Symbol ) {
EXPECT_NE(result1.existent, result2.existent);
}
-TEST_F( NamePoolTest, insert_global_reference_Symbol ) {
- const char *name = "Hello MCLinker";
+TEST_F(NamePoolTest, insert_global_reference_Symbol) {
+ const char* name = "Hello MCLinker";
bool isDyn = false;
ResolveInfo::Type type = ResolveInfo::NoType;
ResolveInfo::Desc desc = ResolveInfo::Undefined;
@@ -127,15 +107,8 @@ TEST_F( NamePoolTest, insert_global_reference_Symbol ) {
uint64_t size = 0;
ResolveInfo::Visibility other = ResolveInfo::Default;
Resolver::Result result1;
- m_pTestee->insertSymbol(name,
- isDyn,
- type,
- desc,
- binding,
- size,
- other,
- NULL,
- result1);
+ m_pTestee->insertSymbol(
+ name, isDyn, type, desc, binding, size, other, NULL, result1);
EXPECT_NE(name, result1.info->name());
EXPECT_STREQ(name, result1.info->name());
@@ -147,15 +120,8 @@ TEST_F( NamePoolTest, insert_global_reference_Symbol ) {
EXPECT_EQ(other, result1.info->visibility());
Resolver::Result result2;
- m_pTestee->insertSymbol(name,
- isDyn,
- type,
- desc,
- binding,
- size,
- other,
- NULL,
- result2);
+ m_pTestee->insertSymbol(
+ name, isDyn, type, desc, binding, size, other, NULL, result2);
EXPECT_EQ(result1.info, result2.info);
@@ -170,98 +136,71 @@ TEST_F( NamePoolTest, insert_global_reference_Symbol ) {
NULL,
result3);
-
EXPECT_NE(result1.info, result3.info);
}
-
-TEST_F( NamePoolTest, insertSymbol_after_insert_same_string ) {
- const char *name = "Hello MCLinker";
+TEST_F(NamePoolTest, insertSymbol_after_insert_same_string) {
+ const char* name = "Hello MCLinker";
bool isDyn = false;
LDSymbol::Type type = LDSymbol::Defined;
LDSymbol::Binding binding = LDSymbol::Global;
- const llvm::MCSectionData *section = 0;
+ const llvm::MCSectionData* section = 0;
uint64_t value = 0;
uint64_t size = 0;
uint8_t other = 0;
- const char *result1 = m_pTestee->insertString(name);
- LDSymbol *sym = m_pTestee->insertSymbol(name,
- isDyn,
- type,
- binding,
- section,
- value,
- size,
- other);
+ const char* result1 = m_pTestee->insertString(name);
+ LDSymbol* sym = m_pTestee->insertSymbol(
+ name, isDyn, type, binding, section, value, size, other);
EXPECT_STREQ(name, sym->name());
EXPECT_EQ(result1, sym->name());
char s[16];
strcpy(s, result1);
- const char *result2 = m_pTestee->insertString(result1);
- const char *result3 = m_pTestee->insertString(s);
+ const char* result2 = m_pTestee->insertString(result1);
+ const char* result3 = m_pTestee->insertString(s);
EXPECT_EQ(result1, result2);
EXPECT_EQ(result1, result3);
}
-
-TEST_F( NamePoolTest, insert_16384_weak_reference_symbols ) {
+TEST_F(NamePoolTest, insert_16384_weak_reference_symbols) {
char name[16];
bool isDyn = false;
LDSymbol::Type type = LDSymbol::Reference;
LDSymbol::Binding binding = LDSymbol::Weak;
- const llvm::MCSectionData *section = 0;
+ const llvm::MCSectionData* section = 0;
uint64_t value = 0;
uint64_t size = 0;
uint8_t other = 0;
strcpy(name, "Hello MCLinker");
- LDSymbol *syms[128][128];
- for(int i=0; i<128 ;++i) {
+ LDSymbol* syms[128][128];
+ for (int i = 0; i < 128; ++i) {
name[0] = i;
- for(int j=0; j<128 ;++j) {
+ for (int j = 0; j < 128; ++j) {
name[1] = j;
- syms[i][j] = m_pTestee->insertSymbol(name,
- isDyn,
- type,
- binding,
- section,
- value,
- size,
- other);
+ syms[i][j] = m_pTestee->insertSymbol(
+ name, isDyn, type, binding, section, value, size, other);
ASSERT_STREQ(name, syms[i][j]->name());
}
}
- for(int i=127; i>=0 ;--i) {
+ for (int i = 127; i >= 0; --i) {
name[0] = i;
- for(int j=0; j<128 ;++j) {
+ for (int j = 0; j < 128; ++j) {
name[1] = j;
- LDSymbol *sym = m_pTestee->insertSymbol(name,
- isDyn,
- type,
- binding,
- section,
- value,
- size,
- other);
+ LDSymbol* sym = m_pTestee->insertSymbol(
+ name, isDyn, type, binding, section, value, size, other);
ASSERT_EQ(sym, syms[i][j]);
}
}
- for(int i=0; i<128 ;++i) {
+ for (int i = 0; i < 128; ++i) {
name[0] = i;
- for(int j=0; j<128 ;++j) {
+ for (int j = 0; j < 128; ++j) {
name[1] = j;
- LDSymbol *sym = m_pTestee->insertSymbol(name,
- isDyn,
- type,
- binding,
- section,
- value,
- size,
- other);
+ LDSymbol* sym = m_pTestee->insertSymbol(
+ name, isDyn, type, binding, section, value, size, other);
ASSERT_EQ(sym, syms[i][j]);
}
}
diff --git a/unittests/NamePoolTest.h b/unittests/NamePoolTest.h
index 2e4a494..8c63dac 100644
--- a/unittests/NamePoolTest.h
+++ b/unittests/NamePoolTest.h
@@ -11,40 +11,36 @@
#include <gtest.h>
-namespace mcld
-{
+namespace mcld {
class NamePool;
-} // namespace for mcld
+} // namespace for mcld
-namespace mcldtest
-{
+namespace mcldtest {
/** \class NamePoolTest
* \brief
*
* \see NamePool
*/
-class NamePoolTest : public ::testing::Test
-{
-public:
- // Constructor can do set-up work for all test here.
- NamePoolTest();
+class NamePoolTest : public ::testing::Test {
+ public:
+ // Constructor can do set-up work for all test here.
+ NamePoolTest();
- // Destructor can do clean-up work that doesn't throw exceptions here.
- virtual ~NamePoolTest();
+ // Destructor can do clean-up work that doesn't throw exceptions here.
+ virtual ~NamePoolTest();
- // SetUp() will be called immediately before each test.
- virtual void SetUp();
+ // SetUp() will be called immediately before each test.
+ virtual void SetUp();
- // TearDown() will be called immediately after each test.
- virtual void TearDown();
+ // TearDown() will be called immediately after each test.
+ virtual void TearDown();
-protected:
- mcld::NamePool* m_pTestee;
+ protected:
+ mcld::NamePool* m_pTestee;
};
-} // namespace of mcldtest
+} // namespace of mcldtest
#endif
-
diff --git a/unittests/PathSetTest.cpp b/unittests/PathSetTest.cpp
index d735e9c..b5f7b21 100644
--- a/unittests/PathSetTest.cpp
+++ b/unittests/PathSetTest.cpp
@@ -12,34 +12,28 @@
using namespace mcld;
using namespace mcldtest;
-
// Constructor can do set-up work for all test here.
-PathSetTest::PathSetTest()
-{
- // create testee. modify it if need
- m_pTestee = new PathSet();
+PathSetTest::PathSetTest() {
+ // create testee. modify it if need
+ m_pTestee = new PathSet();
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-PathSetTest::~PathSetTest()
-{
- delete m_pTestee;
+PathSetTest::~PathSetTest() {
+ delete m_pTestee;
}
// SetUp() will be called immediately before each test.
-void PathSetTest::SetUp()
-{
+void PathSetTest::SetUp() {
}
// TearDown() will be called immediately after each test.
-void PathSetTest::TearDown()
-{
+void PathSetTest::TearDown() {
}
//==========================================================================//
// Testcases
//
-TEST_F( PathSetTest, ) {
+TEST_F(PathSetTest, ) {
}
-
diff --git a/unittests/PathSetTest.h b/unittests/PathSetTest.h
index 23a2dbf..aee9758 100644
--- a/unittests/PathSetTest.h
+++ b/unittests/PathSetTest.h
@@ -11,40 +11,36 @@
#include <gtest.h>
-namespace mcld
-{
+namespace mcld {
class PathSet;
-} // namespace for mcld
+} // namespace for mcld
-namespace mcldtest
-{
+namespace mcldtest {
/** \class PathSetTest
* \brief The testcase of PathSet
*
* \see PathSet
*/
-class PathSetTest : public ::testing::Test
-{
-public:
- // Constructor can do set-up work for all test here.
- PathSetTest();
+class PathSetTest : public ::testing::Test {
+ public:
+ // Constructor can do set-up work for all test here.
+ PathSetTest();
- // Destructor can do clean-up work that doesn't throw exceptions here.
- virtual ~PathSetTest();
+ // Destructor can do clean-up work that doesn't throw exceptions here.
+ virtual ~PathSetTest();
- // SetUp() will be called immediately before each test.
- virtual void SetUp();
+ // SetUp() will be called immediately before each test.
+ virtual void SetUp();
- // TearDown() will be called immediately after each test.
- virtual void TearDown();
+ // TearDown() will be called immediately after each test.
+ virtual void TearDown();
-protected:
- mcld::PathSet* m_pTestee;
+ protected:
+ mcld::PathSet* m_pTestee;
};
-} // namespace of mcldtest
+} // namespace of mcldtest
#endif
-
diff --git a/unittests/PathTest.cpp b/unittests/PathTest.cpp
index 73e62cc..b22788e 100644
--- a/unittests/PathTest.cpp
+++ b/unittests/PathTest.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
#include "PathTest.h"
-#include <mcld/Support/FileSystem.h>
+#include "mcld/Support/FileSystem.h"
#include <string>
//
@@ -15,34 +15,29 @@ using namespace mcld;
using namespace mcld::sys::fs;
using namespace mcldtest;
-
// Constructor can do set-up work for all test here.
-PathTest::PathTest()
-{
- // create testee. modify it if need
- m_pTestee = new Path();
+PathTest::PathTest() {
+ // create testee. modify it if need
+ m_pTestee = new Path();
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-PathTest::~PathTest()
-{
- delete m_pTestee;
+PathTest::~PathTest() {
+ delete m_pTestee;
}
// SetUp() will be called immediately before each test.
-void PathTest::SetUp()
-{
+void PathTest::SetUp() {
}
// TearDown() will be called immediately after each test.
-void PathTest::TearDown()
-{
+void PathTest::TearDown() {
}
//==========================================================================//
// Testcases
//
-TEST_F( PathTest, should_exist ) {
+TEST_F(PathTest, should_exist) {
std::string root(TOPDIR);
root += "/test/lit.cfg";
m_pTestee->assign(root);
@@ -53,7 +48,7 @@ TEST_F( PathTest, should_exist ) {
EXPECT_TRUE(exists(*m_pTestee));
}
-TEST_F( PathTest, should_not_exist ) {
+TEST_F(PathTest, should_not_exist) {
const std::string root = "/luck";
m_pTestee->assign(root);
EXPECT_FALSE(exists(*m_pTestee));
@@ -63,7 +58,7 @@ TEST_F( PathTest, should_not_exist ) {
EXPECT_FALSE(exists(*m_pTestee));
}
-TEST_F( PathTest, should_is_directory ) {
+TEST_F(PathTest, should_is_directory) {
const std::string root = "../././..";
m_pTestee->assign(root);
EXPECT_TRUE(exists(*m_pTestee));
@@ -74,7 +69,7 @@ TEST_F( PathTest, should_is_directory ) {
EXPECT_TRUE(is_directory(*m_pTestee));
}
-TEST_F( PathTest, should_not_is_directory ) {
+TEST_F(PathTest, should_not_is_directory) {
const std::string root = "/luck";
m_pTestee->assign(root);
EXPECT_FALSE(exists(*m_pTestee));
@@ -85,60 +80,59 @@ TEST_F( PathTest, should_not_is_directory ) {
EXPECT_FALSE(is_directory(*m_pTestee));
}
-TEST_F( PathTest, should_equal ) {
+TEST_F(PathTest, should_equal) {
const std::string root = "aaa/bbb/../../ccc/";
m_pTestee->assign(root);
Path* p2 = new Path("ccc///////");
- EXPECT_TRUE(*m_pTestee==*p2);
+ EXPECT_TRUE(*m_pTestee == *p2);
delete m_pTestee;
m_pTestee = new Path(root);
- EXPECT_TRUE(*m_pTestee==*m_pTestee);
+ EXPECT_TRUE(*m_pTestee == *m_pTestee);
delete p2;
}
-TEST_F( PathTest, should_not_equal ) {
+TEST_F(PathTest, should_not_equal) {
const std::string root = "aa/";
- Path* p2=new Path("aaa//");
-// p2->assign(root);
+ Path* p2 = new Path("aaa//");
+ // p2->assign(root);
m_pTestee->assign(root);
- EXPECT_TRUE(*m_pTestee!=*p2);
+ EXPECT_TRUE(*m_pTestee != *p2);
delete m_pTestee;
m_pTestee = new Path(root);
- EXPECT_TRUE(*m_pTestee!=*p2);
+ EXPECT_TRUE(*m_pTestee != *p2);
delete p2;
}
-TEST_F( PathTest, append_success ) {
-
+TEST_F(PathTest, append_success) {
const std::string root = "aa/";
m_pTestee->assign(root);
m_pTestee->append("aaa");
std::string a("aa/aaa");
- EXPECT_TRUE(m_pTestee->native()=="aa/aaa");
+ EXPECT_TRUE(m_pTestee->native() == "aa/aaa");
delete m_pTestee;
m_pTestee = new Path("aa/");
m_pTestee->append("/aaa");
- EXPECT_TRUE(m_pTestee->native()=="aa/aaa");
+ EXPECT_TRUE(m_pTestee->native() == "aa/aaa");
delete m_pTestee;
m_pTestee = new Path("aa");
m_pTestee->append("/aaa");
- EXPECT_TRUE(m_pTestee->native()=="aa/aaa");
+ EXPECT_TRUE(m_pTestee->native() == "aa/aaa");
delete m_pTestee;
m_pTestee = new Path("aa");
m_pTestee->append("aaa");
- EXPECT_TRUE(m_pTestee->native()=="aa/aaa");
+ EXPECT_TRUE(m_pTestee->native() == "aa/aaa");
}
-TEST_F( PathTest, should_become_generic_string ) {
+TEST_F(PathTest, should_become_generic_string) {
m_pTestee->assign("/etc/../dev/../usr//lib//");
EXPECT_STREQ("/usr/lib/", m_pTestee->generic_string().c_str());
}
-TEST_F( PathTest, parent_path ) {
+TEST_F(PathTest, parent_path) {
m_pTestee->assign("aa/bb/cc/dd");
EXPECT_STREQ("aa/bb/cc", m_pTestee->parent_path().c_str());
delete m_pTestee;
diff --git a/unittests/PathTest.h b/unittests/PathTest.h
index 417a07f..a31b16a 100644
--- a/unittests/PathTest.h
+++ b/unittests/PathTest.h
@@ -12,34 +12,31 @@
#include "mcld/Support/Path.h"
#include <gtest.h>
-namespace mcldtest
-{
+namespace mcldtest {
/** \class PathTest
* \brief a testcase for mcld::Path and its non-member funtions.
*
* \see Path
*/
-class PathTest : public ::testing::Test
-{
-public:
- // Constructor can do set-up work for all test here.
- PathTest();
+class PathTest : public ::testing::Test {
+ public:
+ // Constructor can do set-up work for all test here.
+ PathTest();
- // Destructor can do clean-up work that doesn't throw exceptions here.
- virtual ~PathTest();
+ // Destructor can do clean-up work that doesn't throw exceptions here.
+ virtual ~PathTest();
- // SetUp() will be called immediately before each test.
- virtual void SetUp();
+ // SetUp() will be called immediately before each test.
+ virtual void SetUp();
- // TearDown() will be called immediately after each test.
- virtual void TearDown();
+ // TearDown() will be called immediately after each test.
+ virtual void TearDown();
-protected:
- mcld::sys::fs::Path* m_pTestee;
+ protected:
+ mcld::sys::fs::Path* m_pTestee;
};
-} // namespace of mcldtest
+} // namespace of mcldtest
#endif
-
diff --git a/unittests/RTLinearAllocatorTest.cpp b/unittests/RTLinearAllocatorTest.cpp
index 1e07f4a..1350c50 100644
--- a/unittests/RTLinearAllocatorTest.cpp
+++ b/unittests/RTLinearAllocatorTest.cpp
@@ -6,34 +6,29 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#include <mcld/Support/Allocators.h>
+#include "mcld/Support/Allocators.h"
#include "RTLinearAllocatorTest.h"
using namespace mcld;
using namespace mcldtest;
-
// Constructor can do set-up work for all test here.
-RTLinearAllocatorTest::RTLinearAllocatorTest()
-{
- // create testee. modify it if need
- m_pTestee = new LinearAllocator<Data, 0>(CHUNK_SIZE);
+RTLinearAllocatorTest::RTLinearAllocatorTest() {
+ // create testee. modify it if need
+ m_pTestee = new LinearAllocator<Data, 0>(CHUNK_SIZE);
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-RTLinearAllocatorTest::~RTLinearAllocatorTest()
-{
- delete m_pTestee;
+RTLinearAllocatorTest::~RTLinearAllocatorTest() {
+ delete m_pTestee;
}
// SetUp() will be called immediately before each test.
-void RTLinearAllocatorTest::SetUp()
-{
+void RTLinearAllocatorTest::SetUp() {
}
// TearDown() will be called immediately after each test.
-void RTLinearAllocatorTest::TearDown()
-{
+void RTLinearAllocatorTest::TearDown() {
}
//==========================================================================//
@@ -41,100 +36,99 @@ void RTLinearAllocatorTest::TearDown()
//
TEST_F(RTLinearAllocatorTest, AllocateN) {
- Data* pointer = m_pTestee->allocate(10);
- ASSERT_FALSE(0 == pointer);
- ASSERT_TRUE(CHUNK_SIZE == m_pTestee->max_size());
- ASSERT_FALSE(m_pTestee->empty());
+ Data* pointer = m_pTestee->allocate(10);
+ ASSERT_FALSE(0 == pointer);
+ ASSERT_TRUE(CHUNK_SIZE == m_pTestee->max_size());
+ ASSERT_FALSE(m_pTestee->empty());
}
-TEST_F(RTLinearAllocatorTest, allocate ) {
- Data* pointer = m_pTestee->allocate();
- ASSERT_FALSE(0 == pointer);
- ASSERT_TRUE(CHUNK_SIZE == m_pTestee->max_size());
- ASSERT_FALSE(m_pTestee->empty());
+TEST_F(RTLinearAllocatorTest, allocate) {
+ Data* pointer = m_pTestee->allocate();
+ ASSERT_FALSE(0 == pointer);
+ ASSERT_TRUE(CHUNK_SIZE == m_pTestee->max_size());
+ ASSERT_FALSE(m_pTestee->empty());
}
-TEST_F(RTLinearAllocatorTest, allocateOver ) {
- Data* pointer = m_pTestee->allocate(CHUNK_SIZE+1);
- ASSERT_TRUE(0 == pointer);
- ASSERT_TRUE(0 == m_pTestee->max_size());
- ASSERT_TRUE(m_pTestee->empty());
+TEST_F(RTLinearAllocatorTest, allocateOver) {
+ Data* pointer = m_pTestee->allocate(CHUNK_SIZE + 1);
+ ASSERT_TRUE(0 == pointer);
+ ASSERT_TRUE(0 == m_pTestee->max_size());
+ ASSERT_TRUE(m_pTestee->empty());
}
-TEST_F(RTLinearAllocatorTest, alloc_construct ) {
- Data* pointer = m_pTestee->allocate();
- m_pTestee->construct(pointer);
- ASSERT_TRUE(1 == pointer->one);
- ASSERT_TRUE(2 == pointer->two);
- ASSERT_TRUE(3 == pointer->three);
- ASSERT_TRUE(4 == pointer->four);
+TEST_F(RTLinearAllocatorTest, alloc_construct) {
+ Data* pointer = m_pTestee->allocate();
+ m_pTestee->construct(pointer);
+ ASSERT_TRUE(1 == pointer->one);
+ ASSERT_TRUE(2 == pointer->two);
+ ASSERT_TRUE(3 == pointer->three);
+ ASSERT_TRUE(4 == pointer->four);
}
-TEST_F(RTLinearAllocatorTest, alloc_constructCopy ) {
- Data* pointer = m_pTestee->allocate();
- Data data(7, 7, 7, 7);
- m_pTestee->construct(pointer, data);
+TEST_F(RTLinearAllocatorTest, alloc_constructCopy) {
+ Data* pointer = m_pTestee->allocate();
+ Data data(7, 7, 7, 7);
+ m_pTestee->construct(pointer, data);
- ASSERT_TRUE(7 == pointer->one);
- ASSERT_TRUE(7 == pointer->two);
- ASSERT_TRUE(7 == pointer->three);
- ASSERT_TRUE(7 == pointer->four);
+ ASSERT_TRUE(7 == pointer->one);
+ ASSERT_TRUE(7 == pointer->two);
+ ASSERT_TRUE(7 == pointer->three);
+ ASSERT_TRUE(7 == pointer->four);
}
-TEST_F(RTLinearAllocatorTest, allocN_construct ) {
- Data* pointer = m_pTestee->allocate(10);
- m_pTestee->construct(pointer);
- ASSERT_TRUE(1 == pointer->one);
- ASSERT_TRUE(2 == pointer->two);
- ASSERT_TRUE(3 == pointer->three);
- ASSERT_TRUE(4 == pointer->four);
+TEST_F(RTLinearAllocatorTest, allocN_construct) {
+ Data* pointer = m_pTestee->allocate(10);
+ m_pTestee->construct(pointer);
+ ASSERT_TRUE(1 == pointer->one);
+ ASSERT_TRUE(2 == pointer->two);
+ ASSERT_TRUE(3 == pointer->three);
+ ASSERT_TRUE(4 == pointer->four);
}
-TEST_F(RTLinearAllocatorTest, allocN_constructCopy ) {
- Data* pointer = m_pTestee->allocate(10);
- Data data(7, 7, 7, 7);
- m_pTestee->construct(pointer, data);
-
- ASSERT_TRUE(7 == pointer->one);
- ASSERT_TRUE(7 == pointer->two);
- ASSERT_TRUE(7 == pointer->three);
- ASSERT_TRUE(7 == pointer->four);
-}
+TEST_F(RTLinearAllocatorTest, allocN_constructCopy) {
+ Data* pointer = m_pTestee->allocate(10);
+ Data data(7, 7, 7, 7);
+ m_pTestee->construct(pointer, data);
-TEST_F(RTLinearAllocatorTest, multi_alloc_ctor_iterate ) {
- for (int i=0; i<101; ++i) {
- Data* pointer = m_pTestee->allocate();
- m_pTestee->construct(pointer);
- pointer->one = i;
- }
-/**
- Alloc::iterator data, dEnd = m_pTestee->end();
- int counter = 0;
- for (data=m_pTestee->begin(); data!=dEnd; ++data) {
- ASSERT_EQ(counter, (*data).one);
- ++counter;
- }
-**/
+ ASSERT_TRUE(7 == pointer->one);
+ ASSERT_TRUE(7 == pointer->two);
+ ASSERT_TRUE(7 == pointer->three);
+ ASSERT_TRUE(7 == pointer->four);
}
-TEST_F(RTLinearAllocatorTest, multi_allocN_ctor_iterate ) {
- int counter = 0;
- for (int i=0; i<10000; ++i) {
- Data* pointer = m_pTestee->allocate(10);
- for (int j=0; j<10; ++j) {
- m_pTestee->construct(pointer);
- pointer->one = counter;
- ++pointer;
- ++counter;
- }
- }
-/**
- Alloc::iterator data, dEnd = m_pTestee->end();
- counter = 0;
- for (data=m_pTestee->begin(); data!=dEnd; ++data) {
- ASSERT_EQ(counter, (*data).one);
- ++counter;
- }
-**/
+TEST_F(RTLinearAllocatorTest, multi_alloc_ctor_iterate) {
+ for (int i = 0; i < 101; ++i) {
+ Data* pointer = m_pTestee->allocate();
+ m_pTestee->construct(pointer);
+ pointer->one = i;
+ }
+ /**
+ Alloc::iterator data, dEnd = m_pTestee->end();
+ int counter = 0;
+ for (data=m_pTestee->begin(); data!=dEnd; ++data) {
+ ASSERT_EQ(counter, (*data).one);
+ ++counter;
+ }
+ **/
}
+TEST_F(RTLinearAllocatorTest, multi_allocN_ctor_iterate) {
+ int counter = 0;
+ for (int i = 0; i < 10000; ++i) {
+ Data* pointer = m_pTestee->allocate(10);
+ for (int j = 0; j < 10; ++j) {
+ m_pTestee->construct(pointer);
+ pointer->one = counter;
+ ++pointer;
+ ++counter;
+ }
+ }
+ /**
+ Alloc::iterator data, dEnd = m_pTestee->end();
+ counter = 0;
+ for (data=m_pTestee->begin(); data!=dEnd; ++data) {
+ ASSERT_EQ(counter, (*data).one);
+ ++counter;
+ }
+ **/
+}
diff --git a/unittests/RTLinearAllocatorTest.h b/unittests/RTLinearAllocatorTest.h
index 3ba0cd9..2c4a732 100644
--- a/unittests/RTLinearAllocatorTest.h
+++ b/unittests/RTLinearAllocatorTest.h
@@ -12,63 +12,59 @@
#include <gtest.h>
#include "mcld/Support/Allocators.h"
-namespace mcldtest
-{
+namespace mcldtest {
/** \class RTLinearAllocatorTest
* \brief
*
* \see RTLinearAllocator
*/
-class RTLinearAllocatorTest : public ::testing::Test
-{
-public:
- // Constructor can do set-up work for all test here.
- RTLinearAllocatorTest();
+class RTLinearAllocatorTest : public ::testing::Test {
+ public:
+ // Constructor can do set-up work for all test here.
+ RTLinearAllocatorTest();
- // Destructor can do clean-up work that doesn't throw exceptions here.
- virtual ~RTLinearAllocatorTest();
+ // Destructor can do clean-up work that doesn't throw exceptions here.
+ virtual ~RTLinearAllocatorTest();
- // SetUp() will be called immediately before each test.
- virtual void SetUp();
+ // SetUp() will be called immediately before each test.
+ virtual void SetUp();
- // TearDown() will be called immediately after each test.
- virtual void TearDown();
+ // TearDown() will be called immediately after each test.
+ virtual void TearDown();
-public:
- struct Data {
- Data()
- : one(1), two(2), three(3), four(4)
- { }
+ public:
+ struct Data {
+ Data() : one(1), two(2), three(3), four(4) {}
- Data( unsigned int pOne, unsigned int pTwo, unsigned char pThree, unsigned char pFour)
- {
- one = pOne;
- two = pTwo;
- three = pThree;
- four = pFour;
- }
+ Data(unsigned int pOne,
+ unsigned int pTwo,
+ unsigned char pThree,
+ unsigned char pFour) {
+ one = pOne;
+ two = pTwo;
+ three = pThree;
+ four = pFour;
+ }
- ~Data()
- {
- one = -1;
- two = -2;
- three = -3;
- four = -4;
- }
+ ~Data() {
+ one = -1;
+ two = -2;
+ three = -3;
+ four = -4;
+ }
- unsigned int one;
- unsigned int two;
- unsigned char three;
- unsigned char four;
+ unsigned int one;
+ unsigned int two;
+ unsigned char three;
+ unsigned char four;
};
- enum { CHUNK_SIZE = 32 };
+ enum { CHUNK_SIZE = 32 };
-protected:
- mcld::LinearAllocator<Data,0>* m_pTestee;
+ protected:
+ mcld::LinearAllocator<Data, 0>* m_pTestee;
};
-} // namespace of mcldtest
+} // namespace of mcldtest
#endif
-
diff --git a/unittests/SectionDataTest.cpp b/unittests/SectionDataTest.cpp
index 6a7e366..e9a9292 100644
--- a/unittests/SectionDataTest.cpp
+++ b/unittests/SectionDataTest.cpp
@@ -8,50 +8,44 @@
//===----------------------------------------------------------------------===//
#include "SectionDataTest.h"
-#include <mcld/LD/SectionData.h>
-#include <mcld/LD/LDFileFormat.h>
-#include <mcld/LD/LDSection.h>
+#include "mcld/LD/SectionData.h"
+#include "mcld/LD/LDFileFormat.h"
+#include "mcld/LD/LDSection.h"
using namespace mcld;
using namespace mcldtest;
-
// Constructor can do set-up work for all test here.
-SectionDataTest::SectionDataTest()
-{
+SectionDataTest::SectionDataTest() {
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-SectionDataTest::~SectionDataTest()
-{
+SectionDataTest::~SectionDataTest() {
}
// SetUp() will be called immediately before each test.
-void SectionDataTest::SetUp()
-{
+void SectionDataTest::SetUp() {
}
// TearDown() will be called immediately after each test.
-void SectionDataTest::TearDown()
-{
+void SectionDataTest::TearDown() {
}
//===----------------------------------------------------------------------===//
// Testcases
//===----------------------------------------------------------------------===//
-TEST_F( SectionDataTest, constructor_and_trivial_func ) {
+TEST_F(SectionDataTest, constructor_and_trivial_func) {
LDSection* test = LDSection::Create("test", LDFileFormat::Null, 0, 0);
SectionData* s = SectionData::Create(*test);
- EXPECT_TRUE(s->getSection().name() == "test" && \
+ EXPECT_TRUE(s->getSection().name() == "test" &&
s->getSection().kind() == LDFileFormat::Null);
-
LDSection::Destroy(test);
}
-TEST_F( SectionDataTest, Fragment_list_and_iterator ) {
+TEST_F(SectionDataTest, Fragment_list_and_iterator) {
LDSection* test = LDSection::Create("test", LDFileFormat::Null, 0, 0);
SectionData* s = SectionData::Create(*test);
EXPECT_TRUE(s->empty());
@@ -63,8 +57,8 @@ TEST_F( SectionDataTest, Fragment_list_and_iterator ) {
new Fragment(Fragment::Target, s);
EXPECT_TRUE(5 == s->size());
- //iterator
- llvm::iplist<Fragment>::iterator iter=s->begin();
+ // iterator
+ llvm::iplist<Fragment>::iterator iter = s->begin();
EXPECT_TRUE(Fragment::Alignment == iter->getKind());
++iter;
EXPECT_TRUE(Fragment::Alignment == iter->getKind());
diff --git a/unittests/SectionDataTest.h b/unittests/SectionDataTest.h
index bbc2736..6717f5e 100644
--- a/unittests/SectionDataTest.h
+++ b/unittests/SectionDataTest.h
@@ -13,14 +13,12 @@
namespace mcld {
class SectionData;
-} // namespace for mcld
+} // namespace for mcld
-namespace mcldtest
-{
+namespace mcldtest {
-class SectionDataTest : public ::testing::Test
-{
-public:
+class SectionDataTest : public ::testing::Test {
+ public:
// Constructor can do set-up work for all test here.
SectionDataTest();
@@ -34,7 +32,6 @@ public:
virtual void TearDown();
};
-} // namespace of mcldtest
+} // namespace of mcldtest
#endif
-
diff --git a/unittests/StaticResolverTest.cpp b/unittests/StaticResolverTest.cpp
index a474cdd..75fb34c 100644
--- a/unittests/StaticResolverTest.cpp
+++ b/unittests/StaticResolverTest.cpp
@@ -7,12 +7,12 @@
//
//===----------------------------------------------------------------------===//
#include "StaticResolverTest.h"
-#include <mcld/Support/TargetSelect.h>
-#include <mcld/LD/StaticResolver.h>
-#include <mcld/LD/ResolveInfo.h>
-#include <mcld/LinkerConfig.h>
+#include "mcld/Support/TargetSelect.h"
+#include "mcld/LD/StaticResolver.h"
+#include "mcld/LD/ResolveInfo.h"
+#include "mcld/LinkerConfig.h"
-#include <mcld/Support/FileSystem.h>
+#include "mcld/Support/FileSystem.h"
using namespace mcld;
using namespace mcldtest;
@@ -21,8 +21,7 @@ using namespace mcldtest;
// StaticResolverTest
//===----------------------------------------------------------------------===//
// Constructor can do set-up work for all test here.
-StaticResolverTest::StaticResolverTest()
- : m_pResolver(NULL), m_pConfig(NULL) {
+StaticResolverTest::StaticResolverTest() : m_pResolver(NULL), m_pConfig(NULL) {
// create testee. modify it if need
m_pResolver = new StaticResolver();
@@ -30,41 +29,38 @@ StaticResolverTest::StaticResolverTest()
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-StaticResolverTest::~StaticResolverTest()
-{
+StaticResolverTest::~StaticResolverTest() {
delete m_pResolver;
delete m_pConfig;
}
// SetUp() will be called immediately before each test.
-void StaticResolverTest::SetUp()
-{
+void StaticResolverTest::SetUp() {
}
// TearDown() will be called immediately after each test.
-void StaticResolverTest::TearDown()
-{
+void StaticResolverTest::TearDown() {
}
//==========================================================================//
// Testcases
//
-TEST_F( StaticResolverTest, MDEF ) {
+TEST_F(StaticResolverTest, MDEF) {
ResolveInfo* old_sym = ResolveInfo::Create("abc");
ResolveInfo* new_sym = ResolveInfo::Create("abc");
new_sym->setDesc(ResolveInfo::Define);
old_sym->setDesc(ResolveInfo::Define);
- ASSERT_TRUE( mcld::ResolveInfo::Define == new_sym->desc());
- ASSERT_TRUE( mcld::ResolveInfo::Define == old_sym->desc());
- ASSERT_TRUE( mcld::ResolveInfo::define_flag == new_sym->info());
- ASSERT_TRUE( mcld::ResolveInfo::define_flag == old_sym->info());
+ ASSERT_TRUE(mcld::ResolveInfo::Define == new_sym->desc());
+ ASSERT_TRUE(mcld::ResolveInfo::Define == old_sym->desc());
+ ASSERT_TRUE(mcld::ResolveInfo::define_flag == new_sym->info());
+ ASSERT_TRUE(mcld::ResolveInfo::define_flag == old_sym->info());
bool override = true;
bool result = m_pResolver->resolve(*old_sym, *new_sym, override, 0x0);
ASSERT_TRUE(result);
- ASSERT_FALSE( override );
+ ASSERT_FALSE(override);
}
-TEST_F( StaticResolverTest, DynDefAfterDynUndef ) {
+TEST_F(StaticResolverTest, DynDefAfterDynUndef) {
ResolveInfo* old_sym = ResolveInfo::Create("abc");
ResolveInfo* new_sym = ResolveInfo::Create("abc");
@@ -79,19 +75,19 @@ TEST_F( StaticResolverTest, DynDefAfterDynUndef ) {
old_sym->setSize(1);
- ASSERT_TRUE( mcld::ResolveInfo::Global == new_sym->binding());
- ASSERT_TRUE( mcld::ResolveInfo::Global == old_sym->binding());
- ASSERT_TRUE( mcld::ResolveInfo::Undefined == new_sym->desc());
- ASSERT_TRUE( mcld::ResolveInfo::Define == old_sym->desc());
+ ASSERT_TRUE(mcld::ResolveInfo::Global == new_sym->binding());
+ ASSERT_TRUE(mcld::ResolveInfo::Global == old_sym->binding());
+ ASSERT_TRUE(mcld::ResolveInfo::Undefined == new_sym->desc());
+ ASSERT_TRUE(mcld::ResolveInfo::Define == old_sym->desc());
bool override = false;
bool result = m_pResolver->resolve(*old_sym, *new_sym, override, 0x0);
ASSERT_TRUE(result);
- ASSERT_FALSE( override );
+ ASSERT_FALSE(override);
ASSERT_TRUE(1 == old_sym->size());
}
-TEST_F( StaticResolverTest, DynDefAfterDynDef ) {
+TEST_F(StaticResolverTest, DynDefAfterDynDef) {
ResolveInfo* old_sym = ResolveInfo::Create("abc");
ResolveInfo* new_sym = ResolveInfo::Create("abc");
@@ -106,19 +102,19 @@ TEST_F( StaticResolverTest, DynDefAfterDynDef ) {
old_sym->setSize(1);
- ASSERT_TRUE( mcld::ResolveInfo::Global == new_sym->binding());
- ASSERT_TRUE( mcld::ResolveInfo::Global == old_sym->binding());
- ASSERT_TRUE( mcld::ResolveInfo::Define == new_sym->desc());
- ASSERT_TRUE( mcld::ResolveInfo::Define == old_sym->desc());
+ ASSERT_TRUE(mcld::ResolveInfo::Global == new_sym->binding());
+ ASSERT_TRUE(mcld::ResolveInfo::Global == old_sym->binding());
+ ASSERT_TRUE(mcld::ResolveInfo::Define == new_sym->desc());
+ ASSERT_TRUE(mcld::ResolveInfo::Define == old_sym->desc());
bool override = false;
bool result = m_pResolver->resolve(*old_sym, *new_sym, override, 0x0);
ASSERT_TRUE(result);
- ASSERT_FALSE( override );
+ ASSERT_FALSE(override);
ASSERT_TRUE(1 == old_sym->size());
}
-TEST_F( StaticResolverTest, DynUndefAfterDynUndef ) {
+TEST_F(StaticResolverTest, DynUndefAfterDynUndef) {
ResolveInfo* old_sym = ResolveInfo::Create("abc");
ResolveInfo* new_sym = ResolveInfo::Create("abc");
@@ -133,20 +129,19 @@ TEST_F( StaticResolverTest, DynUndefAfterDynUndef ) {
old_sym->setSize(1);
- ASSERT_TRUE( mcld::ResolveInfo::Global == new_sym->binding());
- ASSERT_TRUE( mcld::ResolveInfo::Global == old_sym->binding());
- ASSERT_TRUE( mcld::ResolveInfo::Undefined == new_sym->desc());
- ASSERT_TRUE( mcld::ResolveInfo::Undefined == old_sym->desc());
+ ASSERT_TRUE(mcld::ResolveInfo::Global == new_sym->binding());
+ ASSERT_TRUE(mcld::ResolveInfo::Global == old_sym->binding());
+ ASSERT_TRUE(mcld::ResolveInfo::Undefined == new_sym->desc());
+ ASSERT_TRUE(mcld::ResolveInfo::Undefined == old_sym->desc());
bool override = false;
bool result = m_pResolver->resolve(*old_sym, *new_sym, override, 0x0);
ASSERT_TRUE(result);
- ASSERT_FALSE( override );
+ ASSERT_FALSE(override);
ASSERT_TRUE(1 == old_sym->size());
}
-TEST_F( StaticResolverTest, OverrideWeakByGlobal )
-{
+TEST_F(StaticResolverTest, OverrideWeakByGlobal) {
ResolveInfo* old_sym = ResolveInfo::Create("abc");
ResolveInfo* new_sym = ResolveInfo::Create("abc");
@@ -155,19 +150,19 @@ TEST_F( StaticResolverTest, OverrideWeakByGlobal )
new_sym->setSize(0);
old_sym->setSize(1);
- ASSERT_TRUE( mcld::ResolveInfo::Global == new_sym->binding());
- ASSERT_TRUE( mcld::ResolveInfo::Weak == old_sym->binding());
+ ASSERT_TRUE(mcld::ResolveInfo::Global == new_sym->binding());
+ ASSERT_TRUE(mcld::ResolveInfo::Weak == old_sym->binding());
- ASSERT_TRUE( mcld::ResolveInfo::global_flag == new_sym->info());
- ASSERT_TRUE( mcld::ResolveInfo::weak_flag == old_sym->info());
+ ASSERT_TRUE(mcld::ResolveInfo::global_flag == new_sym->info());
+ ASSERT_TRUE(mcld::ResolveInfo::weak_flag == old_sym->info());
bool override = false;
bool result = m_pResolver->resolve(*old_sym, *new_sym, override, 0x0);
ASSERT_TRUE(result);
- ASSERT_TRUE( override );
+ ASSERT_TRUE(override);
ASSERT_TRUE(0 == old_sym->size());
}
-TEST_F( StaticResolverTest, DynWeakAfterDynDef ) {
+TEST_F(StaticResolverTest, DynWeakAfterDynDef) {
ResolveInfo* old_sym = ResolveInfo::Create("abc");
ResolveInfo* new_sym = ResolveInfo::Create("abc");
@@ -184,20 +179,19 @@ TEST_F( StaticResolverTest, DynWeakAfterDynDef ) {
old_sym->setSize(1);
- ASSERT_TRUE( mcld::ResolveInfo::Weak == old_sym->binding());
- ASSERT_TRUE( mcld::ResolveInfo::Global == new_sym->binding());
- ASSERT_TRUE( mcld::ResolveInfo::Define == old_sym->desc());
- ASSERT_TRUE( mcld::ResolveInfo::Define == new_sym->desc());
+ ASSERT_TRUE(mcld::ResolveInfo::Weak == old_sym->binding());
+ ASSERT_TRUE(mcld::ResolveInfo::Global == new_sym->binding());
+ ASSERT_TRUE(mcld::ResolveInfo::Define == old_sym->desc());
+ ASSERT_TRUE(mcld::ResolveInfo::Define == new_sym->desc());
bool override = false;
bool result = m_pResolver->resolve(*old_sym, *new_sym, override, 0x0);
ASSERT_TRUE(result);
- ASSERT_FALSE( override );
+ ASSERT_FALSE(override);
ASSERT_TRUE(1 == old_sym->size());
}
-TEST_F( StaticResolverTest, MarkByBiggerCommon )
-{
+TEST_F(StaticResolverTest, MarkByBiggerCommon) {
ResolveInfo* old_sym = ResolveInfo::Create("abc");
ResolveInfo* new_sym = ResolveInfo::Create("abc");
@@ -206,20 +200,19 @@ TEST_F( StaticResolverTest, MarkByBiggerCommon )
new_sym->setSize(999);
old_sym->setSize(0);
- ASSERT_TRUE( mcld::ResolveInfo::Common == new_sym->desc());
- ASSERT_TRUE( mcld::ResolveInfo::Common == old_sym->desc());
+ ASSERT_TRUE(mcld::ResolveInfo::Common == new_sym->desc());
+ ASSERT_TRUE(mcld::ResolveInfo::Common == old_sym->desc());
- ASSERT_TRUE( mcld::ResolveInfo::common_flag == new_sym->info());
- ASSERT_TRUE( mcld::ResolveInfo::common_flag == old_sym->info());
+ ASSERT_TRUE(mcld::ResolveInfo::common_flag == new_sym->info());
+ ASSERT_TRUE(mcld::ResolveInfo::common_flag == old_sym->info());
bool override = true;
bool result = m_pResolver->resolve(*old_sym, *new_sym, override, 0x0);
ASSERT_TRUE(result);
- ASSERT_FALSE( override );
+ ASSERT_FALSE(override);
ASSERT_TRUE(999 == old_sym->size());
}
-TEST_F( StaticResolverTest, OverrideByBiggerCommon )
-{
+TEST_F(StaticResolverTest, OverrideByBiggerCommon) {
ResolveInfo* old_sym = ResolveInfo::Create("abc");
ResolveInfo* new_sym = ResolveInfo::Create("abc");
@@ -229,22 +222,22 @@ TEST_F( StaticResolverTest, OverrideByBiggerCommon )
new_sym->setSize(999);
old_sym->setSize(0);
- ASSERT_TRUE( ResolveInfo::Common == new_sym->desc());
- ASSERT_TRUE( ResolveInfo::Common == old_sym->desc());
- ASSERT_TRUE( ResolveInfo::Weak == old_sym->binding());
+ ASSERT_TRUE(ResolveInfo::Common == new_sym->desc());
+ ASSERT_TRUE(ResolveInfo::Common == old_sym->desc());
+ ASSERT_TRUE(ResolveInfo::Weak == old_sym->binding());
- ASSERT_TRUE( ResolveInfo::common_flag == new_sym->info());
- ASSERT_TRUE( (ResolveInfo::weak_flag | ResolveInfo::common_flag) == old_sym->info());
+ ASSERT_TRUE(ResolveInfo::common_flag == new_sym->info());
+ ASSERT_TRUE((ResolveInfo::weak_flag | ResolveInfo::common_flag) ==
+ old_sym->info());
bool override = false;
bool result = m_pResolver->resolve(*old_sym, *new_sym, override, 0x0);
ASSERT_TRUE(result);
- ASSERT_TRUE( override );
+ ASSERT_TRUE(override);
ASSERT_TRUE(999 == old_sym->size());
}
-TEST_F( StaticResolverTest, OverrideCommonByDefine)
-{
+TEST_F(StaticResolverTest, OverrideCommonByDefine) {
ResolveInfo* old_sym = ResolveInfo::Create("abc");
ResolveInfo* new_sym = ResolveInfo::Create("abc");
@@ -254,183 +247,180 @@ TEST_F( StaticResolverTest, OverrideCommonByDefine)
new_sym->setDesc(ResolveInfo::Define);
new_sym->setSize(999);
- ASSERT_TRUE( ResolveInfo::Define == new_sym->desc());
- ASSERT_TRUE( ResolveInfo::Common == old_sym->desc());
+ ASSERT_TRUE(ResolveInfo::Define == new_sym->desc());
+ ASSERT_TRUE(ResolveInfo::Common == old_sym->desc());
- ASSERT_TRUE( ResolveInfo::define_flag == new_sym->info());
- ASSERT_TRUE( ResolveInfo::common_flag == old_sym->info());
+ ASSERT_TRUE(ResolveInfo::define_flag == new_sym->info());
+ ASSERT_TRUE(ResolveInfo::common_flag == old_sym->info());
bool override = false;
bool result = m_pResolver->resolve(*old_sym, *new_sym, override, 0x0);
ASSERT_TRUE(result);
- ASSERT_TRUE( override );
+ ASSERT_TRUE(override);
ASSERT_TRUE(999 == old_sym->size());
}
-TEST_F( StaticResolverTest, SetUpDesc)
-{
+TEST_F(StaticResolverTest, SetUpDesc) {
ResolveInfo* sym = ResolveInfo::Create("abc");
sym->setIsSymbol(true);
-// ASSERT_FALSE( sym->isSymbol() );
- ASSERT_TRUE( sym->isSymbol() );
- ASSERT_TRUE( sym->isGlobal() );
- ASSERT_FALSE( sym->isWeak() );
- ASSERT_FALSE( sym->isLocal() );
- ASSERT_FALSE( sym->isDefine() );
- ASSERT_TRUE( sym->isUndef() );
- ASSERT_FALSE( sym->isDyn() );
- ASSERT_FALSE( sym->isCommon() );
- ASSERT_FALSE( sym->isIndirect() );
- ASSERT_TRUE( ResolveInfo::NoType == sym->type());
- ASSERT_TRUE( 0 == sym->desc() );
- ASSERT_TRUE( 0 == sym->binding() );
- ASSERT_TRUE( 0 == sym->other() );
+ // ASSERT_FALSE( sym->isSymbol() );
+ ASSERT_TRUE(sym->isSymbol());
+ ASSERT_TRUE(sym->isGlobal());
+ ASSERT_FALSE(sym->isWeak());
+ ASSERT_FALSE(sym->isLocal());
+ ASSERT_FALSE(sym->isDefine());
+ ASSERT_TRUE(sym->isUndef());
+ ASSERT_FALSE(sym->isDyn());
+ ASSERT_FALSE(sym->isCommon());
+ ASSERT_FALSE(sym->isIndirect());
+ ASSERT_TRUE(ResolveInfo::NoType == sym->type());
+ ASSERT_TRUE(0 == sym->desc());
+ ASSERT_TRUE(0 == sym->binding());
+ ASSERT_TRUE(0 == sym->other());
sym->setIsSymbol(false);
- ASSERT_FALSE( sym->isSymbol() );
-// ASSERT_TRUE( sym->isSymbol() );
- ASSERT_TRUE( sym->isGlobal() );
- ASSERT_FALSE( sym->isWeak() );
- ASSERT_FALSE( sym->isLocal() );
- ASSERT_FALSE( sym->isDefine() );
- ASSERT_TRUE( sym->isUndef() );
- ASSERT_FALSE( sym->isDyn() );
- ASSERT_FALSE( sym->isCommon() );
- ASSERT_FALSE( sym->isIndirect() );
- ASSERT_TRUE( ResolveInfo::NoType == sym->type());
- ASSERT_TRUE( 0 == sym->desc() );
- ASSERT_TRUE( 0 == sym->binding() );
- ASSERT_TRUE( 0 == sym->other() );
+ ASSERT_FALSE(sym->isSymbol());
+ // ASSERT_TRUE( sym->isSymbol() );
+ ASSERT_TRUE(sym->isGlobal());
+ ASSERT_FALSE(sym->isWeak());
+ ASSERT_FALSE(sym->isLocal());
+ ASSERT_FALSE(sym->isDefine());
+ ASSERT_TRUE(sym->isUndef());
+ ASSERT_FALSE(sym->isDyn());
+ ASSERT_FALSE(sym->isCommon());
+ ASSERT_FALSE(sym->isIndirect());
+ ASSERT_TRUE(ResolveInfo::NoType == sym->type());
+ ASSERT_TRUE(0 == sym->desc());
+ ASSERT_TRUE(0 == sym->binding());
+ ASSERT_TRUE(0 == sym->other());
sym->setDesc(ResolveInfo::Define);
- ASSERT_FALSE( sym->isSymbol() );
-// ASSERT_TRUE( sym->isSymbol() );
- ASSERT_TRUE( sym->isGlobal() );
- ASSERT_FALSE( sym->isWeak() );
- ASSERT_FALSE( sym->isLocal() );
- ASSERT_TRUE( sym->isDefine() );
- ASSERT_FALSE( sym->isUndef() );
- ASSERT_FALSE( sym->isDyn() );
- ASSERT_FALSE( sym->isCommon() );
- ASSERT_FALSE( sym->isIndirect() );
- ASSERT_TRUE( ResolveInfo::NoType == sym->type());
- ASSERT_TRUE( ResolveInfo::Define == sym->desc() );
- ASSERT_TRUE( 0 == sym->binding() );
- ASSERT_TRUE( 0 == sym->other() );
+ ASSERT_FALSE(sym->isSymbol());
+ // ASSERT_TRUE( sym->isSymbol() );
+ ASSERT_TRUE(sym->isGlobal());
+ ASSERT_FALSE(sym->isWeak());
+ ASSERT_FALSE(sym->isLocal());
+ ASSERT_TRUE(sym->isDefine());
+ ASSERT_FALSE(sym->isUndef());
+ ASSERT_FALSE(sym->isDyn());
+ ASSERT_FALSE(sym->isCommon());
+ ASSERT_FALSE(sym->isIndirect());
+ ASSERT_TRUE(ResolveInfo::NoType == sym->type());
+ ASSERT_TRUE(ResolveInfo::Define == sym->desc());
+ ASSERT_TRUE(0 == sym->binding());
+ ASSERT_TRUE(0 == sym->other());
sym->setDesc(ResolveInfo::Common);
- ASSERT_FALSE( sym->isSymbol() );
-// ASSERT_TRUE( sym->isSymbol() );
- ASSERT_TRUE( sym->isGlobal() );
- ASSERT_FALSE( sym->isWeak() );
- ASSERT_FALSE( sym->isLocal() );
- ASSERT_FALSE( sym->isDyn() );
- ASSERT_FALSE( sym->isDefine() );
- ASSERT_FALSE( sym->isUndef() );
- ASSERT_TRUE( sym->isCommon() );
- ASSERT_FALSE( sym->isIndirect() );
- ASSERT_TRUE( ResolveInfo::NoType == sym->type());
- ASSERT_TRUE( ResolveInfo::Common == sym->desc() );
- ASSERT_TRUE( 0 == sym->binding() );
- ASSERT_TRUE( 0 == sym->other() );
+ ASSERT_FALSE(sym->isSymbol());
+ // ASSERT_TRUE( sym->isSymbol() );
+ ASSERT_TRUE(sym->isGlobal());
+ ASSERT_FALSE(sym->isWeak());
+ ASSERT_FALSE(sym->isLocal());
+ ASSERT_FALSE(sym->isDyn());
+ ASSERT_FALSE(sym->isDefine());
+ ASSERT_FALSE(sym->isUndef());
+ ASSERT_TRUE(sym->isCommon());
+ ASSERT_FALSE(sym->isIndirect());
+ ASSERT_TRUE(ResolveInfo::NoType == sym->type());
+ ASSERT_TRUE(ResolveInfo::Common == sym->desc());
+ ASSERT_TRUE(0 == sym->binding());
+ ASSERT_TRUE(0 == sym->other());
sym->setDesc(ResolveInfo::Indirect);
- ASSERT_FALSE( sym->isSymbol() );
- ASSERT_TRUE( sym->isGlobal() );
- ASSERT_FALSE( sym->isWeak() );
- ASSERT_FALSE( sym->isLocal() );
- ASSERT_FALSE( sym->isDyn() );
- ASSERT_FALSE( sym->isDefine() );
- ASSERT_FALSE( sym->isUndef() );
- ASSERT_FALSE( sym->isCommon() );
- ASSERT_TRUE( sym->isIndirect() );
- ASSERT_TRUE( ResolveInfo::NoType == sym->type());
- ASSERT_TRUE( ResolveInfo::Indirect == sym->desc() );
- ASSERT_TRUE( 0 == sym->binding() );
- ASSERT_TRUE( 0 == sym->other() );
+ ASSERT_FALSE(sym->isSymbol());
+ ASSERT_TRUE(sym->isGlobal());
+ ASSERT_FALSE(sym->isWeak());
+ ASSERT_FALSE(sym->isLocal());
+ ASSERT_FALSE(sym->isDyn());
+ ASSERT_FALSE(sym->isDefine());
+ ASSERT_FALSE(sym->isUndef());
+ ASSERT_FALSE(sym->isCommon());
+ ASSERT_TRUE(sym->isIndirect());
+ ASSERT_TRUE(ResolveInfo::NoType == sym->type());
+ ASSERT_TRUE(ResolveInfo::Indirect == sym->desc());
+ ASSERT_TRUE(0 == sym->binding());
+ ASSERT_TRUE(0 == sym->other());
sym->setDesc(ResolveInfo::Undefined);
- ASSERT_FALSE( sym->isSymbol() );
- ASSERT_TRUE( sym->isGlobal() );
- ASSERT_FALSE( sym->isWeak() );
- ASSERT_FALSE( sym->isLocal() );
- ASSERT_FALSE( sym->isDyn() );
- ASSERT_TRUE( sym->isUndef() );
- ASSERT_FALSE( sym->isDefine() );
- ASSERT_FALSE( sym->isCommon() );
- ASSERT_FALSE( sym->isIndirect() );
- ASSERT_TRUE( ResolveInfo::NoType == sym->type());
- ASSERT_TRUE( 0 == sym->desc() );
- ASSERT_TRUE( 0 == sym->binding() );
- ASSERT_TRUE( 0 == sym->other() );
+ ASSERT_FALSE(sym->isSymbol());
+ ASSERT_TRUE(sym->isGlobal());
+ ASSERT_FALSE(sym->isWeak());
+ ASSERT_FALSE(sym->isLocal());
+ ASSERT_FALSE(sym->isDyn());
+ ASSERT_TRUE(sym->isUndef());
+ ASSERT_FALSE(sym->isDefine());
+ ASSERT_FALSE(sym->isCommon());
+ ASSERT_FALSE(sym->isIndirect());
+ ASSERT_TRUE(ResolveInfo::NoType == sym->type());
+ ASSERT_TRUE(0 == sym->desc());
+ ASSERT_TRUE(0 == sym->binding());
+ ASSERT_TRUE(0 == sym->other());
}
-TEST_F( StaticResolverTest, SetUpBinding)
-{
+TEST_F(StaticResolverTest, SetUpBinding) {
ResolveInfo* sym = ResolveInfo::Create("abc");
sym->setIsSymbol(true);
-// ASSERT_FALSE( sym->isSymbol() );
- ASSERT_TRUE( sym->isSymbol() );
- ASSERT_TRUE( sym->isGlobal() );
- ASSERT_FALSE( sym->isWeak() );
- ASSERT_FALSE( sym->isLocal() );
- ASSERT_FALSE( sym->isDefine() );
- ASSERT_TRUE( sym->isUndef() );
- ASSERT_FALSE( sym->isDyn() );
- ASSERT_FALSE( sym->isCommon() );
- ASSERT_FALSE( sym->isIndirect() );
- ASSERT_TRUE( ResolveInfo::NoType == sym->type());
- ASSERT_TRUE( 0 == sym->desc() );
- ASSERT_TRUE( 0 == sym->binding() );
- ASSERT_TRUE( 0 == sym->other() );
+ // ASSERT_FALSE( sym->isSymbol() );
+ ASSERT_TRUE(sym->isSymbol());
+ ASSERT_TRUE(sym->isGlobal());
+ ASSERT_FALSE(sym->isWeak());
+ ASSERT_FALSE(sym->isLocal());
+ ASSERT_FALSE(sym->isDefine());
+ ASSERT_TRUE(sym->isUndef());
+ ASSERT_FALSE(sym->isDyn());
+ ASSERT_FALSE(sym->isCommon());
+ ASSERT_FALSE(sym->isIndirect());
+ ASSERT_TRUE(ResolveInfo::NoType == sym->type());
+ ASSERT_TRUE(0 == sym->desc());
+ ASSERT_TRUE(0 == sym->binding());
+ ASSERT_TRUE(0 == sym->other());
sym->setBinding(ResolveInfo::Global);
- ASSERT_TRUE( sym->isSymbol() );
- ASSERT_TRUE( sym->isGlobal() );
- ASSERT_FALSE( sym->isWeak() );
- ASSERT_FALSE( sym->isLocal() );
- ASSERT_FALSE( sym->isDefine() );
- ASSERT_TRUE( sym->isUndef() );
- ASSERT_FALSE( sym->isDyn() );
- ASSERT_FALSE( sym->isCommon() );
- ASSERT_FALSE( sym->isIndirect() );
- ASSERT_TRUE( ResolveInfo::NoType == sym->type());
- ASSERT_TRUE( 0 == sym->desc() );
- ASSERT_TRUE( ResolveInfo::Global == sym->binding() );
- ASSERT_TRUE( 0 == sym->other() );
+ ASSERT_TRUE(sym->isSymbol());
+ ASSERT_TRUE(sym->isGlobal());
+ ASSERT_FALSE(sym->isWeak());
+ ASSERT_FALSE(sym->isLocal());
+ ASSERT_FALSE(sym->isDefine());
+ ASSERT_TRUE(sym->isUndef());
+ ASSERT_FALSE(sym->isDyn());
+ ASSERT_FALSE(sym->isCommon());
+ ASSERT_FALSE(sym->isIndirect());
+ ASSERT_TRUE(ResolveInfo::NoType == sym->type());
+ ASSERT_TRUE(0 == sym->desc());
+ ASSERT_TRUE(ResolveInfo::Global == sym->binding());
+ ASSERT_TRUE(0 == sym->other());
sym->setBinding(ResolveInfo::Weak);
- ASSERT_TRUE( sym->isSymbol() );
- ASSERT_FALSE( sym->isGlobal() );
- ASSERT_TRUE( sym->isWeak() );
- ASSERT_FALSE( sym->isLocal() );
- ASSERT_FALSE( sym->isDyn() );
- ASSERT_FALSE( sym->isDefine() );
- ASSERT_TRUE( sym->isUndef() );
- ASSERT_FALSE( sym->isCommon() );
- ASSERT_FALSE( sym->isIndirect() );
- ASSERT_TRUE( ResolveInfo::NoType == sym->type());
- ASSERT_TRUE( 0 == sym->desc() );
- ASSERT_TRUE( ResolveInfo::Weak == sym->binding() );
- ASSERT_TRUE( 0 == sym->other() );
+ ASSERT_TRUE(sym->isSymbol());
+ ASSERT_FALSE(sym->isGlobal());
+ ASSERT_TRUE(sym->isWeak());
+ ASSERT_FALSE(sym->isLocal());
+ ASSERT_FALSE(sym->isDyn());
+ ASSERT_FALSE(sym->isDefine());
+ ASSERT_TRUE(sym->isUndef());
+ ASSERT_FALSE(sym->isCommon());
+ ASSERT_FALSE(sym->isIndirect());
+ ASSERT_TRUE(ResolveInfo::NoType == sym->type());
+ ASSERT_TRUE(0 == sym->desc());
+ ASSERT_TRUE(ResolveInfo::Weak == sym->binding());
+ ASSERT_TRUE(0 == sym->other());
sym->setBinding(ResolveInfo::Local);
- ASSERT_TRUE( sym->isSymbol() );
- ASSERT_FALSE( sym->isGlobal() );
- ASSERT_FALSE( sym->isWeak() );
- ASSERT_TRUE( sym->isLocal() );
- ASSERT_FALSE( sym->isDyn() );
- ASSERT_FALSE( sym->isDefine() );
- ASSERT_TRUE( sym->isUndef() );
- ASSERT_FALSE( sym->isCommon() );
- ASSERT_FALSE( sym->isIndirect() );
- ASSERT_TRUE( ResolveInfo::NoType == sym->type());
- ASSERT_TRUE( 0 == sym->desc() );
- ASSERT_TRUE( ResolveInfo::Local == sym->binding() );
- ASSERT_TRUE( 0 == sym->other() );
+ ASSERT_TRUE(sym->isSymbol());
+ ASSERT_FALSE(sym->isGlobal());
+ ASSERT_FALSE(sym->isWeak());
+ ASSERT_TRUE(sym->isLocal());
+ ASSERT_FALSE(sym->isDyn());
+ ASSERT_FALSE(sym->isDefine());
+ ASSERT_TRUE(sym->isUndef());
+ ASSERT_FALSE(sym->isCommon());
+ ASSERT_FALSE(sym->isIndirect());
+ ASSERT_TRUE(ResolveInfo::NoType == sym->type());
+ ASSERT_TRUE(0 == sym->desc());
+ ASSERT_TRUE(ResolveInfo::Local == sym->binding());
+ ASSERT_TRUE(0 == sym->other());
}
-
diff --git a/unittests/StaticResolverTest.h b/unittests/StaticResolverTest.h
index c6f0699..06f5052 100644
--- a/unittests/StaticResolverTest.h
+++ b/unittests/StaticResolverTest.h
@@ -10,7 +10,7 @@
#define STATICRESOLVER_TEST_H
#include <gtest.h>
-#include <mcld/LinkerConfig.h>
+#include "mcld/LinkerConfig.h"
namespace mcld {
@@ -18,19 +18,17 @@ class StaticResolver;
class ResolveInfoFactory;
class DiagnosticPrinter;
-} // namespace for mcld
+} // namespace for mcld
-namespace mcldtest
-{
+namespace mcldtest {
/** \class StaticResolverTest
* \brief The testcases for static resolver
*
* \see StaticResolver
*/
-class StaticResolverTest : public ::testing::Test
-{
-public:
+class StaticResolverTest : public ::testing::Test {
+ public:
// Constructor can do set-up work for all test here.
StaticResolverTest();
@@ -43,13 +41,12 @@ public:
// TearDown() will be called immediately after each test.
virtual void TearDown();
-protected:
+ protected:
mcld::StaticResolver* m_pResolver;
mcld::LinkerConfig* m_pConfig;
mcld::DiagnosticPrinter* m_pPrinter;
};
-} // namespace of mcldtest
+} // namespace of mcldtest
#endif
-
diff --git a/unittests/StringTableTest.cpp b/unittests/StringTableTest.cpp
index 59a8e7b..061068a 100644
--- a/unittests/StringTableTest.cpp
+++ b/unittests/StringTableTest.cpp
@@ -13,10 +13,8 @@
using namespace mcld;
using namespace mcldtest;
-
// Constructor can do set-up work for all test here.
-StringTableTest::StringTableTest()
-{
+StringTableTest::StringTableTest() {
// create testee. modify it if need
Resolver* R = new Resolver();
StrSymPool* Pool = new StrSymPool(1, 1, *R);
@@ -24,26 +22,23 @@ StringTableTest::StringTableTest()
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-StringTableTest::~StringTableTest()
-{
+StringTableTest::~StringTableTest() {
delete m_pTestee;
}
// SetUp() will be called immediately before each test.
-void StringTableTest::SetUp()
-{
+void StringTableTest::SetUp() {
}
// TearDown() will be called immediately after each test.
-void StringTableTest::TearDown()
-{
+void StringTableTest::TearDown() {
}
//==========================================================================//
// Testcases
//
TEST_F(StringTableTest, different_string_size) {
- int size = 127-32;
+ int size = 127 - 32;
for (int i = 32; i < 127; ++i) {
char c[2];
c[0] = i;
diff --git a/unittests/StringTableTest.h b/unittests/StringTableTest.h
index 60d7f00..8c2ae03 100644
--- a/unittests/StringTableTest.h
+++ b/unittests/StringTableTest.h
@@ -11,23 +11,20 @@
#include <gtest.h>
-namespace mcld
-{
+namespace mcld {
class StringTable;
-} // namespace for mcld
+} // namespace for mcld
-namespace mcldtest
-{
+namespace mcldtest {
/** \class StringTableTest
* \brief
*
* \see StringTable
*/
-class StringTableTest : public ::testing::Test
-{
-public:
+class StringTableTest : public ::testing::Test {
+ public:
// Constructor can do set-up work for all test here.
StringTableTest();
@@ -40,11 +37,10 @@ public:
// TearDown() will be called immediately after each test.
virtual void TearDown();
-protected:
+ protected:
mcld::StringTable* m_pTestee;
};
-} // namespace of mcldtest
+} // namespace of mcldtest
#endif
-
diff --git a/unittests/SymbolCategoryTest.cpp b/unittests/SymbolCategoryTest.cpp
index f1de1d7..7eb1988 100644
--- a/unittests/SymbolCategoryTest.cpp
+++ b/unittests/SymbolCategoryTest.cpp
@@ -6,9 +6,9 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#include <mcld/MC/SymbolCategory.h>
-#include <mcld/LD/ResolveInfo.h>
-#include <mcld/LD/LDSymbol.h>
+#include "mcld/MC/SymbolCategory.h"
+#include "mcld/LD/ResolveInfo.h"
+#include "mcld/LD/LDSymbol.h"
#include <iostream>
#include "SymbolCategoryTest.h"
@@ -16,28 +16,23 @@ using namespace std;
using namespace mcld;
using namespace mcldtest;
-
// Constructor can do set-up work for all test here.
-SymbolCategoryTest::SymbolCategoryTest()
-{
+SymbolCategoryTest::SymbolCategoryTest() {
// create testee. modify it if need
m_pTestee = new SymbolCategory();
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-SymbolCategoryTest::~SymbolCategoryTest()
-{
+SymbolCategoryTest::~SymbolCategoryTest() {
delete m_pTestee;
}
// SetUp() will be called immediately before each test.
-void SymbolCategoryTest::SetUp()
-{
+void SymbolCategoryTest::SetUp() {
}
// TearDown() will be called immediately after each test.
-void SymbolCategoryTest::TearDown()
-{
+void SymbolCategoryTest::TearDown() {
}
//==========================================================================//
diff --git a/unittests/SymbolCategoryTest.h b/unittests/SymbolCategoryTest.h
index a7109ed..39dabd7 100644
--- a/unittests/SymbolCategoryTest.h
+++ b/unittests/SymbolCategoryTest.h
@@ -11,23 +11,20 @@
#include <gtest.h>
-namespace mcld
-{
+namespace mcld {
class SymbolCategory;
-} // namespace for mcld
+} // namespace for mcld
-namespace mcldtest
-{
+namespace mcldtest {
/** \class SymbolCategoryTest
* \brief The testcases of symbol category.
*
* \see SymbolCategory
*/
-class SymbolCategoryTest : public ::testing::Test
-{
-public:
+class SymbolCategoryTest : public ::testing::Test {
+ public:
// Constructor can do set-up work for all test here.
SymbolCategoryTest();
@@ -40,11 +37,10 @@ public:
// TearDown() will be called immediately after each test.
virtual void TearDown();
-protected:
+ protected:
mcld::SymbolCategory* m_pTestee;
};
-} // namespace of mcldtest
+} // namespace of mcldtest
#endif
-
diff --git a/unittests/SymbolTableTest.cpp b/unittests/SymbolTableTest.cpp
index 2dc5143..a601d07 100644
--- a/unittests/SymbolTableTest.cpp
+++ b/unittests/SymbolTableTest.cpp
@@ -6,34 +6,29 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#include <mcld/LD/SymbolTable.h>
+#include "mcld/LD/SymbolTable.h"
#include "SymbolTableTest.h"
using namespace mcld;
using namespace mcldtest;
-
// Constructor can do set-up work for all test here.
-SymbolTableTest::SymbolTableTest()
-{
+SymbolTableTest::SymbolTableTest() {
// create testee. modify it if need
m_pTestee = new SymbolTable<>(m_StrTable);
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-SymbolTableTest::~SymbolTableTest()
-{
+SymbolTableTest::~SymbolTableTest() {
delete m_pTestee;
}
// SetUp() will be called immediately before each test.
-void SymbolTableTest::SetUp()
-{
+void SymbolTableTest::SetUp() {
}
// TearDown() will be called immediately after each test.
-void SymbolTableTest::TearDown()
-{
+void SymbolTableTest::TearDown() {
}
//==========================================================================//
diff --git a/unittests/SymbolTableTest.h b/unittests/SymbolTableTest.h
index 39e8751..4a4ce70 100644
--- a/unittests/SymbolTableTest.h
+++ b/unittests/SymbolTableTest.h
@@ -11,23 +11,20 @@
#include "mcld/LD/StringTable.h"
#include <gtest.h>
-namespace mcld
-{
- template <template <class> class, class>
- class SymbolTable;
-} // namespace for mcld
+namespace mcld {
+template <template <class> class, class>
+class SymbolTable;
+} // namespace for mcld
-namespace mcldtest
-{
+namespace mcldtest {
/** \class SymbolTableTest
* \brief
*
* \see SymbolTable
*/
-class SymbolTableTest : public ::testing::Test
-{
-public:
+class SymbolTableTest : public ::testing::Test {
+ public:
// Constructor can do set-up work for all test here.
SymbolTableTest();
@@ -40,11 +37,11 @@ public:
// TearDown() will be called immediately after each test.
virtual void TearDown();
-protected:
+ protected:
mcld::SymbolTable<>* m_pTestee;
mcld::StringTable m_StrTable;
};
-} // namespace of mcldtest
+} // namespace of mcldtest
#endif
diff --git a/unittests/SystemUtilsTest.cpp b/unittests/SystemUtilsTest.cpp
index 1222794..3923aee 100644
--- a/unittests/SystemUtilsTest.cpp
+++ b/unittests/SystemUtilsTest.cpp
@@ -6,37 +6,31 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#include <mcld/Support/SystemUtils.h>
+#include "mcld/Support/SystemUtils.h"
#include "SystemUtilsTest.h"
using namespace mcld;
using namespace mcld::test;
-
// Constructor can do set-up work for all test here.
-SystemUtilsTest::SystemUtilsTest()
-{
+SystemUtilsTest::SystemUtilsTest() {
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-SystemUtilsTest::~SystemUtilsTest()
-{
+SystemUtilsTest::~SystemUtilsTest() {
}
// SetUp() will be called immediately before each test.
-void SystemUtilsTest::SetUp()
-{
+void SystemUtilsTest::SetUp() {
}
// TearDown() will be called immediately after each test.
-void SystemUtilsTest::TearDown()
-{
+void SystemUtilsTest::TearDown() {
}
//===----------------------------------------------------------------------===//
// Testcases
//===----------------------------------------------------------------------===//
-TEST_F( SystemUtilsTest, test_strerror) {
+TEST_F(SystemUtilsTest, test_strerror) {
ASSERT_TRUE(NULL != mcld::sys::strerror(0));
}
-
diff --git a/unittests/SystemUtilsTest.h b/unittests/SystemUtilsTest.h
index 660d7bb..ce0d204 100644
--- a/unittests/SystemUtilsTest.h
+++ b/unittests/SystemUtilsTest.h
@@ -14,9 +14,8 @@
namespace mcld {
namespace test {
-class SystemUtilsTest : public ::testing::Test
-{
-public:
+class SystemUtilsTest : public ::testing::Test {
+ public:
// Constructor can do set-up work for all test here.
SystemUtilsTest();
@@ -30,8 +29,7 @@ public:
virtual void TearDown();
};
-} // namespace of test
-} // namespace of mcld
+} // namespace of test
+} // namespace of mcld
#endif
-
diff --git a/unittests/TargetMachineTest.cpp b/unittests/TargetMachineTest.cpp
index 85950a9..8501d84 100644
--- a/unittests/TargetMachineTest.cpp
+++ b/unittests/TargetMachineTest.cpp
@@ -11,32 +11,26 @@
using namespace mcld;
using namespace mcldTEST;
-
// Constructor can do set-up work for all test here.
-TargetMachineTest::TargetMachineTest()
-{
+TargetMachineTest::TargetMachineTest() {
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-TargetMachineTest::~TargetMachineTest()
-{
+TargetMachineTest::~TargetMachineTest() {
}
// SetUp() will be called immediately before each test.
-void TargetMachineTest::SetUp()
-{
+void TargetMachineTest::SetUp() {
}
// TearDown() will be called immediately after each test.
-void TargetMachineTest::TearDown()
-{
+void TargetMachineTest::TearDown() {
}
//==========================================================================//
// Testcases
//
-TEST_F( TargetMachineTest, addPassesToEmitFile ) {
- mcld::addPassesToEmitFile();
+TEST_F(TargetMachineTest, addPassesToEmitFile) {
+ mcld::addPassesToEmitFile();
}
-
diff --git a/unittests/TargetMachineTest.h b/unittests/TargetMachineTest.h
index 88a44dc..3d19e68 100644
--- a/unittests/TargetMachineTest.h
+++ b/unittests/TargetMachineTest.h
@@ -11,31 +11,28 @@
#include "mcld/Target/TargetMachine.h"
#include <gtest.h>
-namespace mcldTEST
-{
+namespace mcldTEST {
/** \class TargetMachineTest
* \brief
*
* \see TargetMachine
*/
-class TargetMachineTest : public ::testing::Test
-{
-public:
- // Constructor can do set-up work for all test here.
- TargetMachineTest();
+class TargetMachineTest : public ::testing::Test {
+ public:
+ // Constructor can do set-up work for all test here.
+ TargetMachineTest();
- // Destructor can do clean-up work that doesn't throw exceptions here.
- virtual ~TargetMachineTest();
+ // Destructor can do clean-up work that doesn't throw exceptions here.
+ virtual ~TargetMachineTest();
- // SetUp() will be called immediately before each test.
- virtual void SetUp();
+ // SetUp() will be called immediately before each test.
+ virtual void SetUp();
- // TearDown() will be called immediately after each test.
- virtual void TearDown();
+ // TearDown() will be called immediately after each test.
+ virtual void TearDown();
};
-} // namespace of BOLDTEST
+} // namespace of BOLDTEST
#endif
-
diff --git a/unittests/UniqueGCFactoryBaseTest.cpp b/unittests/UniqueGCFactoryBaseTest.cpp
index a6f7289..5480eab 100644
--- a/unittests/UniqueGCFactoryBaseTest.cpp
+++ b/unittests/UniqueGCFactoryBaseTest.cpp
@@ -6,92 +6,91 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#include <mcld/MC/ContextFactory.h>
-#include <mcld/Support/MemoryAreaFactory.h>
-#include <mcld/Support/TargetSelect.h>
-#include <mcld/Support/Path.h>
+#include "mcld/MC/ContextFactory.h"
+#include "mcld/Support/MemoryAreaFactory.h"
+#include "mcld/Support/TargetSelect.h"
+#include "mcld/Support/Path.h"
#include "UniqueGCFactoryBaseTest.h"
using namespace mcld;
using namespace mcldtest;
-
// Constructor can do set-up work for all test here.
-UniqueGCFactoryBaseTest::UniqueGCFactoryBaseTest()
-{
+UniqueGCFactoryBaseTest::UniqueGCFactoryBaseTest() {
m_pConfig = new LinkerConfig("arm-none-linux-gnueabi");
}
// Destructor can do clean-up work that doesn't throw exceptions here.
-UniqueGCFactoryBaseTest::~UniqueGCFactoryBaseTest()
-{
+UniqueGCFactoryBaseTest::~UniqueGCFactoryBaseTest() {
delete m_pConfig;
}
// SetUp() will be called immediately before each test.
-void UniqueGCFactoryBaseTest::SetUp()
-{
+void UniqueGCFactoryBaseTest::SetUp() {
}
// TearDown() will be called immediately after each test.
-void UniqueGCFactoryBaseTest::TearDown()
-{
+void UniqueGCFactoryBaseTest::TearDown() {
}
//==========================================================================//
// Testcases
//
-TEST_F( UniqueGCFactoryBaseTest, number_constructor ) {
- ContextFactory *contextFactory = new ContextFactory(10);
- contextFactory->produce("/");
- contextFactory->produce("ab/c");
- ASSERT_TRUE( 2 == contextFactory->size());
- delete contextFactory;
+TEST_F(UniqueGCFactoryBaseTest, number_constructor) {
+ ContextFactory* contextFactory = new ContextFactory(10);
+ contextFactory->produce("/");
+ contextFactory->produce("ab/c");
+ ASSERT_TRUE(2 == contextFactory->size());
+ delete contextFactory;
}
-TEST_F( UniqueGCFactoryBaseTest, unique_produce ) {
- ContextFactory *contextFactory = new ContextFactory(10);
- LDContext* context1 = contextFactory->produce("/");
- contextFactory->produce("ab/c");
- ASSERT_TRUE( 2 == contextFactory->size());
- LDContext* context2 = contextFactory->produce("/");
- ASSERT_EQ( context1, context2 );
- delete contextFactory;
+TEST_F(UniqueGCFactoryBaseTest, unique_produce) {
+ ContextFactory* contextFactory = new ContextFactory(10);
+ LDContext* context1 = contextFactory->produce("/");
+ contextFactory->produce("ab/c");
+ ASSERT_TRUE(2 == contextFactory->size());
+ LDContext* context2 = contextFactory->produce("/");
+ ASSERT_EQ(context1, context2);
+ delete contextFactory;
}
-TEST_F( UniqueGCFactoryBaseTest, unique_produce2 ) {
- ContextFactory *contextFactory = new ContextFactory(10);
- LDContext* context1 = contextFactory->produce("abc/def");
- contextFactory->produce("ab/c");
- ASSERT_TRUE( 2 == contextFactory->size());
- LDContext* context2 = contextFactory->produce("ttt/../abc/def");
- ASSERT_EQ( context1, context2 );
- delete contextFactory;
+TEST_F(UniqueGCFactoryBaseTest, unique_produce2) {
+ ContextFactory* contextFactory = new ContextFactory(10);
+ LDContext* context1 = contextFactory->produce("abc/def");
+ contextFactory->produce("ab/c");
+ ASSERT_TRUE(2 == contextFactory->size());
+ LDContext* context2 = contextFactory->produce("ttt/../abc/def");
+ ASSERT_EQ(context1, context2);
+ delete contextFactory;
}
-TEST_F( UniqueGCFactoryBaseTest, iterator )
-{
- sys::fs::Path path1(TOPDIR), path2(TOPDIR);
- path1.append("unittests/test.txt");
- path2.append("unittests/test2.txt");
+TEST_F(UniqueGCFactoryBaseTest, iterator) {
+ sys::fs::Path path1(TOPDIR), path2(TOPDIR);
+ path1.append("unittests/test.txt");
+ path2.append("unittests/test2.txt");
- MemoryAreaFactory* memFactory = new MemoryAreaFactory(10);
- MemoryArea* area1 = memFactory->produce(path1, FileHandle::ReadOnly);
- MemoryArea* area2 = memFactory->produce(path2, FileHandle::ReadOnly);
- ASSERT_NE( area1, area2);
+ MemoryAreaFactory* memFactory = new MemoryAreaFactory(10);
+ MemoryArea* area1 =
+ memFactory->produce(path1, FileHandle::OpenMode(FileHandle::ReadOnly),
+ FileHandle::Permission(FileHandle::System));
+ MemoryArea* area2 =
+ memFactory->produce(path2, FileHandle::OpenMode(FileHandle::ReadOnly),
+ FileHandle::Permission(FileHandle::System));
+ ASSERT_NE(area1, area2);
- MemoryArea* area3 = memFactory->produce(path1, FileHandle::ReadOnly);
+ MemoryArea* area3 =
+ memFactory->produce(path1, FileHandle::OpenMode(FileHandle::ReadOnly),
+ FileHandle::Permission(FileHandle::System));
- ASSERT_EQ(area1, area3);
- ASSERT_FALSE( memFactory->empty());
- ASSERT_TRUE( 2 == memFactory->size());
- MemoryAreaFactory::iterator aIter = memFactory->begin();
- ASSERT_EQ( area1, &(*aIter));
- ++aIter;
- ASSERT_EQ( area2, &(*aIter));
- ++aIter;
- MemoryAreaFactory::iterator aEnd = memFactory->end();
- ASSERT_TRUE( aEnd == aIter);
- delete memFactory;
+ ASSERT_EQ(area1, area3);
+ ASSERT_FALSE(memFactory->empty());
+ ASSERT_TRUE(2 == memFactory->size());
+ MemoryAreaFactory::iterator aIter = memFactory->begin();
+ ASSERT_EQ(area1, &(*aIter));
+ ++aIter;
+ ASSERT_EQ(area2, &(*aIter));
+ ++aIter;
+ MemoryAreaFactory::iterator aEnd = memFactory->end();
+ ASSERT_TRUE(aEnd == aIter);
+ delete memFactory;
}
-
diff --git a/unittests/UniqueGCFactoryBaseTest.h b/unittests/UniqueGCFactoryBaseTest.h
index c2f1c1b..14ba2e0 100644
--- a/unittests/UniqueGCFactoryBaseTest.h
+++ b/unittests/UniqueGCFactoryBaseTest.h
@@ -9,22 +9,20 @@
#ifndef UNIQUE_GCFACTORYBASE_TEST_H
#define UNIQUE_GCFACTORYBASE_TEST_H
-#include <mcld/Support/UniqueGCFactory.h>
-#include <mcld/LinkerConfig.h>
-#include <mcld/LD/DiagnosticPrinter.h>
+#include "mcld/Support/UniqueGCFactory.h"
+#include "mcld/LinkerConfig.h"
+#include "mcld/LD/DiagnosticPrinter.h"
#include <gtest.h>
-namespace mcldtest
-{
+namespace mcldtest {
/** \class UniqueGCFactoryBaseTest
* - check the unique of key.
* - make sure the key associates with the same storage of value.
* - check if all functions in the GCFactoryBase are available.
*/
-class UniqueGCFactoryBaseTest : public ::testing::Test
-{
-public:
+class UniqueGCFactoryBaseTest : public ::testing::Test {
+ public:
// Constructor can do set-up work for all test here.
UniqueGCFactoryBaseTest();
@@ -37,11 +35,10 @@ public:
// TearDown() will be called immediately after each test.
virtual void TearDown();
-private:
+ private:
mcld::LinkerConfig* m_pConfig;
};
-} // namespace of mcldtest
+} // namespace of mcldtest
#endif
-