diff options
author | ADAM David Alan Martin <adam.martin@10gen.com> | 2019-08-14 20:29:07 -0400 |
---|---|---|
committer | ADAM David Alan Martin <adam.martin@10gen.com> | 2019-08-15 04:10:23 -0400 |
commit | f78ba67112fa95a54cfe6d94c33b11e389efdc44 (patch) | |
tree | 18bd313d2787399f9664fa399050fa13b3767c4f /src/mongo/stdx | |
parent | 7eff30764a9d2137fc761e218dc2a58b6c006539 (diff) | |
download | mongo-f78ba67112fa95a54cfe6d94c33b11e389efdc44.tar.gz |
SERVER-42080 `stdx::unordered_map<...>::at` must throw.
Added a test to check that this happens.
Diffstat (limited to 'src/mongo/stdx')
-rw-r--r-- | src/mongo/stdx/SConscript | 10 | ||||
-rw-r--r-- | src/mongo/stdx/unordered_map_test.cpp | 41 |
2 files changed, 51 insertions, 0 deletions
diff --git a/src/mongo/stdx/SConscript b/src/mongo/stdx/SConscript index a51aa3423f4..f954fdf8398 100644 --- a/src/mongo/stdx/SConscript +++ b/src/mongo/stdx/SConscript @@ -13,3 +13,13 @@ env.Benchmark( ], ) + +env.CppUnitTest( + target='stdx_test', + source=[ + 'unordered_map_test.cpp' + ], + LIBDEPS=[ + '$BUILD_DIR/third_party/shim_abseil', + ], +) diff --git a/src/mongo/stdx/unordered_map_test.cpp b/src/mongo/stdx/unordered_map_test.cpp new file mode 100644 index 00000000000..daeaea61358 --- /dev/null +++ b/src/mongo/stdx/unordered_map_test.cpp @@ -0,0 +1,41 @@ +/** + * Copyright (C) 2019-present MongoDB, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the Server Side Public License, version 1, + * as published by MongoDB, Inc. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * Server Side Public License for more details. + * + * You should have received a copy of the Server Side Public License + * along with this program. If not, see + * <http://www.mongodb.com/licensing/server-side-public-license>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the Server Side Public License in all respects for + * all of the code used other than as permitted herein. If you modify file(s) + * with this exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. If you delete this + * exception statement from all source files in the program, then also delete + * it in the license file. + */ + +#include "mongo/stdx/unordered_map.h" + +#include <stdexcept> + +#include "mongo/unittest/unittest.h" + +namespace { +TEST(StdxUnorderedMapTest, atShouldThrow) { + mongo::stdx::unordered_map<int, int> m; + ASSERT_THROWS(m.at(42), std::out_of_range); +} +} // namespace |