PageRenderTime 59ms CodeModel.GetById 19ms RepoModel.GetById 1ms 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
Possible License(s): BSD-3-Clause
  1. // Copyright (c) 2009 - Mozy, Inc.
  2. #include <boost/bind.hpp>
  3. #include "mordor/util.h"
  4. #include "mordor/test/test.h"
  5. using namespace Mordor;
  6. using namespace Mordor::Test;
  7. MORDOR_UNITTEST(Util, muldiv64)
  8. {
  9. MORDOR_TEST_ASSERT_EQUAL(muldiv64(0, 1, 1), 0ULL);
  10. MORDOR_TEST_ASSERT_EQUAL(muldiv64(1, 0, 2), 0ULL);
  11. MORDOR_TEST_ASSERT_EQUAL(muldiv64(1, 2, 3), 0ULL);
  12. MORDOR_TEST_ASSERT_EQUAL(muldiv64(3, 2, 1), 6ULL);
  13. MORDOR_TEST_ASSERT_EQUAL(muldiv64(43849324ULL, 11289432, 65463), 7562042093ULL);
  14. // this computation would overflow without muldiv64()
  15. MORDOR_TEST_ASSERT_EQUAL(muldiv64(0x1111111111111111ULL, 5000000, 1000000), 0x5555555555555555ULL);
  16. }