|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r65608 - sandbox/opaque/libs/opaque/test
From: vicente.botet_at_[hidden]
Date: 2010-09-26 10:48:21
Author: viboes
Date: 2010-09-26 10:48:20 EDT (Sun, 26 Sep 2010)
New Revision: 65608
URL: http://svn.boost.org/trac/boost/changeset/65608
Log:
Opaque: Check explicit conversion from private OT to UT
make uniform test on public and private opaque
Text files modified:
sandbox/opaque/libs/opaque/test/private_opaque_test.cpp | 60 ++++++++++++++--------------
sandbox/opaque/libs/opaque/test/public_opaque_test.cpp | 85 ++++++++++++++++++++++++++++++++-------
2 files changed, 99 insertions(+), 46 deletions(-)
Modified: sandbox/opaque/libs/opaque/test/private_opaque_test.cpp
==============================================================================
--- sandbox/opaque/libs/opaque/test/private_opaque_test.cpp (original)
+++ sandbox/opaque/libs/opaque/test/private_opaque_test.cpp 2010-09-26 10:48:20 EDT (Sun, 26 Sep 2010)
@@ -20,63 +20,63 @@
BOOST_OPAQUE_PRIVATE_TYPEDEF(unsigned,private_unsigned);
BOOST_OPAQUE_PRIVATE_TYPEDEF(unsigned,private_unsigned2);
-void private_assign_test() {
+void assign_test() {
private_unsigned a, a2;
private_unsigned2 b;
//~ a=b; // error
a=a2; // OK
- //~ unsigned i;
-
- //~ i=opaque_static_cast<unsigned>(a);
- //~ i=a; // error
-
- //~ i=b; // error
- //~ a=i; // error
- //~ b=i; // error
+ unsigned i;
+#if !defined(BOOST_NO_EXPLICIT_CONVERSION_OPERATORS)
+ // explicit conversion from OT to UT
+ i=unsigned(a);
+ //error: `OT' used where a `UT' was expected
+#else
+ i=a.underlying();
+#endif
}
-void private_eq_test() {
+void eq_test() {
private_unsigned a(1), b(2), c(2);
BOOST_CHECK(b==c);
BOOST_CHECK((a==b)==false);
}
-void private_neq_test() {
+void neq_test() {
private_unsigned a(1), b(2), c(2);
BOOST_CHECK(a!=b);
BOOST_CHECK((b!=c)==false);
}
-void private_lt_test() {
+void lt_test() {
private_unsigned a(1), b(2), c(2);
BOOST_CHECK(a<b);
BOOST_CHECK((b<a)==false);
BOOST_CHECK((b<c)==false);
}
-void private_gt_test() {
+void gt_test() {
private_unsigned a(1), b(2), c(2);
BOOST_CHECK(b>a);
BOOST_CHECK((a>b)==false);
BOOST_CHECK((b>c)==false);
}
-void private_le_test() {
+void le_test() {
private_unsigned a(1), b(2), c(2);
BOOST_CHECK(a<=b);
BOOST_CHECK((b<=a)==false);
BOOST_CHECK(b<=c);
}
-void private_ge_test() {
+void ge_test() {
private_unsigned a(1), b(2), c(2);
BOOST_CHECK(b>=a);
BOOST_CHECK((a>=b)==false);
BOOST_CHECK(b>=c);
}
-void private_add_test() {
+void add_test() {
private_unsigned a(1), b(2), c(3),d(4);
BOOST_CHECK(a+b==c);
BOOST_CHECK(c==a+b);
@@ -84,7 +84,7 @@
BOOST_CHECK((d==a+b)==false);
}
-void private_substract_test() {
+void substract_test() {
private_unsigned a(1), b(2), c(3),d(4);
BOOST_CHECK(c-b==a);
BOOST_CHECK(a==c-b);
@@ -92,7 +92,7 @@
BOOST_CHECK((d==c-b)==false);
}
-void private_multiply_test() {
+void multiply_test() {
private_unsigned a(1), b(2), c(3),d(6);
BOOST_CHECK(b*c==d);
BOOST_CHECK(b==a*b);
@@ -100,7 +100,7 @@
BOOST_CHECK((d==a*b)==false);
}
-void private_divide_test() {
+void divide_test() {
private_unsigned a(1), b(2), c(3),d(6);
BOOST_CHECK(d/c==b);
BOOST_CHECK(b==d/c);
@@ -138,17 +138,17 @@
test_suite* test = BOOST_TEST_SUITE("private");
- test->add(BOOST_TEST_CASE(&private_assign_test));
- test->add(BOOST_TEST_CASE(&private_eq_test));
- test->add(BOOST_TEST_CASE(&private_neq_test));
- test->add(BOOST_TEST_CASE(&private_lt_test));
- test->add(BOOST_TEST_CASE(&private_gt_test));
- test->add(BOOST_TEST_CASE(&private_le_test));
- test->add(BOOST_TEST_CASE(&private_ge_test));
- test->add(BOOST_TEST_CASE(&private_add_test));
- test->add(BOOST_TEST_CASE(&private_substract_test));
- test->add(BOOST_TEST_CASE(&private_multiply_test));
- test->add(BOOST_TEST_CASE(&private_divide_test));
+ test->add(BOOST_TEST_CASE(&assign_test));
+ test->add(BOOST_TEST_CASE(&eq_test));
+ test->add(BOOST_TEST_CASE(&neq_test));
+ test->add(BOOST_TEST_CASE(<_test));
+ test->add(BOOST_TEST_CASE(>_test));
+ test->add(BOOST_TEST_CASE(&le_test));
+ test->add(BOOST_TEST_CASE(&ge_test));
+ test->add(BOOST_TEST_CASE(&add_test));
+ test->add(BOOST_TEST_CASE(&substract_test));
+ test->add(BOOST_TEST_CASE(&multiply_test));
+ test->add(BOOST_TEST_CASE(÷_test));
test->add(BOOST_TEST_CASE(&unariy_plus_test));
test->add(BOOST_TEST_CASE(&unariy_minus_test));
test->add(BOOST_TEST_CASE(&pre_increment_test));
Modified: sandbox/opaque/libs/opaque/test/public_opaque_test.cpp
==============================================================================
--- sandbox/opaque/libs/opaque/test/public_opaque_test.cpp (original)
+++ sandbox/opaque/libs/opaque/test/public_opaque_test.cpp 2010-09-26 10:48:20 EDT (Sun, 26 Sep 2010)
@@ -19,7 +19,7 @@
BOOST_OPAQUE_PUBLIC_TYPEDEF(unsigned,public_unsigned);
BOOST_OPAQUE_PUBLIC_TYPEDEF(unsigned,public_unsigned2);
-void public_assign_test() {
+void assign_test() {
public_unsigned a, a2;
public_unsigned2 b;
@@ -34,7 +34,7 @@
//~ b=i; // error
}
-void public_eq_test() {
+void eq_test() {
public_unsigned a(1), b(2), c(2);
BOOST_CHECK(b==c);
BOOST_CHECK((a==b)==false);
@@ -47,34 +47,41 @@
BOOST_CHECK((v==a)==false);
}
-void public_lt_test() {
+void neq_test() {
+ public_unsigned a(1), b(2), c(2);
+ BOOST_CHECK(a!=b);
+ BOOST_CHECK((b!=c)==false);
+}
+
+
+void lt_test() {
public_unsigned a(1), b(2), c(2);
BOOST_CHECK(a<b);
BOOST_CHECK((b<a)==false);
BOOST_CHECK((b<c)==false);
}
-void public_gt_test() {
+void gt_test() {
public_unsigned a(1), b(2), c(2);
BOOST_CHECK(b>a);
BOOST_CHECK((a>b)==false);
BOOST_CHECK((b>c)==false);
}
-void public_le_test() {
+void le_test() {
public_unsigned a(1), b(2), c(2);
BOOST_CHECK(a<=b);
BOOST_CHECK((b<=a)==false);
BOOST_CHECK(b<=c);
}
-void public_ge_test() {
+void ge_test() {
public_unsigned a(1), b(2), c(2);
BOOST_CHECK(b>=a);
BOOST_CHECK((a>=b)==false);
BOOST_CHECK(b>=c);
}
-void public_add_test() {
+void add_test() {
public_unsigned a(1), b(2), c(3),d(4);
BOOST_CHECK(a+b==c);
BOOST_CHECK(c==a+b);
@@ -93,7 +100,7 @@
}
-void public_substract_test() {
+void substract_test() {
public_unsigned a(1), b(2), c(3),d(4);
BOOST_CHECK(c-b==a);
BOOST_CHECK(a==c-b);
@@ -109,19 +116,65 @@
}
+void multiply_test() {
+ public_unsigned a(1), b(2), c(3),d(6);
+ BOOST_CHECK(b*c==d);
+ BOOST_CHECK(b==a*b);
+ BOOST_CHECK((b*c==a)==false);
+ BOOST_CHECK((d==a*b)==false);
+}
+
+void divide_test() {
+ public_unsigned a(1), b(2), c(3),d(6);
+ BOOST_CHECK(d/c==b);
+ BOOST_CHECK(b==d/c);
+ BOOST_CHECK((d/c==a)==false);
+ BOOST_CHECK((a==d/c)==false);
+}
+
+
+void unariy_plus_test() {
+ public_unsigned a(1);
+ BOOST_CHECK(+a==a);
+}
+
+void unariy_minus_test() {
+ public_unsigned a(1);
+ BOOST_CHECK(-a==public_unsigned(-1));
+}
+
+void pre_increment_test() {
+ public_unsigned a(1);
+ public_unsigned b(2);
+ BOOST_CHECK(++a==b);
+}
+
+void post_increment_test() {
+ public_unsigned a(1);
+ public_unsigned b(1);
+ BOOST_CHECK(a++==b);
+ BOOST_CHECK(a==public_unsigned(2));
+}
test_suite* init_unit_test_suite(int, char*[])
{
test_suite* test = BOOST_TEST_SUITE("public");
- test->add(BOOST_TEST_CASE(&public_assign_test));
- test->add(BOOST_TEST_CASE(&public_eq_test));
- test->add(BOOST_TEST_CASE(&public_lt_test));
- test->add(BOOST_TEST_CASE(&public_gt_test));
- test->add(BOOST_TEST_CASE(&public_le_test));
- test->add(BOOST_TEST_CASE(&public_ge_test));
- test->add(BOOST_TEST_CASE(&public_add_test));
- test->add(BOOST_TEST_CASE(&public_substract_test));
+ test->add(BOOST_TEST_CASE(&assign_test));
+ test->add(BOOST_TEST_CASE(&eq_test));
+ test->add(BOOST_TEST_CASE(&neq_test));
+ test->add(BOOST_TEST_CASE(<_test));
+ test->add(BOOST_TEST_CASE(>_test));
+ test->add(BOOST_TEST_CASE(&le_test));
+ test->add(BOOST_TEST_CASE(&ge_test));
+ test->add(BOOST_TEST_CASE(&add_test));
+ test->add(BOOST_TEST_CASE(&substract_test));
+ test->add(BOOST_TEST_CASE(&multiply_test));
+ test->add(BOOST_TEST_CASE(÷_test));
+ test->add(BOOST_TEST_CASE(&unariy_plus_test));
+ test->add(BOOST_TEST_CASE(&unariy_minus_test));
+ test->add(BOOST_TEST_CASE(&pre_increment_test));
+ test->add(BOOST_TEST_CASE(&post_increment_test));
return test;
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk