From 0f895b0684200e206392a2f1aef1f3e7136d1071 Mon Sep 17 00:00:00 2001 From: Andrzej Kotulski Date: Fri, 27 May 2016 09:23:38 -0700 Subject: [PATCH] Improve empty vector tests Summary: Now all code in tests is reachable by the analyzer which increases test quality. Reviewed By: dulmarod Differential Revision: D3358591 fbshipit-source-id: d54877e --- .../codetoanalyze/cpp/errors/vector/empty_access.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/infer/tests/codetoanalyze/cpp/errors/vector/empty_access.cpp b/infer/tests/codetoanalyze/cpp/errors/vector/empty_access.cpp index 3113c9a34..eaebf90a3 100644 --- a/infer/tests/codetoanalyze/cpp/errors/vector/empty_access.cpp +++ b/infer/tests/codetoanalyze/cpp/errors/vector/empty_access.cpp @@ -69,32 +69,28 @@ int assign_nonempty() { return vec2[0]; } -int empty_check_nonempty() { - std::vector vec; +int empty_check_nonempty(std::vector& vec) { if (vec.empty()) { return 1; } return vec[0]; } -int empty_check_nonempty2() { - std::vector vec; +int empty_check_nonempty2(std::vector& vec) { if (vec.empty()) { vec.push_back(1); } return vec[0]; } -int empty_check_access_empty() { - std::vector vec; +int empty_check_access_empty(std::vector& vec) { if (vec.empty()) { return vec[0]; } return 1; } -int size_check0_empty() { - std::vector vec; +int size_check0_empty(std::vector& vec) { if (vec.size() == 0) { return vec[0]; }