31 TEST ( range, sequence_of_integers1 ) {
32 std::vector<unsigned> x;
34 ASSERT_EQ ( x.size(), 3 );
35 EXPECT_EQ ( x[0], 1 );
36 EXPECT_EQ ( x[1], 2 );
37 EXPECT_EQ ( x[2], 3 );
41 TEST ( range, sequence_of_integers2 ) {
42 std::vector<unsigned> x;
44 ASSERT_EQ ( x.size(), 2 );
45 EXPECT_EQ ( x[0], 1 );
46 EXPECT_EQ ( x[1], 31 );
50 TEST ( range, sequence_of_integers3 ) {
51 std::vector<unsigned> x;
53 ASSERT_EQ ( x.size(), 5 );
54 EXPECT_EQ ( x[0], 5 );
55 EXPECT_EQ ( x[1], 10 );
56 EXPECT_EQ ( x[2], 15 );
57 EXPECT_EQ ( x[3], 45 );
58 EXPECT_EQ ( x[4], 52 );
62 TEST ( range, sequence_of_floats ) {
65 ASSERT_EQ ( x.size(), 5 );
66 EXPECT_EQ ( x[0], -1.0f );
67 EXPECT_EQ ( x[1], -0.5f );
68 EXPECT_EQ ( x[2], 0.0f );
69 EXPECT_EQ ( x[3], 0.5f );
70 EXPECT_EQ ( x[4], 1.0f );
76 std::vector <float> result;
80 result.push_back ( ir.
get() );
82 ASSERT_EQ ( result.size(), 2 );
83 EXPECT_EQ ( result[0], 5.3f );
84 EXPECT_EQ ( result[1], 10.2f );
88 TEST ( range, integerrange ) {
89 std::vector<unsigned> x;
90 std::vector<unsigned> result;
94 result.push_back ( ir.
get() );
96 ASSERT_EQ ( result.size(), 2 );
97 EXPECT_EQ ( result[0], 5 );
98 EXPECT_EQ ( result[1], 10 );
102 TEST ( range, infiniterange ) {
104 EXPECT_EQ ( x.
done(), false );
105 EXPECT_EQ ( x.
get(), 5 );
107 EXPECT_EQ ( x.
get(), 6 );
109 EXPECT_EQ ( x.
get(), 7 );
115 EXPECT_EQ ( x.
done(), false );
117 EXPECT_EQ ( x.
done(), false );
118 EXPECT_EQ ( x.
get(), 5 );
120 EXPECT_EQ ( x.
get(), 5 );
121 EXPECT_EQ ( x.
done(), true );
123 EXPECT_EQ ( x.
get(), 5 );
124 EXPECT_EQ ( x.
done(), true );
126 EXPECT_EQ ( x.
done(), false );
135 int main (
int argc,
char **argv ) {
136 ::testing::InitGoogleTest ( &argc, argv );
137 return RUN_ALL_TESTS();
void next(void)
Empty implementation.
NumberType get(void)
Always returns sid_.
Implements a Range iterator that will never finish.
NumberType get(void)
Returns range value at position k_.
void start(void)
Empty implementation.
void start(void)
Empty implementation.
void next(void)
Increment index.
void next(void)
Empty implementation.
Implements a Range iterator that only runs once. This is useful e.g. for fsttools that process a batc...
Static variables for logger. Include only once from main file.
bool done(void)
return true.
bool done(void)
Checks if reached the last element.
int main(int argc, char **argv)
main function. If compiled individualy, will kickoff any tests in this file.
NumberType get(void)
Always returns sid_.
bool done(void)
Always return false.
Handles different type of integer ranges.
TEST(range, sequence_of_integers1)
Test getRange with 1:3.
void getRange(const std::string &range, std::vector< NumberType > &x)
Generates ranges from a compact string parameter such as 1,3:5,10.
Unit testing: google testing common header.
Static variable for custom_assert. Include only once from main file.