PageRenderTime 92ms CodeModel.GetById 40ms app.highlight 3ms RepoModel.GetById 37ms app.codeStats 0ms

/mordor/tests/endian.cpp

http://github.com/mozy/mordor
C++ | 20 lines | 15 code | 4 blank | 1 comment | 0 complexity | 6120f614af93a4a51a67dd66db60c2e3 MD5 | raw file
 1// Copyright (c) 2010 - Mozy, Inc.
 2
 3#include "mordor/endian.h"
 4#include "mordor/test/test.h"
 5
 6using namespace Mordor;
 7
 8MORDOR_UNITTEST(Endian, endian)
 9{
10    MORDOR_TEST_ASSERT_EQUAL(byteswap((unsigned short)0x0123u), 0x2301u);
11    MORDOR_TEST_ASSERT_EQUAL(byteswap(0x01234567u), 0x67452301u);
12    MORDOR_TEST_ASSERT_EQUAL(byteswap(0x0123456789abcdefull), 0xefcdab8967452301ull);
13
14    MORDOR_TEST_ASSERT_EQUAL(byteswap((unsigned short)0x0123u),
15        byteswapOnLittleEndian(byteswapOnBigEndian((unsigned short)0x0123u)));
16    MORDOR_TEST_ASSERT_EQUAL(byteswap(0x01234567u),
17        byteswapOnLittleEndian(byteswapOnBigEndian(0x01234567u)));
18    MORDOR_TEST_ASSERT_EQUAL(byteswap(0x0123456789abcdefull),
19        byteswapOnLittleEndian(byteswapOnBigEndian(0x0123456789abcdefull)));
20}