]>
git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/third_party/ms-gsl/tests/assertion_tests.cpp
1 ///////////////////////////////////////////////////////////////////////////////
3 // Copyright (c) 2015 Microsoft Corporation. All rights reserved.
5 // This code is licensed under the MIT License (MIT).
7 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
8 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
10 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
11 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
12 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
15 ///////////////////////////////////////////////////////////////////////////////
17 #include <gtest/gtest.h>
18 #include <gsl/gsl_assert> // for fail_fast (ptr only), Ensures, Expects
24 static constexpr char deathstring
[] = "Expected Death";
28 Expects(i
> 0 && i
< 10);
35 Ensures(i
> 0 && i
< 10);
40 TEST(assertion_tests
, expects
)
42 std::set_terminate([] {
43 std::cerr
<< "Expected Death. expects";
47 EXPECT_TRUE(f(2) == 2);
48 EXPECT_DEATH(f(10), deathstring
);
52 TEST(assertion_tests
, ensures
)
54 std::set_terminate([] {
55 std::cerr
<< "Expected Death. ensures";
59 EXPECT_TRUE(g(2) == 3);
60 EXPECT_DEATH(g(9), deathstring
);