1 // Copyright 2020 The Pigweed Authors
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
7 // https://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
15 #include "pw_assert/light.h"
17 #include "gtest/gtest.h"
18 #include "pw_assert/assert.h"
20 // PW_ASSERT() should always be enabled, and always evaluate the expression.
21 TEST(Light, AssertTrue) {
23 PW_ASSERT(++evaluated);
24 EXPECT_EQ(evaluated, 2);
27 // PW_DASSERT() might be disabled sometimes.
28 TEST(Light, DebugAssertTrue) {
30 PW_DASSERT(++evaluated);
31 if (PW_ASSERT_ENABLE_DEBUG == 1) {
32 EXPECT_EQ(evaluated, 2);
34 EXPECT_EQ(evaluated, 1);
38 // Unfortunately, we don't have the infrastructure to test failure handling
39 // automatically, since the harness crashes in the process of running this
40 // test. The unsatisfying alternative is to test the functionality manually,
41 // then disable the test.
43 TEST(Light, AssertFalse) {
49 TEST(Light, DebugAssertFalse) {