Fixed overflow warning in unit test on 32-bit compile

release/4.3a0
Richard Roberts 2013-12-17 11:36:50 -05:00
parent 2553e39746
commit 2d14896497
1 changed files with 22 additions and 17 deletions

View File

@ -36,28 +36,33 @@ TEST(Key, KeySymbolConversion) {
EXPECT(assert_equal(original, actual)) EXPECT(assert_equal(original, actual))
} }
/* ************************************************************************* */
template<int KeySize>
Key KeyTestValue();
template<>
Key KeyTestValue<8>()
{
return 0x6100000000000005;
};
template<>
Key KeyTestValue<4>()
{
return 0x61000005;
};
/* ************************************************************************* */ /* ************************************************************************* */
TEST(Key, KeySymbolEncoding) { TEST(Key, KeySymbolEncoding) {
// Test encoding of Symbol <-> size_t <-> string // Test encoding of Symbol <-> size_t <-> string
if(sizeof(Key) == 8) {
Symbol symbol(0x61, 5); Symbol symbol(0x61, 5);
Key key = 0x6100000000000005; Key key = KeyTestValue<sizeof(Key)>();
string str = "a5"; string str = "a5";
EXPECT_LONGS_EQUAL((long)key, (long)(Key)symbol); EXPECT_LONGS_EQUAL((long)key, (long)(Key)symbol);
EXPECT(assert_equal(str, DefaultKeyFormatter(symbol))); EXPECT(assert_equal(str, DefaultKeyFormatter(symbol)));
EXPECT(assert_equal(symbol, Symbol(key))); EXPECT(assert_equal(symbol, Symbol(key)));
} else if(sizeof(Key) == 4) {
Symbol symbol(0x61, 5);
Key key = 0x61000005;
string str = "a5";
EXPECT_LONGS_EQUAL((long)key, (long)(Key)symbol);
EXPECT(assert_equal(str, DefaultKeyFormatter(symbol)));
EXPECT(assert_equal(symbol, Symbol(key)));
}
} }
/* ************************************************************************* */ /* ************************************************************************* */