Comments (2)
Ah, never mind. figured it out. One of the tests needs exception support built in.
Fixed my build file and now all tests pass:
❯ bazel test "@frozen//:all_tests" //third_party/cc/test:frozen_test
INFO: Analyzed 11 targets (0 packages loaded, 0 targets configured).
INFO: Found 11 test targets...
INFO: Elapsed time: 0.172s, Critical Path: 0.00s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
//third_party/cc/test:frozen_test (cached) PASSED in 0.3s
@frozen//:algorithms_test (cached) PASSED in 1.2s
@frozen//:map_test (cached) PASSED in 1.2s
@frozen//:rand_test (cached) PASSED in 1.1s
@frozen//:set_test (cached) PASSED in 1.1s
@frozen//:str_set_test (cached) PASSED in 1.1s
@frozen//:str_test (cached) PASSED in 1.1s
@frozen//:unordered_map_str_test (cached) PASSED in 1.2s
@frozen//:unordered_map_test (cached) PASSED in 1.1s
@frozen//:unordered_set_test (cached) PASSED in 1.1s
@frozen//:unordered_str_set_test (cached) PASSED in 1.2s
INFO: Build completed successfully, 1 total action
Updated build file for anybody who needs it:
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
licenses(["notice"]) # Apache 2.0
exports_files(["LICENSE"])
FROZEN_HEADERS = [
"include/frozen/algorithm.h",
"include/frozen/bits/algorithms.h",
"include/frozen/bits/basic_types.h",
"include/frozen/bits/constexpr_assert.h",
"include/frozen/bits/elsa.h",
"include/frozen/bits/exceptions.h",
"include/frozen/bits/pmh.h",
"include/frozen/bits/version.h",
"include/frozen/map.h",
"include/frozen/random.h",
"include/frozen/set.h",
"include/frozen/string.h",
"include/frozen/unordered_map.h",
"include/frozen/unordered_set.h",
]
FROZEN_COPTS = [
"-O3",
"-funroll-loops",
]
# Build frozen both with and without exceptions
cc_library(
name = "frozen",
hdrs = FROZEN_HEADERS,
copts = FROZEN_COPTS,
defines = [
"FROZEN_NO_EXCEPTIONS",
],
includes = [
"include",
],
linkstatic = True,
visibility = ["//visibility:public"],
)
cc_library(
name = "frozen_with_exceptions",
hdrs = FROZEN_HEADERS,
copts = FROZEN_COPTS,
includes = [
"include",
],
linkstatic = True,
visibility = ["//visibility:public"],
)
test_suite(
name = "all_tests",
tests = [
":algorithms_test",
":map_test",
":rand_test",
":set_test",
":str_set_test",
":str_test",
# Bazel can't run CTest. Implemented our own death test using googletest.
# See: frozen_test.cc
# ":unordered_map_no_exceptions_test",
":unordered_map_str_test",
":unordered_map_test",
":unordered_set_test",
":unordered_str_set_test",
],
visibility = ["//visibility:public"],
)
cc_library(
name = "test_runner",
srcs = [
"tests/test_main.cpp",
],
hdrs = [
"tests/bench.hpp",
"tests/catch.hpp",
],
)
# cc_test(
# name = "unordered_map_no_exceptions_test",
# size = "small",
# srcs = [
# "tests/no_exceptions.cpp",
# ],
# visibility = ["//visibility:public"],
# deps = [
# ":frozen",
# # ":test_runner",
# ],
# )
cc_test(
name = "algorithms_test",
size = "small",
srcs = [
"tests/test_algorithms.cpp",
],
visibility = ["//visibility:public"],
deps = [
":frozen",
":test_runner",
],
)
cc_test(
name = "map_test",
size = "small",
srcs = [
"tests/test_map.cpp",
],
visibility = ["//visibility:public"],
deps = [
":frozen",
":test_runner",
],
)
cc_test(
name = "rand_test",
size = "small",
srcs = [
"tests/test_rand.cpp",
],
visibility = ["//visibility:public"],
deps = [
":frozen",
":test_runner",
],
)
cc_test(
name = "set_test",
size = "small",
srcs = [
"tests/test_set.cpp",
],
visibility = ["//visibility:public"],
deps = [
":frozen",
":test_runner",
],
)
cc_test(
name = "str_test",
size = "small",
srcs = [
"tests/test_str.cpp",
],
visibility = ["//visibility:public"],
deps = [
":frozen",
":test_runner",
],
)
cc_test(
name = "str_set_test",
size = "small",
srcs = [
"tests/test_str_set.cpp",
],
visibility = ["//visibility:public"],
deps = [
":frozen",
":test_runner",
],
)
cc_test(
name = "unordered_map_test",
size = "small",
srcs = [
"tests/test_unordered_map.cpp",
],
visibility = ["//visibility:public"],
deps = [
":frozen_with_exceptions",
":test_runner",
],
)
cc_test(
name = "unordered_map_str_test",
size = "small",
srcs = [
"tests/test_unordered_map_str.cpp",
],
visibility = ["//visibility:public"],
deps = [
":frozen",
":test_runner",
],
)
cc_test(
name = "unordered_set_test",
size = "small",
srcs = [
"tests/test_unordered_set.cpp",
],
visibility = ["//visibility:public"],
deps = [
":frozen",
":test_runner",
],
)
cc_test(
name = "unordered_str_set_test",
size = "small",
srcs = [
"tests/test_unordered_str_set.cpp",
],
visibility = ["//visibility:public"],
deps = [
":frozen",
":test_runner",
],
)
Implemented a death test separately for my repository:
cc_test(
name = "frozen_test",
size = "small",
srcs = ["frozen_test.cc"],
visibility = ["//visibility:public"],
deps = [
"@com_google_googletest//:gtest_main",
"@frozen",
],
)
frozen_test.cc
:
#include "frozen/unordered_map.h"
#include "gtest/gtest.h"
TEST(FrozenTest, OurFrozenIsBuiltWithoutExceptions) {
constexpr frozen::unordered_map<int, int, 1> map{{1, 4}};
ASSERT_DEATH(map.at(3), "");
}
Thank you for an awesome library.
Please feel free to close the bug.
from frozen.
I'd welcome the patch for the death test, feel free to propose a PR for it!
from frozen.
Related Issues (20)
- frozen::unordered_multiset? HOT 1
- Compilation errors in VS 2019 HOT 7
- include/frozen/map.h:114:12: error: binding reference of type 'int' to value of type 'const int' drops 'const' qualifier HOT 2
- Error when compiling the examples in the released version 1.0.0 HOT 2
- Support for std::array? HOT 2
- Warning concerning a missing constexpr HOT 3
- [Windows][VS][MSVC] Compilation failed - min / max macros HOT 2
- Add map/set final() method? HOT 5
- Status of cvector and carray
- Building tests fail because of incompatible catch2 version. HOT 1
- How to create a string key at runtime? HOT 5
- Frozen bimap? HOT 2
- Frozen constexpr map AVL tree ?
- Test compilation error HOT 5
- map::at() may return incorrect item HOT 1
- What are extended versions of `unordered_map::find`/`at` are for? HOT 1
- test_unordered_set.cpp failed to be built with gcc 12.2.0 HOT 4
- test_unordered_map.cpp: error: modification of 'ze_map' is not a constant expression; error: non-constant condition for static assertion HOT 2
- Cannot find frozen with `find_package(frozen REQUIRED)`
- CTAD issue using frozen::map HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from frozen.