From dcb2565df6c1d429bade99667313a23bbae53548 Mon Sep 17 00:00:00 2001 From: keita Date: Fri, 5 Mar 2021 11:31:44 +0900 Subject: [PATCH] code format --- src/cocoatweet/api/favorite/create.cc | 9 +++++---- src/cocoatweet/api/favorite/create.h | 2 +- src/cocoatweet/api/favorite/destroy.cc | 12 +++++++----- src/cocoatweet/api/favorite/destroy.h | 2 +- src/cocoatweet/api/favorite/favorite.h | 4 ++-- src/cocoatweet/api/model/tweet.cc | 20 ++++++++++---------- src/cocoatweet/api/model/tweet.h | 20 +++++++++----------- src/cocoatweet/oauth/key.h | 6 +----- test/api/model/tweet.cc | 15 ++++++++++----- test/oauth/key.cc | 6 +++--- 10 files changed, 49 insertions(+), 47 deletions(-) diff --git a/src/cocoatweet/api/favorite/create.cc b/src/cocoatweet/api/favorite/create.cc index 7ecb523..a181e1a 100644 --- a/src/cocoatweet/api/favorite/create.cc +++ b/src/cocoatweet/api/favorite/create.cc @@ -13,10 +13,11 @@ void Create::id(const std::string& _id) { CocoaTweet::API::Model::Tweet Create::process(std::weak_ptr _oauth) { CocoaTweet::API::Model::Tweet tweet; - HttpPost::process(_oauth, [&tweet](const unsigned int _responseCode, const std::string& _rcv) { - tweet = CocoaTweet::API::Model::Tweet(_responseCode, _rcv); - }); + HttpPost::process(_oauth, + [&tweet](const unsigned int _responseCode, const std::string& _rcv) { + tweet = CocoaTweet::API::Model::Tweet(_responseCode, _rcv); + }); - return tweet; + return tweet; } } // namespace CocoaTweet::API::Favorites diff --git a/src/cocoatweet/api/favorite/create.h b/src/cocoatweet/api/favorite/create.h index a8f7388..58e6c88 100644 --- a/src/cocoatweet/api/favorite/create.h +++ b/src/cocoatweet/api/favorite/create.h @@ -9,7 +9,7 @@ class Create : public CocoaTweet::API::Interface::HttpPost { public: Create(); void id(const std::string& _id); - CocoaTweet::API::Model::Tweet process(std::weak_ptr _oauth); + CocoaTweet::API::Model::Tweet process(std::weak_ptr _oauth); private: }; diff --git a/src/cocoatweet/api/favorite/destroy.cc b/src/cocoatweet/api/favorite/destroy.cc index e26ae0b..126eac6 100644 --- a/src/cocoatweet/api/favorite/destroy.cc +++ b/src/cocoatweet/api/favorite/destroy.cc @@ -11,12 +11,14 @@ void Destroy::id(const std::string& _id) { bodyParam_.insert_or_assign("id", _id); } -CocoaTweet::API::Model::Tweet Destroy::process(std::weak_ptr _oauth) { +CocoaTweet::API::Model::Tweet Destroy::process( + std::weak_ptr _oauth) { CocoaTweet::API::Model::Tweet tweet; - HttpPost::process(_oauth, [&tweet](const unsigned int _responseCode, const std::string& _rcv) { - tweet = CocoaTweet::API::Model::Tweet(_responseCode, _rcv); - }); + HttpPost::process(_oauth, + [&tweet](const unsigned int _responseCode, const std::string& _rcv) { + tweet = CocoaTweet::API::Model::Tweet(_responseCode, _rcv); + }); - return tweet; + return tweet; } } // namespace CocoaTweet::API::Favorites diff --git a/src/cocoatweet/api/favorite/destroy.h b/src/cocoatweet/api/favorite/destroy.h index 719a22b..5515375 100644 --- a/src/cocoatweet/api/favorite/destroy.h +++ b/src/cocoatweet/api/favorite/destroy.h @@ -9,7 +9,7 @@ class Destroy : public CocoaTweet::API::Interface::HttpPost { public: Destroy(); void id(const std::string& _id); - CocoaTweet::API::Model::Tweet process(std::weak_ptr _oauth); + CocoaTweet::API::Model::Tweet process(std::weak_ptr _oauth); private: }; diff --git a/src/cocoatweet/api/favorite/favorite.h b/src/cocoatweet/api/favorite/favorite.h index 1f6ed6c..b79544a 100644 --- a/src/cocoatweet/api/favorite/favorite.h +++ b/src/cocoatweet/api/favorite/favorite.h @@ -10,8 +10,8 @@ class Favorite : public groupInterface { public: Favorite() = default; Favorite(std::shared_ptr _oauth); - CocoaTweet::API::Model::Tweet Create(const std::string& _id) const; - CocoaTweet::API::Model::Tweet Destroy(const std::string& _id) const; + CocoaTweet::API::Model::Tweet Create(const std::string& _id) const; + CocoaTweet::API::Model::Tweet Destroy(const std::string& _id) const; }; } // namespace CocoaTweet::API::Favorites diff --git a/src/cocoatweet/api/model/tweet.cc b/src/cocoatweet/api/model/tweet.cc index 0f617ce..3bf3fb7 100644 --- a/src/cocoatweet/api/model/tweet.cc +++ b/src/cocoatweet/api/model/tweet.cc @@ -13,21 +13,21 @@ Tweet Tweet::parse(const unsigned int _responseCode, const std::string& _json) { if (_responseCode == 200) { tweet.id(j["id_str"]); - tweet.createdAt(j["created_at"]); - tweet.text(j["text"]); - tweet.source(j["source"]); + tweet.createdAt(j["created_at"]); + tweet.text(j["text"]); + tweet.source(j["source"]); } else { auto error = j["errors"][0]["code"]; auto message = j["errors"][0]["message"]; if (error.get() == 144) { throw CocoaTweet::Exception::TweetNotFoundException(message.get().c_str()); - }else if(error.get() == 32){ + } else if (error.get() == 32) { throw CocoaTweet::Exception::AuthenticateException(message.get().c_str()); - }else if(error.get() == 187){ + } else if (error.get() == 187) { throw CocoaTweet::Exception::TweetDuplicateException(message.get().c_str()); - }else if(error.get() == 88 || error.get() == 185){ + } else if (error.get() == 88 || error.get() == 185) { throw CocoaTweet::Exception::RateLimitException(message.get().c_str()); - }else if(error.get() == 186){ + } else if (error.get() == 186) { throw CocoaTweet::Exception::TweetTooLongException(message.get().c_str()); } } @@ -39,14 +39,14 @@ void Tweet::id(const std::string _id) { id_ = _id; } -void Tweet::createdAt(const std::string _at){ +void Tweet::createdAt(const std::string _at) { createdAt_ = _at; } -void Tweet::text(const std::string _text){ +void Tweet::text(const std::string _text) { text_ = _text; } -void Tweet::source(const std::string _source){ +void Tweet::source(const std::string _source) { source_ = _source; } diff --git a/src/cocoatweet/api/model/tweet.h b/src/cocoatweet/api/model/tweet.h index 0be1cbd..ca80b95 100644 --- a/src/cocoatweet/api/model/tweet.h +++ b/src/cocoatweet/api/model/tweet.h @@ -12,21 +12,19 @@ public: : Tweet(Tweet::parse(_responseCode, _json)) {} static Tweet parse(const unsigned int _responseCode, const std::string& _json); void id(const std::string _id); - void createdAt(const std::string _at); - void text(const std::string _text); - void source(const std::string _source); + void createdAt(const std::string _at); + void text(const std::string _text); + void source(const std::string _source); const std::string id() const; - const std::string createdAt() const; - const std::string text() const; - const std::string source() const; + const std::string createdAt() const; + const std::string text() const; + const std::string source() const; private: std::string id_; - std::string createdAt_; - std::string text_; - std::string source_; - - + std::string createdAt_; + std::string text_; + std::string source_; }; } // namespace CocoaTweet::API::Model diff --git a/src/cocoatweet/oauth/key.h b/src/cocoatweet/oauth/key.h index 07aba49..71828e4 100644 --- a/src/cocoatweet/oauth/key.h +++ b/src/cocoatweet/oauth/key.h @@ -11,11 +11,7 @@ class Key { const std::string accessTokenSecret_; public: - Key() - : consumerKey_(""), - consumerSecret_(""), - accessToken_(""), - accessTokenSecret_("") {} + Key() : consumerKey_(""), consumerSecret_(""), accessToken_(""), accessTokenSecret_("") {} Key(const std::string& _consumerKey, const std::string& _consumerSecret, const std::string& _accessToken, const std::string& _accessTokenSecret) : consumerKey_(_consumerKey), diff --git a/test/api/model/tweet.cc b/test/api/model/tweet.cc index 82ea605..c7450c7 100644 --- a/test/api/model/tweet.cc +++ b/test/api/model/tweet.cc @@ -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) { @@ -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) { @@ -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) { @@ -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) { @@ -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() diff --git a/test/oauth/key.cc b/test/oauth/key.cc index c5bd0c7..f03b2b8 100644 --- a/test/oauth/key.cc +++ b/test/oauth/key.cc @@ -6,7 +6,7 @@ BOOST_AUTO_TEST_SUITE(oauth_key) BOOST_AUTO_TEST_CASE(test01) { - CocoaTweet::OAuth::Key key; + CocoaTweet::OAuth::Key key; BOOST_TEST(key.consumerKey() == ""); BOOST_TEST(key.consumerSecret() == ""); @@ -15,7 +15,8 @@ BOOST_AUTO_TEST_CASE(test01) { } 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.consumerSecret() == "consumerSecret"); @@ -31,5 +32,4 @@ BOOST_AUTO_TEST_CASE(test02) { BOOST_TEST(secret.at("oauth_token") == "accessTokenSecret"); } - BOOST_AUTO_TEST_SUITE_END()