summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-05-30 17:37:31 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-05-30 17:37:31 +0000
commitee2f195dd3e40f49698ca4dc2666ec09c770e80d (patch)
tree66fa9a69e5789356dfe844991e64bac9222f3a35 /unittests
parentab44ce3d598882e51a25eb82eb7ae6308de85ae6 (diff)
Notes
Diffstat (limited to 'unittests')
-rw-r--r--unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp12
-rw-r--r--unittests/Support/ManagedStatic.cpp41
2 files changed, 45 insertions, 8 deletions
diff --git a/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp b/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
index 9e846674648cb..3d14eb736df25 100644
--- a/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
+++ b/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
@@ -311,9 +311,8 @@ void TestAllForms() {
EXPECT_EQ(Data2, toReference(DieDG.find(Attr_DW_FORM_ref2), 0));
EXPECT_EQ(Data4, toReference(DieDG.find(Attr_DW_FORM_ref4), 0));
EXPECT_EQ(Data8, toReference(DieDG.find(Attr_DW_FORM_ref8), 0));
- if (Version >= 4) {
+ if (Version >= 4)
EXPECT_EQ(Data8_2, toReference(DieDG.find(Attr_DW_FORM_ref_sig8), 0));
- }
EXPECT_EQ(UData[0], toReference(DieDG.find(Attr_DW_FORM_ref_udata), 0));
//----------------------------------------------------------------------
@@ -321,17 +320,15 @@ void TestAllForms() {
//----------------------------------------------------------------------
EXPECT_EQ(1ULL, toUnsigned(DieDG.find(Attr_DW_FORM_flag_true), 0));
EXPECT_EQ(0ULL, toUnsigned(DieDG.find(Attr_DW_FORM_flag_false), 1));
- if (Version >= 4) {
+ if (Version >= 4)
EXPECT_EQ(1ULL, toUnsigned(DieDG.find(Attr_DW_FORM_flag_present), 0));
- }
//----------------------------------------------------------------------
// Test SLEB128 based forms
//----------------------------------------------------------------------
EXPECT_EQ(SData, toSigned(DieDG.find(Attr_DW_FORM_sdata), 0));
- if (Version >= 5) {
+ if (Version >= 5)
EXPECT_EQ(ICSData, toSigned(DieDG.find(Attr_DW_FORM_implicit_const), 0));
- }
//----------------------------------------------------------------------
// Test ULEB128 based forms
@@ -343,10 +340,9 @@ void TestAllForms() {
//----------------------------------------------------------------------
EXPECT_EQ(Dwarf32Values[0],
toReference(DieDG.find(Attr_DW_FORM_GNU_ref_alt), 0));
- if (Version >= 4) {
+ if (Version >= 4)
EXPECT_EQ(Dwarf32Values[1],
toSectionOffset(DieDG.find(Attr_DW_FORM_sec_offset), 0));
- }
//----------------------------------------------------------------------
// Add an address at the end to make sure we can decode this value
diff --git a/unittests/Support/ManagedStatic.cpp b/unittests/Support/ManagedStatic.cpp
index 153884ba42986..4e2e93036a83e 100644
--- a/unittests/Support/ManagedStatic.cpp
+++ b/unittests/Support/ManagedStatic.cpp
@@ -57,4 +57,45 @@ TEST(Initialize, MultipleThreads) {
}
#endif
+namespace NestedStatics {
+static ManagedStatic<int> Ms1;
+struct Nest {
+ Nest() {
+ ++(*Ms1);
+ }
+
+ ~Nest() {
+ assert(Ms1.isConstructed());
+ ++(*Ms1);
+ }
+};
+static ManagedStatic<Nest> Ms2;
+
+TEST(ManagedStaticTest, NestedStatics) {
+ EXPECT_FALSE(Ms1.isConstructed());
+ EXPECT_FALSE(Ms2.isConstructed());
+
+ *Ms2;
+ EXPECT_TRUE(Ms1.isConstructed());
+ EXPECT_TRUE(Ms2.isConstructed());
+}
+} // namespace NestedStatics
+
+namespace CustomCreatorDeletor {
+struct CustomCreate {
+ static void *call() {
+ void *Mem = std::malloc(sizeof(int));
+ *((int *)Mem) = 42;
+ return Mem;
+ }
+};
+struct CustomDelete {
+ static void call(void *P) { std::free(P); }
+};
+static ManagedStatic<int, CustomCreate, CustomDelete> Custom;
+TEST(ManagedStaticTest, CustomCreatorDeletor) {
+ EXPECT_EQ(42, *Custom);
+}
+} // namespace CustomCreatorDeletor
+
} // anonymous namespace