{"action":"created","issue":{"url":"https://api.github.com/repos/boostorg/test/issues/131","repository_url":"https://api.github.com/repos/boostorg/test","labels_url":"https://api.github.com/repos/boostorg/test/issues/131/labels{/name}","comments_url":"https://api.github.com/repos/boostorg/test/issues/131/comments","events_url":"https://api.github.com/repos/boostorg/test/issues/131/events","html_url":"https://github.com/boostorg/test/issues/131","id":297446498,"node_id":"MDU6SXNzdWUyOTc0NDY0OTg=","number":131,"title":"Provide more flexible ways for outputting the tested types","user":{"login":"akrzemi1","id":2912717,"node_id":"MDQ6VXNlcjI5MTI3MTc=","avatar_url":"https://avatars1.githubusercontent.com/u/2912717?v=4","gravatar_id":"","url":"https://api.github.com/users/akrzemi1","html_url":"https://github.com/akrzemi1","followers_url":"https://api.github.com/users/akrzemi1/followers","following_url":"https://api.github.com/users/akrzemi1/following{/other_user}","gists_url":"https://api.github.com/users/akrzemi1/gists{/gist_id}","starred_url":"https://api.github.com/users/akrzemi1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akrzemi1/subscriptions","organizations_url":"https://api.github.com/users/akrzemi1/orgs","repos_url":"https://api.github.com/users/akrzemi1/repos","events_url":"https://api.github.com/users/akrzemi1/events{/privacy}","received_events_url":"https://api.github.com/users/akrzemi1/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"raffienficiaud","id":6357107,"node_id":"MDQ6VXNlcjYzNTcxMDc=","avatar_url":"https://avatars1.githubusercontent.com/u/6357107?v=4","gravatar_id":"","url":"https://api.github.com/users/raffienficiaud","html_url":"https://github.com/raffienficiaud","followers_url":"https://api.github.com/users/raffienficiaud/followers","following_url":"https://api.github.com/users/raffienficiaud/following{/other_user}","gists_url":"https://api.github.com/users/raffienficiaud/gists{/gist_id}","starred_url":"https://api.github.com/users/raffienficiaud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raffienficiaud/subscriptions","organizations_url":"https://api.github.com/users/raffienficiaud/orgs","repos_url":"https://api.github.com/users/raffienficiaud/repos","events_url":"https://api.github.com/users/raffienficiaud/events{/privacy}","received_events_url":"https://api.github.com/users/raffienficiaud/received_events","type":"User","site_admin":false},"assignees":[{"login":"raffienficiaud","id":6357107,"node_id":"MDQ6VXNlcjYzNTcxMDc=","avatar_url":"https://avatars1.githubusercontent.com/u/6357107?v=4","gravatar_id":"","url":"https://api.github.com/users/raffienficiaud","html_url":"https://github.com/raffienficiaud","followers_url":"https://api.github.com/users/raffienficiaud/followers","following_url":"https://api.github.com/users/raffienficiaud/following{/other_user}","gists_url":"https://api.github.com/users/raffienficiaud/gists{/gist_id}","starred_url":"https://api.github.com/users/raffienficiaud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raffienficiaud/subscriptions","organizations_url":"https://api.github.com/users/raffienficiaud/orgs","repos_url":"https://api.github.com/users/raffienficiaud/repos","events_url":"https://api.github.com/users/raffienficiaud/events{/privacy}","received_events_url":"https://api.github.com/users/raffienficiaud/received_events","type":"User","site_admin":false}],"milestone":null,"comments":3,"created_at":"2018-02-15T13:31:57Z","updated_at":"2018-10-02T09:00:57Z","closed_at":null,"author_association":"MEMBER","body":"According to the docs, if I want a custom output from tests for my type, I either have to provide an ADL-visible `operator<<` or ADL-visible function `boost_test_print_type`.  This is not satisfactory in a number of cases.\r\n\r\n### 1. Sometimes I operate on pointers or pairs:\r\n\r\n```c++\r\nstruct Item\r\n{\r\n  int uid;\r\n  string name;\r\n  string title;\r\n};\r\n\r\nusing ItemPtr = std::shared_ptr<Item>;\r\nusing Count = std::pair<Item, int>;\r\n```\r\n\r\nAnd I would like to serialize `ItemPtr p` by `p->uid`.\r\n\r\nI cannot do this because I would have to add a declaration to namespace `std` which is an undefined behavior.\r\n\r\n### 2. Sometimes I want to display the same object in two different ways in two different test cases.\r\n\r\nIn a different test case I may want to display `ItemPtr p` as\r\n\r\n```c++\r\n \"{\"s + p->name + \",\" + p->title + \"}\"\r\n```\r\n\r\nIssue 1 could be addressed in two ways.\r\n\r\n 1. The library provides a class template `boost::test::print_type<T>::print(T const&, std::ostream&)` which by default goes to `boost_test_print_type` but I can provide a specialization for my types.\r\n\r\n 2. You provide a function ADL-based interface, but one of the arguments is from `boost::test` namespace:\r\n\r\n```c++\r\nnamespace boost { namespace test {\r\n\r\n  struct tag {};\r\n\r\n  template <typename T>\r\n  void print_type(T const&, std::ostream&, tag); // default impl\r\n\r\n}}\r\n```\r\n\r\nThis way, I can always add overload into namespace `boost::test`:\r\n\r\n\r\n```c++\r\nnamespace boost { namespace test {\r\n\r\n  void print_type(std::shared_ptr<int> const&, std::ostream&, tag); // overload\r\n\r\n}}\r\n```\r\n\r\nTags could also solve the second issue, if they were somehow associated with test cases of test case fixtures. Or if rather than tags one would use fixture or test case namesnames:\r\n\r\n\r\n```c++\r\nnamespace boost { namespace test {\r\n\r\n  template <typename TT>\r\n  struct tag {};\r\n\r\n  template <typename T, typename TT>\r\n  void print_type(T const&, std::ostream&, tag<TT>); // default impl\r\n\r\n}}\r\n```\r\n\r\n```c++\r\nnamespace boost { namespace test {\r\n\r\n  // overloads:\r\n  void print_type(std::shared_ptr<int> const&, std::ostream&, tag<fixture_1>); \r\n  void print_type(std::shared_ptr<int> const&, std::ostream&, tag<fixture_2>); \r\n\r\n}}\r\n```"},"comment":{"url":"https://api.github.com/repos/boostorg/test/issues/comments/426201134","html_url":"https://github.com/boostorg/test/issues/131#issuecomment-426201134","issue_url":"https://api.github.com/repos/boostorg/test/issues/131","id":426201134,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNjIwMTEzNA==","user":{"login":"akrzemi1","id":2912717,"node_id":"MDQ6VXNlcjI5MTI3MTc=","avatar_url":"https://avatars1.githubusercontent.com/u/2912717?v=4","gravatar_id":"","url":"https://api.github.com/users/akrzemi1","html_url":"https://github.com/akrzemi1","followers_url":"https://api.github.com/users/akrzemi1/followers","following_url":"https://api.github.com/users/akrzemi1/following{/other_user}","gists_url":"https://api.github.com/users/akrzemi1/gists{/gist_id}","starred_url":"https://api.github.com/users/akrzemi1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akrzemi1/subscriptions","organizations_url":"https://api.github.com/users/akrzemi1/orgs","repos_url":"https://api.github.com/users/akrzemi1/repos","events_url":"https://api.github.com/users/akrzemi1/events{/privacy}","received_events_url":"https://api.github.com/users/akrzemi1/received_events","type":"User","site_admin":false},"created_at":"2018-10-02T09:00:57Z","updated_at":"2018-10-02T09:00:57Z","author_association":"MEMBER","body":"On the second thought though, maybe it will not suffice. In order for this to work, the framework (the macros) will have to call the function always with three arguments:\r\n\r\n```c++\r\n boost_test_print_type(theStream(), arg, TheFixtureTag());\r\n```\r\n\r\nOverloads currently provided by users, which are two-argument will stop working.\r\n\r\nSo, you will have to add an another level of customization. Some new ADL-discovered function, which by default forwards to the old (2-argument) `boost_test_print_type` ."}}
{"actor":{"display_login":"akrzemi1"}}