{"action":"created","comment":{"url":"https://api.github.com/repos/git-afsantos/jTuples/pulls/comments/33669532","id":33669532,"diff_hunk":"@@ -0,0 +1,167 @@\n+/*\n+ * Copyright (c) 2015 git-afsantos\n+ *\n+ * Permission is hereby granted, free of charge, to any person obtaining a copy\n+ * of this software and associated documentation files (the \"Software\"), to deal\n+ * in the Software without restriction, including without limitation the rights\n+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+ * copies of the Software, and to permit persons to whom the Software is\n+ * furnished to do so, subject to the following conditions:\n+ *\n+ * The above copyright notice and this permission notice shall be included in\n+ * all copies or substantial portions of the Software.\n+ *\n+ * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n+ * THE SOFTWARE.\n+ */\n+package org.jtuples;\n+\n+import java.util.Arrays;\n+import java.util.Iterator;\n+import java.util.List;\n+import org.junit.Test;\n+import static org.junit.Assert.*;\n+\n+/**\n+ *\n+ * @author Benjamim Sonntag <benjamimsonntag@gmail.com>\n+ */\n+public class TuplesTest {\n+\n+    @Test\n+    public void testPairWith() {\n+        Tuple expected = new Pair<>(\"1\", \"2\");\n+        assertEquals(expected, Tuples.with(\"1\", \"2\"));\n+    }\n+\n+    @Test\n+    public void testTripleWith() {\n+        Tuple expected = new Triple<>(\"1\", \"2\", \"3\");\n+        assertEquals(expected, Tuples.with(\"1\", \"2\", \"3\"));\n+    }\n+\n+    @Test\n+    public void testFourthWith() {\n+        Tuple expected = new Quadruple<>(\"1\", \"2\", \"3\", \"4\");\n+        assertEquals(expected, Tuples.with(\"1\", \"2\", \"3\", \"4\"));\n+    }\n+\n+    @Test\n+    public void testQuintupleWith() {\n+        Tuple expected = new Quintuple<>(\"1\", \"2\", \"3\", \"4\", \"5\");\n+        assertEquals(expected, Tuples.with(\"1\", \"2\", \"3\", \"4\", \"5\"));\n+    }\n+\n+    @Test\n+    public void testFlatFirst() {\n+        Pair<Pair<String, String>, String> pair = new Pair<>(\n+                new Pair<>(\"1\", \"2\"),\n+                \"3\"\n+        );\n+        Tuple expected = new Triple<>(\"1\", \"2\", \"3\");\n+        assertEquals(expected, Tuples.flatFirst(pair));\n+    }\n+\n+    @Test\n+    public void testFlatSecond() {\n+        Pair<String, Pair<String, String>> pair = new Pair<>(\n+                \"1\",\n+                new Pair<>(\"2\", \"3\")\n+        );\n+        Tuple expected = new Triple<>(\"1\", \"2\", \"3\");\n+        assertEquals(expected, Tuples.flatSecond(pair));\n+    }\n+\n+    @Test\n+    public void testAssociateFirst() {\n+        Pair<String, Pair<String, String>> pair = new Pair<>(\n+                \"1\",\n+                new Pair<>(\"2\", \"3\")\n+        );\n+        Tuple expected = new Pair<>(\n+                new Pair<>(\"1\", \"2\"),\n+                \"3\"\n+        );\n+        assertEquals(expected, Tuples.associateFirst(pair));\n+    }\n+\n+    @Test\n+    public void testAssociateSecond() {\n+        Pair<Pair<String, String>, String> pair = new Pair<>(\n+                new Pair<>(\"1\", \"2\"),\n+                \"3\"\n+        );\n+        Tuple expected = new Pair<>(\n+                \"1\",\n+                new Pair<>(\"2\", \"3\")\n+        );\n+        assertEquals(expected, Tuples.associateSecond(pair));\n+    }\n+\n+    @Test\n+    public void testMap_Pair() {\n+        Pair<String, String> pair = new Pair<>(\"1\", \"2\");\n+        Tuple expected = new Pair<>(\"11\", \"22\");\n+        assertEquals(expected, Tuples.map(pair, s -> s + s));\n+    }\n+\n+    @Test\n+    public void testMap_Triple() {\n+        Triple<String, String, String> triple = new Triple<>(\"1\", \"2\", \"3\");\n+        Tuple expected = new Triple<>(\"11\", \"22\", \"33\");\n+        assertEquals(expected, Tuples.map(triple, s -> s + s));\n+    }\n+\n+    @Test\n+    public void testMap_Quadruple() {\n+        Quadruple<String, String, String, String> quadruple =\n+                new Quadruple<>(\"1\", \"2\", \"3\", \"4\");\n+        Tuple expected = new Quadruple<>(\"11\", \"22\", \"33\", \"44\");\n+        assertEquals(expected, Tuples.map(quadruple, s -> s + s));\n+    }\n+\n+    @Test\n+    public void testMap_Quintuple() {\n+        Quintuple<String, String, String, String, String> quintuple =\n+                new Quintuple<>(\"1\", \"2\", \"3\", \"4\", \"5\");\n+        Tuple expected = new Quintuple<>(\"11\", \"22\", \"33\", \"44\", \"55\");\n+        assertEquals(expected, Tuples.map(quintuple, s -> s + s));\n+    }\n+\n+    @Test\n+    public void testZip_Iterable() {\n+        List<String> firsts = Arrays.asList(\"1\", \"2\", \"3\", \"4\");\n+        List<Integer> seconds = Arrays.asList(1, 2, 3, 4);\n+        List<Pair<String, Integer>> expected = Arrays.asList(\n+                new Pair<>(\"1\", 1),\n+                new Pair<>(\"2\", 2),\n+                new Pair<>(\"3\", 3),\n+                new Pair<>(\"4\", 4)\n+        );\n+        assertArrayEquals(expected.toArray(),\n+                Tuples.zip(firsts, seconds).toArray());\n+    }\n+\n+    @Test\n+    public void testZip_Iterator() {\n+        List<String> firsts = Arrays.asList(\"1\", \"2\", \"3\", \"4\");\n+        List<Integer> seconds = Arrays.asList(1, 2, 3, 4);\n+        List<Pair<String, Integer>> expected = Arrays.asList(\n+                new Pair<>(\"1\", 1),\n+                new Pair<>(\"2\", 2),\n+                new Pair<>(\"3\", 3),\n+                new Pair<>(\"4\", 4)\n+        );\n+        \n+        Iterator<Pair<String, Integer>> iterator =\n+                Tuples.zip(firsts.iterator(), seconds.iterator());\n+        \n+        expected.forEach(pair -> assertEquals(pair, iterator.next()));\n+    }\n+    ","path":"jtuples/src/test/java/org/jtuples/TuplesTest.java","position":166,"original_position":166,"commit_id":"d49a838e2f1b92ceb074113b479fa967d3109936","original_commit_id":"a20862d01c025898e17a9406c7d88078ebb3812b","user":{"login":"bsonntag","id":6205451,"avatar_url":"https://avatars.githubusercontent.com/u/6205451?v=3","gravatar_id":"","url":"https://api.github.com/users/bsonntag","html_url":"https://github.com/bsonntag","followers_url":"https://api.github.com/users/bsonntag/followers","following_url":"https://api.github.com/users/bsonntag/following{/other_user}","gists_url":"https://api.github.com/users/bsonntag/gists{/gist_id}","starred_url":"https://api.github.com/users/bsonntag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bsonntag/subscriptions","organizations_url":"https://api.github.com/users/bsonntag/orgs","repos_url":"https://api.github.com/users/bsonntag/repos","events_url":"https://api.github.com/users/bsonntag/events{/privacy}","received_events_url":"https://api.github.com/users/bsonntag/received_events","type":"User","site_admin":false},"body":"Good point. What do you suggest then? How could we check if two iterators are equal?","created_at":"2015-07-01T11:26:19Z","updated_at":"2015-07-01T11:26:19Z","html_url":"https://github.com/git-afsantos/jTuples/pull/13#discussion_r33669532","pull_request_url":"https://api.github.com/repos/git-afsantos/jTuples/pulls/13","_links":{"self":{"href":"https://api.github.com/repos/git-afsantos/jTuples/pulls/comments/33669532"},"html":{"href":"https://github.com/git-afsantos/jTuples/pull/13#discussion_r33669532"},"pull_request":{"href":"https://api.github.com/repos/git-afsantos/jTuples/pulls/13"}}},"pull_request":{"url":"https://api.github.com/repos/git-afsantos/jTuples/pulls/13","id":37622735,"html_url":"https://github.com/git-afsantos/jTuples/pull/13","diff_url":"https://github.com/git-afsantos/jTuples/pull/13.diff","patch_url":"https://github.com/git-afsantos/jTuples/pull/13.patch","issue_url":"https://api.github.com/repos/git-afsantos/jTuples/issues/13","number":13,"state":"open","locked":false,"title":"Starts implementation of Tuples class.","user":{"login":"bsonntag","id":6205451,"avatar_url":"https://avatars.githubusercontent.com/u/6205451?v=3","gravatar_id":"","url":"https://api.github.com/users/bsonntag","html_url":"https://github.com/bsonntag","followers_url":"https://api.github.com/users/bsonntag/followers","following_url":"https://api.github.com/users/bsonntag/following{/other_user}","gists_url":"https://api.github.com/users/bsonntag/gists{/gist_id}","starred_url":"https://api.github.com/users/bsonntag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bsonntag/subscriptions","organizations_url":"https://api.github.com/users/bsonntag/orgs","repos_url":"https://api.github.com/users/bsonntag/repos","events_url":"https://api.github.com/users/bsonntag/events{/privacy}","received_events_url":"https://api.github.com/users/bsonntag/received_events","type":"User","site_admin":false},"body":"`Tuples` is a utility class with factory methods as well as methods for the following operations:\r\n\r\n- `flatRight` and `flatLeft`;\r\n- `associateRight` and `associateLeft`;\r\n- `map`;\r\n- `zip`.","created_at":"2015-06-13T10:11:59Z","updated_at":"2015-07-01T11:26:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5525321d6ba697547d9d5e8374d3159187c59421","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/git-afsantos/jTuples/pulls/13/commits","review_comments_url":"https://api.github.com/repos/git-afsantos/jTuples/pulls/13/comments","review_comment_url":"https://api.github.com/repos/git-afsantos/jTuples/pulls/comments{/number}","comments_url":"https://api.github.com/repos/git-afsantos/jTuples/issues/13/comments","statuses_url":"https://api.github.com/repos/git-afsantos/jTuples/statuses/d49a838e2f1b92ceb074113b479fa967d3109936","head":{"label":"git-afsantos:bs-tuples-helper-class","ref":"bs-tuples-helper-class","sha":"d49a838e2f1b92ceb074113b479fa967d3109936","user":{"login":"git-afsantos","id":5166824,"avatar_url":"https://avatars.githubusercontent.com/u/5166824?v=3","gravatar_id":"","url":"https://api.github.com/users/git-afsantos","html_url":"https://github.com/git-afsantos","followers_url":"https://api.github.com/users/git-afsantos/followers","following_url":"https://api.github.com/users/git-afsantos/following{/other_user}","gists_url":"https://api.github.com/users/git-afsantos/gists{/gist_id}","starred_url":"https://api.github.com/users/git-afsantos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/git-afsantos/subscriptions","organizations_url":"https://api.github.com/users/git-afsantos/orgs","repos_url":"https://api.github.com/users/git-afsantos/repos","events_url":"https://api.github.com/users/git-afsantos/events{/privacy}","received_events_url":"https://api.github.com/users/git-afsantos/received_events","type":"User","site_admin":false},"repo":{"id":35178869,"name":"jTuples","full_name":"git-afsantos/jTuples","owner":{"login":"git-afsantos","id":5166824,"avatar_url":"https://avatars.githubusercontent.com/u/5166824?v=3","gravatar_id":"","url":"https://api.github.com/users/git-afsantos","html_url":"https://github.com/git-afsantos","followers_url":"https://api.github.com/users/git-afsantos/followers","following_url":"https://api.github.com/users/git-afsantos/following{/other_user}","gists_url":"https://api.github.com/users/git-afsantos/gists{/gist_id}","starred_url":"https://api.github.com/users/git-afsantos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/git-afsantos/subscriptions","organizations_url":"https://api.github.com/users/git-afsantos/orgs","repos_url":"https://api.github.com/users/git-afsantos/repos","events_url":"https://api.github.com/users/git-afsantos/events{/privacy}","received_events_url":"https://api.github.com/users/git-afsantos/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/git-afsantos/jTuples","description":"Java gets a Pair.","fork":false,"url":"https://api.github.com/repos/git-afsantos/jTuples","forks_url":"https://api.github.com/repos/git-afsantos/jTuples/forks","keys_url":"https://api.github.com/repos/git-afsantos/jTuples/keys{/key_id}","collaborators_url":"https://api.github.com/repos/git-afsantos/jTuples/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/git-afsantos/jTuples/teams","hooks_url":"https://api.github.com/repos/git-afsantos/jTuples/hooks","issue_events_url":"https://api.github.com/repos/git-afsantos/jTuples/issues/events{/number}","events_url":"https://api.github.com/repos/git-afsantos/jTuples/events","assignees_url":"https://api.github.com/repos/git-afsantos/jTuples/assignees{/user}","branches_url":"https://api.github.com/repos/git-afsantos/jTuples/branches{/branch}","tags_url":"https://api.github.com/repos/git-afsantos/jTuples/tags","blobs_url":"https://api.github.com/repos/git-afsantos/jTuples/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/git-afsantos/jTuples/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/git-afsantos/jTuples/git/refs{/sha}","trees_url":"https://api.github.com/repos/git-afsantos/jTuples/git/trees{/sha}","statuses_url":"https://api.github.com/repos/git-afsantos/jTuples/statuses/{sha}","languages_url":"https://api.github.com/repos/git-afsantos/jTuples/languages","stargazers_url":"https://api.github.com/repos/git-afsantos/jTuples/stargazers","contributors_url":"https://api.github.com/repos/git-afsantos/jTuples/contributors","subscribers_url":"https://api.github.com/repos/git-afsantos/jTuples/subscribers","subscription_url":"https://api.github.com/repos/git-afsantos/jTuples/subscription","commits_url":"https://api.github.com/repos/git-afsantos/jTuples/commits{/sha}","git_commits_url":"https://api.github.com/repos/git-afsantos/jTuples/git/commits{/sha}","comments_url":"https://api.github.com/repos/git-afsantos/jTuples/comments{/number}","issue_comment_url":"https://api.github.com/repos/git-afsantos/jTuples/issues/comments{/number}","contents_url":"https://api.github.com/repos/git-afsantos/jTuples/contents/{+path}","compare_url":"https://api.github.com/repos/git-afsantos/jTuples/compare/{base}...{head}","merges_url":"https://api.github.com/repos/git-afsantos/jTuples/merges","archive_url":"https://api.github.com/repos/git-afsantos/jTuples/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/git-afsantos/jTuples/downloads","issues_url":"https://api.github.com/repos/git-afsantos/jTuples/issues{/number}","pulls_url":"https://api.github.com/repos/git-afsantos/jTuples/pulls{/number}","milestones_url":"https://api.github.com/repos/git-afsantos/jTuples/milestones{/number}","notifications_url":"https://api.github.com/repos/git-afsantos/jTuples/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/git-afsantos/jTuples/labels{/name}","releases_url":"https://api.github.com/repos/git-afsantos/jTuples/releases{/id}","created_at":"2015-05-06T19:34:17Z","updated_at":"2015-05-08T09:23:09Z","pushed_at":"2015-07-01T11:20:37Z","git_url":"git://github.com/git-afsantos/jTuples.git","ssh_url":"git@github.com:git-afsantos/jTuples.git","clone_url":"https://github.com/git-afsantos/jTuples.git","svn_url":"https://github.com/git-afsantos/jTuples","homepage":"","size":464,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"base":{"label":"git-afsantos:master","ref":"master","sha":"ef5b79425395e346acf5510a0c3668065ebca6a2","user":{"login":"git-afsantos","id":5166824,"avatar_url":"https://avatars.githubusercontent.com/u/5166824?v=3","gravatar_id":"","url":"https://api.github.com/users/git-afsantos","html_url":"https://github.com/git-afsantos","followers_url":"https://api.github.com/users/git-afsantos/followers","following_url":"https://api.github.com/users/git-afsantos/following{/other_user}","gists_url":"https://api.github.com/users/git-afsantos/gists{/gist_id}","starred_url":"https://api.github.com/users/git-afsantos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/git-afsantos/subscriptions","organizations_url":"https://api.github.com/users/git-afsantos/orgs","repos_url":"https://api.github.com/users/git-afsantos/repos","events_url":"https://api.github.com/users/git-afsantos/events{/privacy}","received_events_url":"https://api.github.com/users/git-afsantos/received_events","type":"User","site_admin":false},"repo":{"id":35178869,"name":"jTuples","full_name":"git-afsantos/jTuples","owner":{"login":"git-afsantos","id":5166824,"avatar_url":"https://avatars.githubusercontent.com/u/5166824?v=3","gravatar_id":"","url":"https://api.github.com/users/git-afsantos","html_url":"https://github.com/git-afsantos","followers_url":"https://api.github.com/users/git-afsantos/followers","following_url":"https://api.github.com/users/git-afsantos/following{/other_user}","gists_url":"https://api.github.com/users/git-afsantos/gists{/gist_id}","starred_url":"https://api.github.com/users/git-afsantos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/git-afsantos/subscriptions","organizations_url":"https://api.github.com/users/git-afsantos/orgs","repos_url":"https://api.github.com/users/git-afsantos/repos","events_url":"https://api.github.com/users/git-afsantos/events{/privacy}","received_events_url":"https://api.github.com/users/git-afsantos/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/git-afsantos/jTuples","description":"Java gets a Pair.","fork":false,"url":"https://api.github.com/repos/git-afsantos/jTuples","forks_url":"https://api.github.com/repos/git-afsantos/jTuples/forks","keys_url":"https://api.github.com/repos/git-afsantos/jTuples/keys{/key_id}","collaborators_url":"https://api.github.com/repos/git-afsantos/jTuples/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/git-afsantos/jTuples/teams","hooks_url":"https://api.github.com/repos/git-afsantos/jTuples/hooks","issue_events_url":"https://api.github.com/repos/git-afsantos/jTuples/issues/events{/number}","events_url":"https://api.github.com/repos/git-afsantos/jTuples/events","assignees_url":"https://api.github.com/repos/git-afsantos/jTuples/assignees{/user}","branches_url":"https://api.github.com/repos/git-afsantos/jTuples/branches{/branch}","tags_url":"https://api.github.com/repos/git-afsantos/jTuples/tags","blobs_url":"https://api.github.com/repos/git-afsantos/jTuples/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/git-afsantos/jTuples/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/git-afsantos/jTuples/git/refs{/sha}","trees_url":"https://api.github.com/repos/git-afsantos/jTuples/git/trees{/sha}","statuses_url":"https://api.github.com/repos/git-afsantos/jTuples/statuses/{sha}","languages_url":"https://api.github.com/repos/git-afsantos/jTuples/languages","stargazers_url":"https://api.github.com/repos/git-afsantos/jTuples/stargazers","contributors_url":"https://api.github.com/repos/git-afsantos/jTuples/contributors","subscribers_url":"https://api.github.com/repos/git-afsantos/jTuples/subscribers","subscription_url":"https://api.github.com/repos/git-afsantos/jTuples/subscription","commits_url":"https://api.github.com/repos/git-afsantos/jTuples/commits{/sha}","git_commits_url":"https://api.github.com/repos/git-afsantos/jTuples/git/commits{/sha}","comments_url":"https://api.github.com/repos/git-afsantos/jTuples/comments{/number}","issue_comment_url":"https://api.github.com/repos/git-afsantos/jTuples/issues/comments{/number}","contents_url":"https://api.github.com/repos/git-afsantos/jTuples/contents/{+path}","compare_url":"https://api.github.com/repos/git-afsantos/jTuples/compare/{base}...{head}","merges_url":"https://api.github.com/repos/git-afsantos/jTuples/merges","archive_url":"https://api.github.com/repos/git-afsantos/jTuples/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/git-afsantos/jTuples/downloads","issues_url":"https://api.github.com/repos/git-afsantos/jTuples/issues{/number}","pulls_url":"https://api.github.com/repos/git-afsantos/jTuples/pulls{/number}","milestones_url":"https://api.github.com/repos/git-afsantos/jTuples/milestones{/number}","notifications_url":"https://api.github.com/repos/git-afsantos/jTuples/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/git-afsantos/jTuples/labels{/name}","releases_url":"https://api.github.com/repos/git-afsantos/jTuples/releases{/id}","created_at":"2015-05-06T19:34:17Z","updated_at":"2015-05-08T09:23:09Z","pushed_at":"2015-07-01T11:20:37Z","git_url":"git://github.com/git-afsantos/jTuples.git","ssh_url":"git@github.com:git-afsantos/jTuples.git","clone_url":"https://github.com/git-afsantos/jTuples.git","svn_url":"https://github.com/git-afsantos/jTuples","homepage":"","size":464,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/git-afsantos/jTuples/pulls/13"},"html":{"href":"https://github.com/git-afsantos/jTuples/pull/13"},"issue":{"href":"https://api.github.com/repos/git-afsantos/jTuples/issues/13"},"comments":{"href":"https://api.github.com/repos/git-afsantos/jTuples/issues/13/comments"},"review_comments":{"href":"https://api.github.com/repos/git-afsantos/jTuples/pulls/13/comments"},"review_comment":{"href":"https://api.github.com/repos/git-afsantos/jTuples/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/git-afsantos/jTuples/pulls/13/commits"},"statuses":{"href":"https://api.github.com/repos/git-afsantos/jTuples/statuses/d49a838e2f1b92ceb074113b479fa967d3109936"}}}}