| 1 | /* |
| 2 | * test-value.cc |
| 3 | * |
| 4 | * Created on: Aug 27, 2016 |
| 5 | * Author: m.kolny |
| 6 | */ |
| 7 | #include "mmtest.h" |
| 8 | #include <gstreamermm.h> |
| 9 | |
| 10 | TEST(ValueTest, TestDefaultRangeValue) |
| 11 | { |
| 12 | Gst::Range<Gst::Fraction> fraction_range; |
| 13 | Gst::Fraction default_fraction; |
| 14 | |
| 15 | ASSERT_EQ(default_fraction.denom, fraction_range.max.denom); |
| 16 | ASSERT_EQ(default_fraction.num, fraction_range.min.num); |
| 17 | } |
| 18 | |
| 19 | TEST(ValueTest, TestUserDefinedRangeValue) |
| 20 | { |
| 21 | Gst::Range<int> int_range(10, 20); |
| 22 | |
| 23 | ASSERT_EQ(10, int_range.min); |
| 24 | ASSERT_EQ(20, int_range.max); |
| 25 | } |
| 26 | |
| 27 | TEST(ValueTest, TestIntRangeToGValue) |
| 28 | { |
| 29 | Glib::Value<Gst::Range<int>> value; |
| 30 | value.init(Glib::Value<Gst::Range<int>>::value_type()); |
| 31 | value.set(Gst::Range<int>(8000, 50000)); |
| 32 | |
| 33 | Gst::Structure structure("my-structure"); |
| 34 | Glib::Value<int> v; |
| 35 | v.init(G_TYPE_INT); |
| 36 | v.set(12); |
| 37 | structure.set_field("rate", value); |
| 38 | |
| 39 | Glib::Value<Gst::Range<int>> gst_value; |
| 40 | structure.get_field("rate", gst_value); |
| 41 | Gst::Range<int> range(gst_value); |
| 42 | int max = range.max; |
| 43 | |
| 44 | ASSERT_EQ(max, 50000); |
| 45 | } |
| 46 |