[cluttermm] Updates test-interval-creation to use make_check.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cluttermm] Updates test-interval-creation to use make_check.
- Date: Fri, 14 Mar 2014 09:04:33 +0000 (UTC)
commit 3693ae2739445b624dc8e752619fe4e82a483cd2
Author: Ian Martin <martin_id vodafone co nz>
Date: Fri Mar 14 17:51:50 2014 +1300
Updates test-interval-creation to use make_check.
Adds a meaningful return value, allowing make_check to return some information if the tests fail.
tests/test-interval-creation.cc | 51 +++++++++++++++++++++++++++++++-------
1 files changed, 41 insertions(+), 10 deletions(-)
---
diff --git a/tests/test-interval-creation.cc b/tests/test-interval-creation.cc
index 965fec8..ce12da9 100644
--- a/tests/test-interval-creation.cc
+++ b/tests/test-interval-creation.cc
@@ -6,7 +6,11 @@ int main(int argc, char** argv)
// initialize the C++ wrapper types
Clutter::init(&argc, &argv);
- std::cout << "Creating Clutter::Interval with (int) values: 10, 20" << std::endl;
+ //a return value to allow make check to output a useful summary:
+ int errorval(0);
+
+ int int_a(10);
+ int int_b(20);
Glib::RefPtr<Clutter::Interval> interval1 = Clutter::Interval::create(10, 20);
Glib::Value<int> initial1, final1, compute1;
@@ -15,20 +19,36 @@ int main(int argc, char** argv)
compute1.init(compute1.value_type());
interval1->get_interval(initial1, final1);
- std::cout << "Getting values from created interval: " << initial1.get() << ", " << final1.get() <<
std::endl;
+ if( (int(initial1.get()) != int_a) || ( int(final1.get()) != int_b) )
+ {
+ errorval++;
+ std::cout << "Getting incorrect values from created interval: " <<
+ initial1.get() << ", " << final1.get() << std::endl;
+
+ }
interval1->compute_value(0.5, compute1);
- std::cout << "Computing a value with factor = 0.5: " << compute1.get() << std::endl << std::endl;
+ std::cout << "Computing a value with factor = 0.5: " <<
+ compute1.get() << std::endl << std::endl;
+ if( compute1.get() != (int_a + int_b ) /2 )
+ {
+ std::cout << "Computing incorrect value with factor = 0.5: " <<
+ compute1.get() << std::endl << std::endl;
+ errorval += 10;
+ }
+ double dub_a(10.35);
+ double dub_b(20.73);
Glib::Value<double> initial2, final2, compute2;
initial2.init(initial2.value_type());
final2.init(final2.value_type());
compute2.init(compute2.value_type());
- initial2.set(10.35);
- final2.set(20.73);
+ initial2.set(dub_a);
+ final2.set(dub_b);
- std::cout << "Creating Clutter::Interval with Glib::Value<double> values: " << initial2.get() << ", " <<
final2.get() << std::endl;
+ std::cout << "Creating Clutter::Interval with Glib::Value<double> values: " <<
+ initial2.get() << ", " << final2.get() << std::endl;
Glib::RefPtr<Clutter::Interval> interval2 = Clutter::Interval::create_with_values(initial2, final2);
@@ -36,10 +56,21 @@ int main(int argc, char** argv)
final2.reset();
interval2->get_interval(initial2, final2);
- std::cout << "Getting values from created interval: " << initial2.get() << ", " << final2.get() <<
std::endl;
+ if( ( dub_a != initial2.get() ) || ( dub_b != final2.get() ) )
+ {
+ std::cout << "Getting incorrect values from created interval: " <<
+ initial2.get() << ", " << final2.get() << std::endl;
+ errorval += 100;
+ }
+
+ interval2->compute_value( 0.7, compute2 );
+ double compval = dub_a + ( ( dub_b - dub_a ) /2 );
+ if( compute2.get() != compval )
+ {
+ std::cout << "Error computing a value with factor = 0.7: " << compute2.get() << "; correct value is "<<
compval << std::endl;
+ errorval += 1000;
+ }
- interval2->compute_value(0.7, compute2);
- std::cout << "Computing a value with factor = 0.7: " << compute2.get() << std::endl;
+ return errorval;
- return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]