blob: de0b316fe0c66a3403f3975642dca7d7a3d02081 [file] [log] [blame]
Luca Versari99fddff2022-05-25 10:22:32 -07001// Part of the Crubit project, under the Apache License v2.0 with LLVM
2// Exceptions. See /LICENSE for license information.
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5// Tests for various types of expressions.
6
7#include "gmock/gmock.h"
8#include "gtest/gtest.h"
9#include "lifetime_analysis/test/lifetime_analysis_test.h"
10
11namespace clang {
12namespace tidy {
13namespace lifetimes {
14namespace {
15
16TEST_F(LifetimeAnalysisTest, IncrementAndDecrement) {
17 EXPECT_THAT(GetLifetimes(R"(
18 int* prefix_inc(int* p) {
19 return ++p;
20 }
21 int* prefix_dec(int* p) {
22 return --p;
23 }
24 int* postfix_inc(int* p) {
25 return p++;
26 }
27 int* postfix_dec(int* p) {
28 return p--;
29 }
30 )"),
31 LifetimesAre({{"prefix_inc", "a -> a"},
32 {"prefix_dec", "a -> a"},
33 {"postfix_inc", "a -> a"},
34 {"postfix_dec", "a -> a"}}));
35}
36
37} // namespace
38} // namespace lifetimes
39} // namespace tidy
40} // namespace clang