You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
670 B

// Copyright 2017 Google Inc. All Rights Reserved.
// Licensed under the Apache License, Version 2.0 (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];
}