SIGN IN SIGN UP
PaddlePaddle / Paddle UNCLAIMED

PArallel Distributed Deep LEarning: Machine Learning Framework from Industrial Practice (『飞桨』核心框架,深度学习&机器学习高性能单机、分布式训练和跨平台部署)

0 0 11 C++
2018-02-12 18:48:00 +08:00
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.
2017-12-26 11:08:29 +08:00
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
2017-12-26 11:08:29 +08:00
http://www.apache.org/licenses/LICENSE-2.0
2017-12-26 11:08:29 +08:00
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 "paddle/utils/string/to_string.h"
#include <gtest/gtest.h>
constexpr char kOutputString[] = "User Defined Output"; // NOLINT
class UserDefinedClass {
public:
};
std::ostream& operator<<(std::ostream& s, const UserDefinedClass& ins) {
2017-08-09 14:29:24 +08:00
s << kOutputString;
return s;
}
TEST(to_string, normal) {
using paddle::string::to_string;
2017-08-09 14:14:47 +08:00
ASSERT_EQ("10", to_string(10));
ASSERT_EQ("abc", to_string("abc"));
2017-08-09 14:14:47 +08:00
ASSERT_EQ("1.2", to_string(1.2));
}
TEST(to_string, user_defined) {
UserDefinedClass instance;
ASSERT_EQ(kOutputString, paddle::string::to_string(instance));
}