mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
646c78a9d0
- Bug 1143130 - Initialize nsIFrame::ContentOffsets members, and some additional cleanup. r=roc (334109d125)
- Bug 1185436 - Mark DumpFrameTree() and DumpFrameTreeLimited() const. r=roc (f444841ce7)
- Bug 1163328 - Tests for mozilla::Tuple. r=froydnj (9bdf4a67eb)
- Bug 1184385 - Add a Tie() utility function for tuples (the equivalent of std::tie()) to MFBT. r=froydnj (a683a079e7)
- Bug 1186315 - Fix TestTuple error and add it into testing list. r=nfroyd (8ea986d022)
- Bug 1185706 - support Tie() for mozilla::Pair. r=froydnj (2a74853496)
- Bug 1186126 - Note incompatibility with NSPR printf-like functions. r=nfroyd (eb3aa88cd3)
- Bug 1188895 - Replace U+0A00 with U+0200 in MacroForEach.h. r=Ms2ger (e63d0be26f)
- Bug 1182370 - _BitScan* does not modify *pIndex if input is zero. - r=waldo (3c1280da48)
- Bug 1193600 - Add Clamp and IsPowerOfTwo to MFBT. - r=waldo (7e5e321a74)
- Bug 1139036 - Bind all symbols from libmozglue.dylib when it is loaded. r=ted (c948da5c6d)
- bug 1198226 - Add HOST_{CFLAGS,CXXFLAGS,DEFINES} support to mozbuild frontend+recursive make backend. r=mshal (c5558cbf4c)
- bug 1198226 - Move HOST_{C,CXX}FLAGS to moz.build HOST_{CFLAGS,CXXFLAGS,DEFINES}. r=mshal (031909f24a)
- bug 1198226 - Add HOST_{C,CXX}FLAGS recursive make varible blacklist. r=mshal (c808385c2f)
- Bug 1204134 (attempt 2) - Fix and disallow warnings in config/moz.build. r=glandium. (e1a21ccade)
- code style (374f57dbea)
- Bug 1184284 - Remove txToRemove warning from nsSHistory::RemoveDuplicate. r=smaug (14f02229d5)
- Bug 1203379 - Fix indentation of gfxWordCacheTest.cpp. r=jrmuizel. (c04b07ce17)
- Bug 1203427 (part 1) - Add nsExpirationTracker::mName. r=froydnj. (974b39f117)
- Bug 1203427 (part 2) - Remove an argument to nsTimeout::InitTimer. r=mccr8. (f6f196c26c)
- Bug 1203809 - pass textperf obj into gfxFontGroup constructor. r=m_kato (1ea2f5cfd2)
- Bug 1203427 (part 3) - Change order of InitCommon() arguments. r=froydnj. (07e6c9b5ca)
- Bug 1203427 (part 4) - Remove trailing whitespace from nsITimer.idl. r=froydnj. (df4473f30a)
- Bug 1186112 - Get rid of the #define'd constants in BMPFileHeaders.h. r=tn (c18103f391)
88 lines
3.3 KiB
C++
88 lines
3.3 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "mozilla/MathAlgorithms.h"
|
|
|
|
using mozilla::Clamp;
|
|
using mozilla::IsPowerOfTwo;
|
|
|
|
static void
|
|
TestClamp()
|
|
{
|
|
MOZ_RELEASE_ASSERT(Clamp(0, 0, 0) == 0);
|
|
MOZ_RELEASE_ASSERT(Clamp(1, 0, 0) == 0);
|
|
MOZ_RELEASE_ASSERT(Clamp(-1, 0, 0) == 0);
|
|
|
|
MOZ_RELEASE_ASSERT(Clamp(0, 1, 1) == 1);
|
|
MOZ_RELEASE_ASSERT(Clamp(0, 1, 2) == 1);
|
|
|
|
MOZ_RELEASE_ASSERT(Clamp(0, -1, -1) == -1);
|
|
MOZ_RELEASE_ASSERT(Clamp(0, -2, -1) == -1);
|
|
|
|
MOZ_RELEASE_ASSERT(Clamp(0, 1, 3) == 1);
|
|
MOZ_RELEASE_ASSERT(Clamp(1, 1, 3) == 1);
|
|
MOZ_RELEASE_ASSERT(Clamp(2, 1, 3) == 2);
|
|
MOZ_RELEASE_ASSERT(Clamp(3, 1, 3) == 3);
|
|
MOZ_RELEASE_ASSERT(Clamp(4, 1, 3) == 3);
|
|
MOZ_RELEASE_ASSERT(Clamp(5, 1, 3) == 3);
|
|
|
|
MOZ_RELEASE_ASSERT(Clamp<uint8_t>(UINT8_MAX, 0, UINT8_MAX) == UINT8_MAX);
|
|
MOZ_RELEASE_ASSERT(Clamp<uint8_t>(0, 0, UINT8_MAX) == 0);
|
|
|
|
MOZ_RELEASE_ASSERT(Clamp<int8_t>(INT8_MIN, INT8_MIN, INT8_MAX) == INT8_MIN);
|
|
MOZ_RELEASE_ASSERT(Clamp<int8_t>(INT8_MIN, 0, INT8_MAX) == 0);
|
|
MOZ_RELEASE_ASSERT(Clamp<int8_t>(INT8_MAX, INT8_MIN, INT8_MAX) == INT8_MAX);
|
|
MOZ_RELEASE_ASSERT(Clamp<int8_t>(INT8_MAX, INT8_MIN, 0) == 0);
|
|
}
|
|
|
|
static void
|
|
TestIsPowerOfTwo()
|
|
{
|
|
MOZ_RELEASE_ASSERT(!IsPowerOfTwo(0u));
|
|
MOZ_RELEASE_ASSERT( IsPowerOfTwo(1u));
|
|
MOZ_RELEASE_ASSERT( IsPowerOfTwo(2u));
|
|
MOZ_RELEASE_ASSERT(!IsPowerOfTwo(3u));
|
|
MOZ_RELEASE_ASSERT( IsPowerOfTwo(4u));
|
|
MOZ_RELEASE_ASSERT(!IsPowerOfTwo(5u));
|
|
MOZ_RELEASE_ASSERT(!IsPowerOfTwo(6u));
|
|
MOZ_RELEASE_ASSERT(!IsPowerOfTwo(7u));
|
|
MOZ_RELEASE_ASSERT( IsPowerOfTwo(8u));
|
|
MOZ_RELEASE_ASSERT(!IsPowerOfTwo(9u));
|
|
|
|
MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint8_t(UINT8_MAX/2))); // 127, 0x7f
|
|
MOZ_RELEASE_ASSERT( IsPowerOfTwo(uint8_t(UINT8_MAX/2 + 1))); // 128, 0x80
|
|
MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint8_t(UINT8_MAX/2 + 2))); // 129, 0x81
|
|
MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint8_t(UINT8_MAX - 1))); // 254, 0xfe
|
|
MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint8_t(UINT8_MAX))); // 255, 0xff
|
|
|
|
MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint16_t(UINT16_MAX/2))); // 0x7fff
|
|
MOZ_RELEASE_ASSERT( IsPowerOfTwo(uint16_t(UINT16_MAX/2 + 1))); // 0x8000
|
|
MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint16_t(UINT16_MAX/2 + 2))); // 0x8001
|
|
MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint16_t(UINT16_MAX - 1))); // 0xfffe
|
|
MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint16_t(UINT16_MAX))); // 0xffff
|
|
|
|
MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint32_t(UINT32_MAX/2)));
|
|
MOZ_RELEASE_ASSERT( IsPowerOfTwo(uint32_t(UINT32_MAX/2 + 1)));
|
|
MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint32_t(UINT32_MAX/2 + 2)));
|
|
MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint32_t(UINT32_MAX - 1)));
|
|
MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint32_t(UINT32_MAX)));
|
|
|
|
MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint64_t(UINT64_MAX/2)));
|
|
MOZ_RELEASE_ASSERT( IsPowerOfTwo(uint64_t(UINT64_MAX/2 + 1)));
|
|
MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint64_t(UINT64_MAX/2 + 2)));
|
|
MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint64_t(UINT64_MAX - 1)));
|
|
MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint64_t(UINT64_MAX)));
|
|
}
|
|
|
|
int
|
|
main()
|
|
{
|
|
TestIsPowerOfTwo();
|
|
TestClamp();
|
|
|
|
return 0;
|
|
}
|