code format

This commit is contained in:
keita
2021-03-05 11:31:44 +09:00
parent 9aa3fe1c9a
commit dcb2565df6
10 changed files with 49 additions and 47 deletions
+2 -1
View File
@@ -13,7 +13,8 @@ void Create::id(const std::string& _id) {
CocoaTweet::API::Model::Tweet Create::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) { CocoaTweet::API::Model::Tweet Create::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) {
CocoaTweet::API::Model::Tweet tweet; CocoaTweet::API::Model::Tweet tweet;
HttpPost::process(_oauth, [&tweet](const unsigned int _responseCode, const std::string& _rcv) { HttpPost::process(_oauth,
[&tweet](const unsigned int _responseCode, const std::string& _rcv) {
tweet = CocoaTweet::API::Model::Tweet(_responseCode, _rcv); tweet = CocoaTweet::API::Model::Tweet(_responseCode, _rcv);
}); });
+4 -2
View File
@@ -11,9 +11,11 @@ void Destroy::id(const std::string& _id) {
bodyParam_.insert_or_assign("id", _id); bodyParam_.insert_or_assign("id", _id);
} }
CocoaTweet::API::Model::Tweet Destroy::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) { CocoaTweet::API::Model::Tweet Destroy::process(
std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) {
CocoaTweet::API::Model::Tweet tweet; CocoaTweet::API::Model::Tweet tweet;
HttpPost::process(_oauth, [&tweet](const unsigned int _responseCode, const std::string& _rcv) { HttpPost::process(_oauth,
[&tweet](const unsigned int _responseCode, const std::string& _rcv) {
tweet = CocoaTweet::API::Model::Tweet(_responseCode, _rcv); tweet = CocoaTweet::API::Model::Tweet(_responseCode, _rcv);
}); });
+7 -7
View File
@@ -21,13 +21,13 @@ Tweet Tweet::parse(const unsigned int _responseCode, const std::string& _json) {
auto message = j["errors"][0]["message"]; auto message = j["errors"][0]["message"];
if (error.get<int>() == 144) { if (error.get<int>() == 144) {
throw CocoaTweet::Exception::TweetNotFoundException(message.get<std::string>().c_str()); throw CocoaTweet::Exception::TweetNotFoundException(message.get<std::string>().c_str());
}else if(error.get<int>() == 32){ } else if (error.get<int>() == 32) {
throw CocoaTweet::Exception::AuthenticateException(message.get<std::string>().c_str()); throw CocoaTweet::Exception::AuthenticateException(message.get<std::string>().c_str());
}else if(error.get<int>() == 187){ } else if (error.get<int>() == 187) {
throw CocoaTweet::Exception::TweetDuplicateException(message.get<std::string>().c_str()); throw CocoaTweet::Exception::TweetDuplicateException(message.get<std::string>().c_str());
}else if(error.get<int>() == 88 || error.get<int>() == 185){ } else if (error.get<int>() == 88 || error.get<int>() == 185) {
throw CocoaTweet::Exception::RateLimitException(message.get<std::string>().c_str()); throw CocoaTweet::Exception::RateLimitException(message.get<std::string>().c_str());
}else if(error.get<int>() == 186){ } else if (error.get<int>() == 186) {
throw CocoaTweet::Exception::TweetTooLongException(message.get<std::string>().c_str()); throw CocoaTweet::Exception::TweetTooLongException(message.get<std::string>().c_str());
} }
} }
@@ -39,14 +39,14 @@ void Tweet::id(const std::string _id) {
id_ = _id; id_ = _id;
} }
void Tweet::createdAt(const std::string _at){ void Tweet::createdAt(const std::string _at) {
createdAt_ = _at; createdAt_ = _at;
} }
void Tweet::text(const std::string _text){ void Tweet::text(const std::string _text) {
text_ = _text; text_ = _text;
} }
void Tweet::source(const std::string _source){ void Tweet::source(const std::string _source) {
source_ = _source; source_ = _source;
} }
-2
View File
@@ -25,8 +25,6 @@ private:
std::string createdAt_; std::string createdAt_;
std::string text_; std::string text_;
std::string source_; std::string source_;
}; };
} // namespace CocoaTweet::API::Model } // namespace CocoaTweet::API::Model
+1 -5
View File
@@ -11,11 +11,7 @@ class Key {
const std::string accessTokenSecret_; const std::string accessTokenSecret_;
public: public:
Key() Key() : consumerKey_(""), consumerSecret_(""), accessToken_(""), accessTokenSecret_("") {}
: consumerKey_(""),
consumerSecret_(""),
accessToken_(""),
accessTokenSecret_("") {}
Key(const std::string& _consumerKey, const std::string& _consumerSecret, Key(const std::string& _consumerKey, const std::string& _consumerSecret,
const std::string& _accessToken, const std::string& _accessTokenSecret) const std::string& _accessToken, const std::string& _accessTokenSecret)
: consumerKey_(_consumerKey), : consumerKey_(_consumerKey),
+10 -5
View File
@@ -42,7 +42,8 @@ BOOST_AUTO_TEST_CASE(test03) {
}] }]
})"; })";
BOOST_CHECK_THROW(CocoaTweet::API::Model::Tweet(401, json), CocoaTweet::Exception::AuthenticateException); BOOST_CHECK_THROW(CocoaTweet::API::Model::Tweet(401, json),
CocoaTweet::Exception::AuthenticateException);
} }
BOOST_AUTO_TEST_CASE(test04) { BOOST_AUTO_TEST_CASE(test04) {
@@ -53,7 +54,8 @@ BOOST_AUTO_TEST_CASE(test04) {
}] }]
})"; })";
BOOST_CHECK_THROW(CocoaTweet::API::Model::Tweet(429, json), CocoaTweet::Exception::RateLimitException); BOOST_CHECK_THROW(CocoaTweet::API::Model::Tweet(429, json),
CocoaTweet::Exception::RateLimitException);
} }
BOOST_AUTO_TEST_CASE(test05) { BOOST_AUTO_TEST_CASE(test05) {
@@ -64,7 +66,8 @@ BOOST_AUTO_TEST_CASE(test05) {
}] }]
})"; })";
BOOST_CHECK_THROW(CocoaTweet::API::Model::Tweet(403, json), CocoaTweet::Exception::RateLimitException); BOOST_CHECK_THROW(CocoaTweet::API::Model::Tweet(403, json),
CocoaTweet::Exception::RateLimitException);
} }
BOOST_AUTO_TEST_CASE(test06) { BOOST_AUTO_TEST_CASE(test06) {
@@ -75,7 +78,8 @@ BOOST_AUTO_TEST_CASE(test06) {
}] }]
})"; })";
BOOST_CHECK_THROW(CocoaTweet::API::Model::Tweet(403, json), CocoaTweet::Exception::TweetTooLongException); BOOST_CHECK_THROW(CocoaTweet::API::Model::Tweet(403, json),
CocoaTweet::Exception::TweetTooLongException);
} }
BOOST_AUTO_TEST_CASE(test07) { BOOST_AUTO_TEST_CASE(test07) {
@@ -86,6 +90,7 @@ BOOST_AUTO_TEST_CASE(test07) {
}] }]
})"; })";
BOOST_CHECK_THROW(CocoaTweet::API::Model::Tweet(403, json), CocoaTweet::Exception::TweetDuplicateException); BOOST_CHECK_THROW(CocoaTweet::API::Model::Tweet(403, json),
CocoaTweet::Exception::TweetDuplicateException);
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()
+2 -2
View File
@@ -15,7 +15,8 @@ BOOST_AUTO_TEST_CASE(test01) {
} }
BOOST_AUTO_TEST_CASE(test02) { BOOST_AUTO_TEST_CASE(test02) {
CocoaTweet::OAuth::Key key("consumerKey", "consumerSecret", "accessToken", "accessTokenSecret"); CocoaTweet::OAuth::Key key("consumerKey", "consumerSecret", "accessToken",
"accessTokenSecret");
BOOST_TEST(key.consumerKey() == "consumerKey"); BOOST_TEST(key.consumerKey() == "consumerKey");
BOOST_TEST(key.consumerSecret() == "consumerSecret"); BOOST_TEST(key.consumerSecret() == "consumerSecret");
@@ -31,5 +32,4 @@ BOOST_AUTO_TEST_CASE(test02) {
BOOST_TEST(secret.at("oauth_token") == "accessTokenSecret"); BOOST_TEST(secret.at("oauth_token") == "accessTokenSecret");
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()