assimp/test/unit/utNoBoostTest.cpp

73 lines
2.2 KiB
C++
Raw Normal View History

2015-05-19 04:24:07 +00:00
#include "UnitTestPCH.h"
#include "BoostWorkaround/boost/tuple/tuple.hpp"
#define ASSIMP_FORCE_NOBOOST
#include "BoostWorkaround/boost/format.hpp"
using namespace std;
using namespace Assimp;
using boost::format;
using boost::str;
// ------------------------------------------------------------------------------------------------
TEST(NoBoostTest, testFormat)
{
2015-05-19 04:26:05 +00:00
EXPECT_EQ( "Ahoi!", boost::str( boost::format("Ahoi!") ));
EXPECT_EQ( "Ahoi! %", boost::str( boost::format("Ahoi! %%") ));
EXPECT_EQ( "Ahoi! ", boost::str( boost::format("Ahoi! %s") ));
EXPECT_EQ( "Ahoi! !!", boost::str( boost::format("Ahoi! %s") % "!!" ));
EXPECT_EQ( "Ahoi! !!", boost::str( boost::format("Ahoi! %s") % "!!" % "!!" ));
EXPECT_EQ( "abc", boost::str( boost::format("%s%s%s") % "a" % std::string("b") % "c" ));
2015-05-19 04:24:07 +00:00
}
struct another
{
2015-05-19 04:26:05 +00:00
int dummy;
2015-05-19 04:24:07 +00:00
};
// ------------------------------------------------------------------------------------------------
TEST(NoBoostTest, Tuple) {
2015-05-19 04:26:05 +00:00
// Implicit conversion
boost::tuple<unsigned,unsigned,unsigned> first = boost::make_tuple(4,4,4);
EXPECT_EQ(4U, first.get<0>());
EXPECT_EQ(4U, first.get<1>());
EXPECT_EQ(4U, first.get<2>());
2015-05-19 04:24:07 +00:00
boost::tuple<int, float, double, bool, another> second;
2015-05-19 04:26:05 +00:00
bool b = second.get<3>();
2015-05-19 04:24:07 +00:00
// check empty tuple
2015-05-19 04:26:05 +00:00
boost::tuple<> third;
third;
2015-05-19 04:24:07 +00:00
2015-05-19 04:26:05 +00:00
// FIXME: Explicit conversion not really required yet
boost::tuple<float,float,float> last =
(boost::tuple<float,float,float>)boost::make_tuple(1.,2.,3.);
EXPECT_EQ(1.f, last.get<0>());
EXPECT_EQ(2.f, last.get<1>());
EXPECT_EQ(3.f, last.get<2>());
2015-05-19 04:24:07 +00:00
2015-05-19 04:26:05 +00:00
// Non-const access
first.get<0>() = 1;
first.get<1>() = 2;
first.get<2>() = 3;
EXPECT_EQ(1U, first.get<0>());
EXPECT_EQ(2U, first.get<1>());
EXPECT_EQ(3U, first.get<2>());
2015-05-19 04:24:07 +00:00
2015-05-19 04:26:05 +00:00
// Const cases
const boost::tuple<unsigned,unsigned,unsigned> constant = boost::make_tuple(5,5,5);
first.get<0>() = constant.get<0>();
EXPECT_EQ(5U, constant.get<0>());
EXPECT_EQ(5U, first.get<0>());
2015-05-19 04:24:07 +00:00
2015-05-19 04:26:05 +00:00
// Direct assignment w. explicit conversion
last = first;
EXPECT_EQ(5.f, last.get<0>());
EXPECT_EQ(2.f, last.get<1>());
EXPECT_EQ(3.f, last.get<2>());
2015-05-19 04:24:07 +00:00
}