class Z4 {
public:
Z4() : m_Value(0) {}
explicit Z4(int x) : m_Value(x > 0 ? (x & 3) : ((-x) & 3)) {}
bool operator==(
const Z4& rhs)
const {
return m_Value == rhs.m_Value; }
bool operator!=(
const Z4& rhs)
const {
return m_Value != rhs.m_Value; }
Z4& operator+=(const Z4& rhs) {
m_Value = (m_Value + rhs.m_Value) & 3;
return *this;
}
int value() const { return m_Value; }
Z4& operator++() {
m_Value = (m_Value + 1) & 3;
return *this;
}
private:
int m_Value;
};
str << "Z4(" << data.value() << ")";
return str;
}
Z4 result(lhs);
result += rhs;
return result;
}
class Q4 {
public:
enum ValueType {
ONE = 0,
I = 1,
J = 2,
K = 3,
MINUS_ONE = 4,
MINUS_I = 5,
MINUS_J = 6,
MINUS_K = 7
};
Q4() : m_Value(ONE) {}
explicit Q4(int x) : m_Value(static_cast<ValueType>(x > 0 ? x % 8 : -x % 8)) {}
bool operator==(
const Q4& rhs)
const {
return m_Value == rhs.m_Value; }
bool operator!=(
const Q4& rhs)
const {
return m_Value != rhs.m_Value; }
Q4& operator+=(const Q4& rhs);
ValueType value() const { return m_Value; }
Q4& operator++() {
m_Value = static_cast<ValueType>((m_Value + 1) % 8);
return *this;
}
private:
ValueType m_Value;
};
Q4& Q4::operator+=(const Q4& rhs) {
static const ValueType table[8][8] = {{ONE, I, J, K, MINUS_ONE, MINUS_I, MINUS_J, MINUS_K},
{I, MINUS_ONE, K, MINUS_J, MINUS_I, ONE, MINUS_K, J},
{J, MINUS_K, MINUS_ONE, I, MINUS_J, K, ONE, MINUS_I},
{K, J, MINUS_I, MINUS_ONE, MINUS_K, MINUS_J, I, ONE},
{MINUS_ONE, MINUS_I, MINUS_J, MINUS_K, ONE, I, J, K},
{MINUS_I, ONE, MINUS_K, J, I, MINUS_ONE, K, MINUS_J},
{MINUS_J, K, ONE, MINUS_I, J, MINUS_K, MINUS_ONE, I},
{MINUS_K, MINUS_J, I, ONE, K, J, MINUS_I, MINUS_ONE}};
m_Value = table[m_Value][rhs.m_Value];
return *this;
}
switch (data.value()) {
case Q4::ONE:
str << "1";
break;
case Q4::I:
str << "i";
break;
case Q4::J:
str << "j";
break;
case Q4::K:
str << "k";
break;
case Q4::MINUS_ONE:
str << "-1";
break;
case Q4::MINUS_I:
str << "-i";
break;
case Q4::MINUS_J:
str << "-j";
break;
case Q4::MINUS_K:
str << "-k";
break;
default:
str << "ERROR";
break;
}
return str;
}
Q4 result(lhs);
result += rhs;
return result;
}
template <class T>
class GroupTest : public ::testing::Test {
public:
};
typedef ::testing::Types<Z4, Q4, unsigned char> MyTypes;
TypeParam x = TypeParam();
TypeParam y = TypeParam(x);
x = y;
TypeParam z = x;
++z;
}
TypeParam e = TypeParam();
TypeParam a = TypeParam();
TypeParam b = TypeParam();
TypeParam c = TypeParam();
do {
do {
do {
ASSERT_EQ(a + (b + c), (a + b) + c) <<
"a = " << a <<
", "
<< "b = " << b << ", "
<< "c = " << c;
++c;
} while (e != c);
++b;
} while (e != b);
++a;
} while (e != a);
}
TypeParam e = TypeParam();
TypeParam a = TypeParam();
do {
++a;
} while (e != a);
}
TypeParam e = TypeParam();
TypeParam a = TypeParam();
do {
bool success = false;
TypeParam b = TypeParam();
do {
if (e == a + b) {
success = true;
break;
}
} while (e != b);
} while (e != a);
}
NLIB_PATHMAPPER_FORSAMPLE
bool SampleMain(int argc, char** argv) {
InitPathMapperForSample();
char path[512];
char buf[512];
size_t count;
g_PathMapper.ResolvePath(&count, path, "nlibpath:///readwrite/param_type.xml");
::testing::GTEST_FLAG(output) = buf;
}
NLIB_MAINFUNC