diff options
author | jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com> | 2021-03-19 11:49:38 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-19 11:49:38 -0700 |
commit | 5792e5c529756e3569ca43e635995ec2eed365a9 (patch) | |
tree | 8042d83a26879cfd44e8b4924c80ac297aa0733f /infra/cifuzz/test_data/external-project/my_api.cpp | |
parent | 2b4af8f24ab41d57dc2a33c6e3b63f016f35fe7a (diff) | |
download | oss-fuzz-5792e5c529756e3569ca43e635995ec2eed365a9.tar.gz |
[NFC][CIFuzz] Rename test_files to test_data and delete unneeded testcases directory (#5448)
Diffstat (limited to 'infra/cifuzz/test_data/external-project/my_api.cpp')
-rw-r--r-- | infra/cifuzz/test_data/external-project/my_api.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/infra/cifuzz/test_data/external-project/my_api.cpp b/infra/cifuzz/test_data/external-project/my_api.cpp new file mode 100644 index 000000000..9a2c1bc1c --- /dev/null +++ b/infra/cifuzz/test_data/external-project/my_api.cpp @@ -0,0 +1,36 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Implementation of "my_api". +#include "my_api.h" + +#include <vector> + +// Do some computations with 'str', return the result. +// This function contains a bug. Can you spot it? +size_t DoStuff(const std::string &str) { + std::vector<int> Vec({0, 1, 2, 3, 4}); + size_t Idx = 0; + if (str.size() > 5) + Idx++; + if (str.find("foo") != std::string::npos) + Idx++; + if (str.find("bar") != std::string::npos) + Idx++; + if (str.find("ouch") != std::string::npos) + Idx++; + if (str.find("omg") != std::string::npos) + Idx++; + return Vec[Idx]; +} |