Codemod: use #include angle brackets in folly and thrift
[folly.git] / folly / test / function_benchmark / test_functions.cpp
index 932ac59bf22587ffe869013ccfa5e259c7705475..d5c4ddd4998fb346ae3068d27173bc534a9bfb7a 100644 (file)
@@ -1,14 +1,75 @@
-// Copyright 2004-present Facebook.  All rights reserved.
-#include "folly/test/function_benchmark/test_functions.h"
+/*
+ * Copyright 2014 Facebook, Inc.
+ *
+ * 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.
+ */
+
+#include <folly/test/function_benchmark/test_functions.h>
 
 /*
  * These functions are defined in a separate file so that
  * gcc won't be able to inline them.
  */
 
+
+class Exception : public std::exception {
+ public:
+  explicit Exception(const std::string& value) : value_(value) {}
+  virtual ~Exception(void) throw() {}
+
+  virtual const char *what(void) const throw() {
+    return value_.c_str();
+  }
+
+ private:
+  std::string value_;
+};
+
 void doNothing() {
 }
 
+void throwException() {
+  throw Exception("this is a test");
+}
+
+std::exception_ptr returnExceptionPtr() {
+  Exception ex("this is a test");
+  return std::make_exception_ptr(ex);
+}
+
+void exceptionPtrReturnParam(std::exception_ptr* excReturn) {
+  if (excReturn) {
+    Exception ex("this is a test");
+    *excReturn = std::make_exception_ptr(ex);
+  }
+}
+
+std::string returnString() {
+  return "this is a test";
+}
+
+std::string returnStringNoExcept() noexcept {
+  return "this is a test";
+}
+
+int returnCode(int value) {
+  return value;
+}
+
+int returnCodeNoExcept(int value) noexcept {
+  return value;
+}
+
 void TestClass::doNothing() {
 }