aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-01-22 12:02:40 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-01-22 12:02:40 +0000
commit6f0147d96dca9a6dc7f841eddff451dbf0bbac85 (patch)
tree5b597cda80529cbe28be59e0408ef60350eb8e29
parent664d53715dcd7c9c266083179bae00ff19750557 (diff)
downloadpaludis-6f0147d96dca9a6dc7f841eddff451dbf0bbac85.tar.gz
paludis-6f0147d96dca9a6dc7f841eddff451dbf0bbac85.tar.xz
Checked dereferencing isn't pure
-rw-r--r--paludis/counted_ptr.hh8
-rw-r--r--paludis/counted_ptr_TEST.cc37
2 files changed, 31 insertions, 14 deletions
diff --git a/paludis/counted_ptr.hh b/paludis/counted_ptr.hh
index 7eeec2c..5b9dcaf 100644
--- a/paludis/counted_ptr.hh
+++ b/paludis/counted_ptr.hh
@@ -246,22 +246,22 @@ namespace paludis
/**
* Dereference operator (const).
*/
- inline const T_ & operator* () const PALUDIS_ATTRIBUTE((pure));
+ inline const T_ & operator* () const;
/**
* Dereference to member operator (const).
*/
- inline const T_ * operator-> () const PALUDIS_ATTRIBUTE((pure));
+ inline const T_ * operator-> () const;
/**
* Dereference operator (non const).
*/
- T_ & operator* () PALUDIS_ATTRIBUTE((pure));
+ T_ & operator* ();
/**
* Dereference to member operator (non const).
*/
- T_ * operator-> () PALUDIS_ATTRIBUTE((pure));
+ T_ * operator-> ();
/**
* Not null?
diff --git a/paludis/counted_ptr_TEST.cc b/paludis/counted_ptr_TEST.cc
index aec8020..30df20c 100644
--- a/paludis/counted_ptr_TEST.cc
+++ b/paludis/counted_ptr_TEST.cc
@@ -110,7 +110,7 @@ namespace test_cases
TEST_CHECK_EQUAL(*j, "moo");
TEST_CHECK_EQUAL(j->length(), 3);
}
- } counted_ptr_dereference_tests;
+ } test_counted_ptr_dereference;
/**
* \test CountedPtr copy tests.
@@ -130,7 +130,7 @@ namespace test_cases
TEST_CHECK_EQUAL(*i, 10);
TEST_CHECK_EQUAL(*i2, 10);
}
- } counted_ptr_copy_tests;
+ } test_counted_ptr_copy;
/**
* \test CountedPtr dereference-assign tests.
@@ -160,7 +160,7 @@ namespace test_cases
TEST_CHECK_EQUAL(*i, 40);
TEST_CHECK_EQUAL(*i2, 40);
}
- } counted_ptr_dereference_assign_tests;
+ } test_counted_ptr_dereference_assign;
/**
* \test CountedPtr assign value tests.
@@ -183,7 +183,7 @@ namespace test_cases
TEST_CHECK_EQUAL(*i, 20);
TEST_CHECK_EQUAL(*i2, 10);
}
- } counted_ptr_assign_value_tests;
+ } test_counted_ptr_assign_value;
/**
* \test CountedPtr assign pointer tests.
@@ -209,7 +209,7 @@ namespace test_cases
TEST_CHECK_EQUAL(*i2, 10);
TEST_CHECK_EQUAL(*i3, 30);
}
- } counted_ptr_assign_pointer_tests;
+ } test_counted_ptr_assign_pointer;
/**
* \test CountedPtr internal creation tests.
@@ -243,7 +243,7 @@ namespace test_cases
MyClass::Pointer j(new MyClass(20));
TEST_CHECK_EQUAL(*j, 20);
}
- } counted_ptr_internal_dereference_tests;
+ } test_counted_ptr_internal_dereference;
/**
* \test CountedPtr internal copy tests.
@@ -263,7 +263,7 @@ namespace test_cases
TEST_CHECK_EQUAL(*i, 10);
TEST_CHECK_EQUAL(*i2, 10);
}
- } counted_ptr_internal_copy_tests;
+ } test_counted_ptr_internal_copy;
/**
* \test CountedPtr internal dereference-assign tests.
@@ -294,7 +294,7 @@ namespace test_cases
TEST_CHECK_EQUAL(*i, 40);
TEST_CHECK_EQUAL(*i2, 40);
}
- } counted_ptr_internal_dereference_assign_tests;
+ } test_counted_ptr_internal_dereference_assign;
/**
* \test CountedPtr internal assign value tests.
@@ -318,7 +318,7 @@ namespace test_cases
TEST_CHECK_EQUAL(*i, 20);
TEST_CHECK_EQUAL(*i2, 10);
}
- } counted_ptr_internal_assign_value_tests;
+ } test_counted_ptr_internal_assign_value;
/**
* \test CountedPtr internal assign pointer tests.
@@ -345,6 +345,23 @@ namespace test_cases
TEST_CHECK_EQUAL(*i2, 10);
TEST_CHECK_EQUAL(*i3, 30);
}
- } counted_ptr_internal_assign_pointer_tests;
+ } test_counted_ptr_internal_assign_pointer;
+
+ /**
+ * \test CountedPtr zero dereferences.
+ *
+ * \ingroup Test
+ */
+ struct CountedPtrZeroDeferenceTests : TestCase
+ {
+ CountedPtrZeroDeferenceTests() :
+ TestCase("CountedPtr zero dereference tests") { }
+
+ void run()
+ {
+ CountedPtr<int, count_policy::ExternalCountTag, dereference_policy::CheckedDereferenceTag> i(0);
+ TEST_CHECK_THROWS(++*i, CountedPtrError);
+ }
+ } test_counted_ptr_zero_dereference;
}