PageRenderTime 82ms CodeModel.GetById 40ms app.highlight 2ms RepoModel.GetById 38ms app.codeStats 0ms

/mordor/tests/util.cpp

http://github.com/mozy/mordor
C++ | 23 lines | 14 code | 7 blank | 2 comment | 0 complexity | 1fdc0302301e164d476adcbfc19c010f MD5 | raw file
 1// Copyright (c) 2009 - Mozy, Inc.
 2
 3#include <boost/bind.hpp>
 4
 5#include "mordor/util.h"
 6#include "mordor/test/test.h"
 7
 8using namespace Mordor;
 9using namespace Mordor::Test;
10
11
12MORDOR_UNITTEST(Util, muldiv64)
13{
14    MORDOR_TEST_ASSERT_EQUAL(muldiv64(0, 1, 1), 0ULL);
15    MORDOR_TEST_ASSERT_EQUAL(muldiv64(1, 0, 2), 0ULL);
16    MORDOR_TEST_ASSERT_EQUAL(muldiv64(1, 2, 3), 0ULL);
17    MORDOR_TEST_ASSERT_EQUAL(muldiv64(3, 2, 1), 6ULL);
18    MORDOR_TEST_ASSERT_EQUAL(muldiv64(43849324ULL, 11289432, 65463), 7562042093ULL);
19
20    // this computation would overflow without muldiv64()
21    MORDOR_TEST_ASSERT_EQUAL(muldiv64(0x1111111111111111ULL, 5000000, 1000000), 0x5555555555555555ULL);
22
23}