1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jsapi-tests/testHashTableInit.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,26 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#include "js/HashTable.h" 1.9 +#include "jsapi-tests/tests.h" 1.10 + 1.11 +typedef js::HashSet<uint32_t, js::DefaultHasher<uint32_t>, js::SystemAllocPolicy> IntSet; 1.12 + 1.13 +static const uint32_t MaxAllowedHashInit = 1 << 23; 1.14 + 1.15 +BEGIN_TEST(testHashInitAlmostTooHuge) 1.16 +{ 1.17 + IntSet smallEnough; 1.18 + CHECK(smallEnough.init(MaxAllowedHashInit)); 1.19 + return true; 1.20 +} 1.21 +END_TEST(testHashInitAlmostTooHuge) 1.22 + 1.23 +BEGIN_TEST(testHashInitTooHuge) 1.24 +{ 1.25 + IntSet tooBig; 1.26 + CHECK(!tooBig.init(MaxAllowedHashInit + 1)); 1.27 + return true; 1.28 +} 1.29 +END_TEST(testHashInitTooHuge)