4 // Copyright (C) 2008-2018 Lorenzo Caminiti
5 // Distributed under the Boost Software License, Version 1.0 (see accompanying
6 // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
7 // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html
9 // Test with and without all invariants (static/cv/const-only) declarations.
11 #include "../detail/oteststream.hpp"
12 #include <boost/contract/base_types.hpp>
13 #include <boost/contract/constructor.hpp>
14 #include <boost/contract/destructor.hpp>
15 #include <boost/contract/public_function.hpp>
16 #include <boost/contract/function.hpp>
17 #include <boost/contract/override.hpp>
18 #include <boost/contract/check.hpp>
19 #include <boost/contract/assert.hpp>
20 #include <boost/detail/lightweight_test.hpp>
23 boost::contract::test::detail::oteststream out;
25 struct b : private boost::contract::constructor_precondition<b> {
26 // Test also with no base_types.
28 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
29 static void static_invariant() { out << "b::static_inv" << std::endl; }
31 #ifdef BOOST_CONTRACT_TEST_CV_INV
32 void invariant() const volatile { out << "b::cv_inv" << std::endl; }
34 #ifdef BOOST_CONTRACT_TEST_CONST_INV
35 void invariant() const { out << "b::const_inv" << std::endl; }
38 b() : boost::contract::constructor_precondition<b>([] {
39 out << "b::ctor::pre" << std::endl;
41 boost::contract::check c = boost::contract::constructor(this)
42 .old([] { out << "b::ctor::old" << std::endl; })
43 .postcondition([] { out << "b::ctor::post" << std::endl; })
45 out << "b::ctor::body" << std::endl;
49 boost::contract::check c = boost::contract::destructor(this)
50 .old([] { out << "b::dtor::old" << std::endl; })
51 .postcondition([] { out << "b::dtor::post" << std::endl; })
53 out << "b::dtor::body" << std::endl;
56 virtual void f(char x, boost::contract::virtual_* v = 0) volatile {
57 boost::contract::check c = boost::contract::public_function(v, this)
59 out << "b::f::volatile_pre" << std::endl;
60 BOOST_CONTRACT_ASSERT(x == 'b');
62 .old([] { out << "b::f::volatile_old" << std::endl; })
63 .postcondition([] { out << "b::f::volatile_post" << std::endl; })
65 out << "b::f::volatile_body" << std::endl;
68 virtual void f(char x, boost::contract::virtual_* v = 0) {
69 boost::contract::check c = boost::contract::public_function(v, this)
71 out << "b::f::pre" << std::endl;
72 BOOST_CONTRACT_ASSERT(x == 'b');
74 .old([] { out << "b::f::old" << std::endl; })
75 .postcondition([] { out << "b::f::post" << std::endl; })
77 out << "b::f::body" << std::endl;
82 #define BASES private boost::contract::constructor_precondition<a>, public b
85 typedef BOOST_CONTRACT_BASE_TYPES(BASES) base_types;
88 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
89 static void static_invariant() { out << "a::static_inv" << std::endl; }
91 #ifdef BOOST_CONTRACT_TEST_CV_INV
92 void invariant() const volatile { out << "a::cv_inv" << std::endl; }
94 #ifdef BOOST_CONTRACT_TEST_CONST_INV
95 void invariant() const { out << "a::const_inv" << std::endl; }
98 a() : boost::contract::constructor_precondition<a>([] {
99 out << "a::ctor::pre" << std::endl;
101 boost::contract::check c = boost::contract::constructor(this)
102 .old([] { out << "a::ctor::old" << std::endl; })
103 .postcondition([] { out << "a::ctor::post" << std::endl; })
105 out << "a::ctor::body" << std::endl;
109 boost::contract::check c = boost::contract::destructor(this)
110 .old([] { out << "a::dtor::old" << std::endl; })
111 .postcondition([] { out << "a::dtor::post" << std::endl; })
113 out << "a::dtor::body" << std::endl;
116 virtual void f(char x, boost::contract::virtual_* v = 0)
117 volatile /* override */ {
118 boost::contract::check c = boost::contract::public_function<
121 static_cast<void (a::*)(char x, boost::contract::virtual_*)
126 out << "a::f::volatile_pre" << std::endl;
127 BOOST_CONTRACT_ASSERT(x == 'a');
129 .old([] { out << "a::f::volatile_old" << std::endl; })
130 .postcondition([] { out << "a::f::volatile_post" << std::endl; })
132 out << "a::f::volatile_body" << std::endl;
135 virtual void f(char x, boost::contract::virtual_* v = 0) /* override */ {
136 boost::contract::check c = boost::contract::public_function<
139 static_cast<void (a::*)(char x, boost::contract::virtual_*)>(&a::f),
143 out << "a::f::pre" << std::endl;
144 BOOST_CONTRACT_ASSERT(x == 'a');
146 .old([] { out << "a::f::old" << std::endl; })
147 .postcondition([] { out << "a::f::post" << std::endl; })
149 out << "a::f::body" << std::endl;
153 boost::contract::check c = boost::contract::public_function<a>()
154 .precondition([] { out << "a::s::pre" << std::endl; })
155 .old([] { out << "a::s::old" << std::endl; })
156 .postcondition([] { out << "a::s::post" << std::endl; })
158 out << "a::s::body" << std::endl;
163 boost::contract::check c = boost::contract::function()
164 .precondition([] { out << "a::p::volatile_pre" << std::endl; })
165 .old([] { out << "a::p::volatile_old" << std::endl; })
166 .postcondition([] { out << "a::p::volatile_post" << std::endl; })
168 out << "a::p::volatile_body" << std::endl;
172 boost::contract::check c = boost::contract::function()
173 .precondition([] { out << "a::p::pre" << std::endl; })
174 .old([] { out << "a::p::old" << std::endl; })
175 .postcondition([] { out << "a::p::post" << std::endl; })
177 out << "a::p::body" << std::endl;
180 void call_p() volatile { p(); }
181 void call_p() { p(); }
185 boost::contract::check c = boost::contract::function()
186 .precondition([] { out << "a::q::volatile_pre" << std::endl; })
187 .old([] { out << "a::q::volatile_old" << std::endl; })
188 .postcondition([] { out << "a::q::volatile_post" << std::endl; })
190 out << "a::q::volatile_body" << std::endl;
194 boost::contract::check c = boost::contract::function()
195 .precondition([] { out << "a::q::pre" << std::endl; })
196 .old([] { out << "a::q::old" << std::endl; })
197 .postcondition([] { out << "a::q::post" << std::endl; })
199 out << "a::q::body" << std::endl;
202 void call_q() volatile { q(); }
203 void call_q() { q(); }
205 BOOST_CONTRACT_OVERRIDE(f)
209 std::ostringstream ok;
211 { // Test volatile call with bases.
214 ok.str(""); ok // Ctors always check const_inv (even if volatile).
215 #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
216 << "a::ctor::pre" << std::endl
217 << "b::ctor::pre" << std::endl
220 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
221 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
222 << "b::static_inv" << std::endl
225 #ifndef BOOST_CONTRACT_NO_OLDS
226 << "b::ctor::old" << std::endl
228 << "b::ctor::body" << std::endl
229 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
230 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
231 << "b::static_inv" << std::endl
233 #ifdef BOOST_CONTRACT_TEST_CV_INV
234 << "b::cv_inv" << std::endl
236 #ifdef BOOST_CONTRACT_TEST_CONST_INV
237 << "b::const_inv" << std::endl
240 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
241 << "b::ctor::post" << std::endl
244 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
245 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
246 << "a::static_inv" << std::endl
249 #ifndef BOOST_CONTRACT_NO_OLDS
250 << "a::ctor::old" << std::endl
252 << "a::ctor::body" << std::endl
253 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
254 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
255 << "a::static_inv" << std::endl
257 #ifdef BOOST_CONTRACT_TEST_CV_INV
258 << "a::cv_inv" << std::endl
260 #ifdef BOOST_CONTRACT_TEST_CONST_INV
261 << "a::const_inv" << std::endl
264 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
265 << "a::ctor::post" << std::endl
268 BOOST_TEST(out.eq(ok.str()));
272 ok.str(""); ok // Volatile checks static and cv (but not const) inv.
273 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
274 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
275 << "b::static_inv" << std::endl
277 #ifdef BOOST_CONTRACT_TEST_CV_INV
278 << "b::cv_inv" << std::endl
280 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
281 << "a::static_inv" << std::endl
283 #ifdef BOOST_CONTRACT_TEST_CV_INV
284 << "a::cv_inv" << std::endl
287 #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
288 << "b::f::volatile_pre" << std::endl
289 << "a::f::volatile_pre" << std::endl
291 #ifndef BOOST_CONTRACT_NO_OLDS
292 << "b::f::volatile_old" << std::endl
293 << "a::f::volatile_old" << std::endl
295 << "a::f::volatile_body" << std::endl
296 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
297 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
298 << "b::static_inv" << std::endl
300 #ifdef BOOST_CONTRACT_TEST_CV_INV
301 << "b::cv_inv" << std::endl
303 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
304 << "a::static_inv" << std::endl
306 #ifdef BOOST_CONTRACT_TEST_CV_INV
307 << "a::cv_inv" << std::endl
310 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
311 << "b::f::volatile_old" << std::endl
312 << "b::f::volatile_post" << std::endl
313 << "a::f::volatile_post" << std::endl
316 BOOST_TEST(out.eq(ok.str()));
319 av.s(); // Test static call.
321 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
322 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
323 << "a::static_inv" << std::endl
326 #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
327 << "a::s::pre" << std::endl
329 #ifndef BOOST_CONTRACT_NO_OLDS
330 << "a::s::old" << std::endl
332 << "a::s::body" << std::endl
333 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
334 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
335 << "a::static_inv" << std::endl
338 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
339 << "a::s::post" << std::endl
342 BOOST_TEST(out.eq(ok.str()));
345 av.call_p(); // Test (indirect) protected call.
347 #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
348 << "a::p::volatile_pre" << std::endl
350 #ifndef BOOST_CONTRACT_NO_OLDS
351 << "a::p::volatile_old" << std::endl
353 << "a::p::volatile_body" << std::endl
354 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
355 << "a::p::volatile_post" << std::endl
358 BOOST_TEST(out.eq(ok.str()));
361 av.call_q(); // Test (indirect) private call.
363 #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
364 << "a::q::volatile_pre" << std::endl
366 #ifndef BOOST_CONTRACT_NO_OLDS
367 << "a::q::volatile_old" << std::endl
369 << "a::q::volatile_body" << std::endl
370 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
371 << "a::q::volatile_post" << std::endl
374 BOOST_TEST(out.eq(ok.str()));
377 } // Call a's destructor.
378 ok.str(""); ok // Dtors always check const_inv (even if volatile).
379 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
380 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
381 << "a::static_inv" << std::endl
383 #ifdef BOOST_CONTRACT_TEST_CV_INV
384 << "a::cv_inv" << std::endl
386 #ifdef BOOST_CONTRACT_TEST_CONST_INV
387 << "a::const_inv" << std::endl
390 #ifndef BOOST_CONTRACT_NO_OLDS
391 << "a::dtor::old" << std::endl
393 << "a::dtor::body" << std::endl
394 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
395 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
396 << "a::static_inv" << std::endl
399 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
400 << "a::dtor::post" << std::endl
403 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
404 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
405 << "b::static_inv" << std::endl
407 #ifdef BOOST_CONTRACT_TEST_CV_INV
408 << "b::cv_inv" << std::endl
410 #ifdef BOOST_CONTRACT_TEST_CONST_INV
411 << "b::const_inv" << std::endl
414 #ifndef BOOST_CONTRACT_NO_OLDS
415 << "b::dtor::old" << std::endl
417 << "b::dtor::body" << std::endl
418 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
419 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
420 << "b::static_inv" << std::endl
423 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
424 << "b::dtor::post" << std::endl
427 BOOST_TEST(out.eq(ok.str()));
429 { // Test non-volatile call with bases.
432 ok.str(""); ok // Ctors always check cv_inv (even if not volatile).
433 #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
434 << "a::ctor::pre" << std::endl
435 << "b::ctor::pre" << std::endl
438 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
439 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
440 << "b::static_inv" << std::endl
443 #ifndef BOOST_CONTRACT_NO_OLDS
444 << "b::ctor::old" << std::endl
446 << "b::ctor::body" << std::endl
447 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
448 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
449 << "b::static_inv" << std::endl
451 #ifdef BOOST_CONTRACT_TEST_CV_INV
452 << "b::cv_inv" << std::endl
454 #ifdef BOOST_CONTRACT_TEST_CONST_INV
455 << "b::const_inv" << std::endl
458 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
459 << "b::ctor::post" << std::endl
462 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
463 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
464 << "a::static_inv" << std::endl
467 #ifndef BOOST_CONTRACT_NO_OLDS
468 << "a::ctor::old" << std::endl
470 << "a::ctor::body" << std::endl
471 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
472 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
473 << "a::static_inv" << std::endl
475 #ifdef BOOST_CONTRACT_TEST_CV_INV
476 << "a::cv_inv" << std::endl
478 #ifdef BOOST_CONTRACT_TEST_CONST_INV
479 << "a::const_inv" << std::endl
482 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
483 << "a::ctor::post" << std::endl
486 BOOST_TEST(out.eq(ok.str()));
490 ok.str(""); ok // Non-cv checks static and const (but not cv) inv.
491 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
492 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
493 << "b::static_inv" << std::endl
495 #ifdef BOOST_CONTRACT_TEST_CONST_INV
496 << "b::const_inv" << std::endl
498 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
499 << "a::static_inv" << std::endl
501 #ifdef BOOST_CONTRACT_TEST_CONST_INV
502 << "a::const_inv" << std::endl
505 #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
506 << "b::f::pre" << std::endl
507 << "a::f::pre" << std::endl
509 #ifndef BOOST_CONTRACT_NO_OLDS
510 << "b::f::old" << std::endl
511 << "a::f::old" << std::endl
513 << "a::f::body" << std::endl
514 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
515 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
516 << "b::static_inv" << std::endl
518 #ifdef BOOST_CONTRACT_TEST_CONST_INV
519 << "b::const_inv" << std::endl
521 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
522 << "a::static_inv" << std::endl
524 #ifdef BOOST_CONTRACT_TEST_CONST_INV
525 << "a::const_inv" << std::endl
528 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
529 << "b::f::old" << std::endl
530 << "b::f::post" << std::endl
531 << "a::f::post" << std::endl
534 BOOST_TEST(out.eq(ok.str()));
537 aa.s(); // Test static call.
539 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
540 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
541 << "a::static_inv" << std::endl
544 #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
545 << "a::s::pre" << std::endl
547 #ifndef BOOST_CONTRACT_NO_OLDS
548 << "a::s::old" << std::endl
550 << "a::s::body" << std::endl
551 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
552 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
553 << "a::static_inv" << std::endl
556 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
557 << "a::s::post" << std::endl
560 BOOST_TEST(out.eq(ok.str()));
563 aa.call_p(); // Test (indirect) protected call.
565 #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
566 << "a::p::pre" << std::endl
568 #ifndef BOOST_CONTRACT_NO_OLDS
569 << "a::p::old" << std::endl
571 << "a::p::body" << std::endl
572 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
573 << "a::p::post" << std::endl
576 BOOST_TEST(out.eq(ok.str()));
579 aa.call_q(); // Test (indirect) private call.
581 #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
582 << "a::q::pre" << std::endl
584 #ifndef BOOST_CONTRACT_NO_OLDS
585 << "a::q::old" << std::endl
587 << "a::q::body" << std::endl
588 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
589 << "a::q::post" << std::endl
592 BOOST_TEST(out.eq(ok.str()));
595 } // Call a's destructor.
596 ok.str(""); ok // Dtors always check cv_inv (even if not volatile).
597 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
598 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
599 << "a::static_inv" << std::endl
601 #ifdef BOOST_CONTRACT_TEST_CV_INV
602 << "a::cv_inv" << std::endl
604 #ifdef BOOST_CONTRACT_TEST_CONST_INV
605 << "a::const_inv" << std::endl
608 #ifndef BOOST_CONTRACT_NO_OLDS
609 << "a::dtor::old" << std::endl
611 << "a::dtor::body" << std::endl
612 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
613 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
614 << "a::static_inv" << std::endl
617 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
618 << "a::dtor::post" << std::endl
621 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
622 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
623 << "b::static_inv" << std::endl
625 #ifdef BOOST_CONTRACT_TEST_CV_INV
626 << "b::cv_inv" << std::endl
628 #ifdef BOOST_CONTRACT_TEST_CONST_INV
629 << "b::const_inv" << std::endl
632 #ifndef BOOST_CONTRACT_NO_OLDS
633 << "b::dtor::old" << std::endl
635 << "b::dtor::body" << std::endl
636 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
637 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
638 << "b::static_inv" << std::endl
641 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
642 << "b::dtor::post" << std::endl
645 BOOST_TEST(out.eq(ok.str()));
648 { // Test volatile call with no bases.
651 ok.str(""); ok // Ctors always check const_inv (even if volatile).
652 #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
653 << "b::ctor::pre" << std::endl
656 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
657 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
658 << "b::static_inv" << std::endl
661 #ifndef BOOST_CONTRACT_NO_OLDS
662 << "b::ctor::old" << std::endl
664 << "b::ctor::body" << std::endl
665 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
666 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
667 << "b::static_inv" << std::endl
669 #ifdef BOOST_CONTRACT_TEST_CV_INV
670 << "b::cv_inv" << std::endl
672 #ifdef BOOST_CONTRACT_TEST_CONST_INV
673 << "b::const_inv" << std::endl
676 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
677 << "b::ctor::post" << std::endl
680 BOOST_TEST(out.eq(ok.str()));
684 ok.str(""); ok // Volatile checks static and cv (but not const) inv.
685 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
686 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
687 << "b::static_inv" << std::endl
689 #ifdef BOOST_CONTRACT_TEST_CV_INV
690 << "b::cv_inv" << std::endl
693 #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
694 << "b::f::volatile_pre" << std::endl
696 #ifndef BOOST_CONTRACT_NO_OLDS
697 << "b::f::volatile_old" << std::endl
699 << "b::f::volatile_body" << std::endl
700 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
701 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
702 << "b::static_inv" << std::endl
704 #ifdef BOOST_CONTRACT_TEST_CV_INV
705 << "b::cv_inv" << std::endl
708 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
709 << "b::f::volatile_post" << std::endl
712 BOOST_TEST(out.eq(ok.str()));
715 } // Call b's destructor.
716 ok.str(""); ok // Dtors always check const_inv (even if volatile).
717 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
718 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
719 << "b::static_inv" << std::endl
721 #ifdef BOOST_CONTRACT_TEST_CV_INV
722 << "b::cv_inv" << std::endl
724 #ifdef BOOST_CONTRACT_TEST_CONST_INV
725 << "b::const_inv" << std::endl
728 #ifndef BOOST_CONTRACT_NO_OLDS
729 << "b::dtor::old" << std::endl
731 << "b::dtor::body" << std::endl
732 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
733 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
734 << "b::static_inv" << std::endl
737 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
738 << "b::dtor::post" << std::endl
741 BOOST_TEST(out.eq(ok.str()));
743 { // Test non-volatile call with no bases.
746 ok.str(""); ok // Ctors always check cv_inv (even if not volatile).
747 #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
748 << "b::ctor::pre" << std::endl
751 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
752 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
753 << "b::static_inv" << std::endl
756 #ifndef BOOST_CONTRACT_NO_OLDS
757 << "b::ctor::old" << std::endl
759 << "b::ctor::body" << std::endl
760 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
761 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
762 << "b::static_inv" << std::endl
764 #ifdef BOOST_CONTRACT_TEST_CV_INV
765 << "b::cv_inv" << std::endl
767 #ifdef BOOST_CONTRACT_TEST_CONST_INV
768 << "b::const_inv" << std::endl
771 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
772 << "b::ctor::post" << std::endl
775 BOOST_TEST(out.eq(ok.str()));
779 ok.str(""); ok // Non-cv checks static and const (but not cv) inv.
780 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
781 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
782 << "b::static_inv" << std::endl
784 #ifdef BOOST_CONTRACT_TEST_CONST_INV
785 << "b::const_inv" << std::endl
788 #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
789 << "b::f::pre" << std::endl
791 #ifndef BOOST_CONTRACT_NO_OLDS
792 << "b::f::old" << std::endl
794 << "b::f::body" << std::endl
795 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
796 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
797 << "b::static_inv" << std::endl
799 #ifdef BOOST_CONTRACT_TEST_CONST_INV
800 << "b::const_inv" << std::endl
803 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
804 << "b::f::post" << std::endl
807 BOOST_TEST(out.eq(ok.str()));
810 } // Call b's destructor.
811 ok.str(""); ok // Dtors always check cv_inv (even if not volatile).
812 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
813 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
814 << "b::static_inv" << std::endl
816 #ifdef BOOST_CONTRACT_TEST_CV_INV
817 << "b::cv_inv" << std::endl
819 #ifdef BOOST_CONTRACT_TEST_CONST_INV
820 << "b::const_inv" << std::endl
823 #ifndef BOOST_CONTRACT_NO_OLDS
824 << "b::dtor::old" << std::endl
826 << "b::dtor::body" << std::endl
827 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
828 #ifdef BOOST_CONTRACT_TEST_STATIC_INV
829 << "b::static_inv" << std::endl
832 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
833 << "b::dtor::post" << std::endl
836 BOOST_TEST(out.eq(ok.str()));
838 return boost::report_errors();