{"id":16829977,"url":"https://github.com/rtfb/godoctest","last_synced_at":"2025-03-17T22:07:36.420Z","repository":{"id":148321442,"uuid":"81009468","full_name":"rtfb/godoctest","owner":"rtfb","description":null,"archived":false,"fork":false,"pushed_at":"2017-07-23T11:01:23.000Z","size":27,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-24T08:22:44.571Z","etag":null,"topics":["doctest","go","testing"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rtfb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-05T17:38:15.000Z","updated_at":"2018-05-09T08:38:04.000Z","dependencies_parsed_at":"2023-05-19T18:30:29.857Z","dependency_job_id":null,"html_url":"https://github.com/rtfb/godoctest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtfb%2Fgodoctest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtfb%2Fgodoctest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtfb%2Fgodoctest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtfb%2Fgodoctest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rtfb","download_url":"https://codeload.github.com/rtfb/godoctest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244117656,"owners_count":20400743,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["doctest","go","testing"],"created_at":"2024-10-13T11:36:52.053Z","updated_at":"2025-03-17T22:07:36.389Z","avatar_url":"https://github.com/rtfb.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\ngodoctest\n=========\n\n`godoctest` spares you some drudgery by generating boilerplate around your\ntable-driven tests.\n\nInside a function, immediately following the declaration, write a comment of the\nform `[]test{\u003cyour test table\u003e}`. Each row of the table should consist of N + M\nelements, where N is the number of parameters and M is the number of return\nvalues. `godoctest` derives the types for the test table from the function\ndeclaration and generates all the usual boilerplate for a test function. See the\nexample below.\n\nHere's your source code:\n\n``` go\nfunc fibonacci(n int) int {\n\t/*\n\t\t[]test{\n\t\t\t{1, 1},\n\t\t\t{2, 1},\n\t\t\t{3, 2},\n\t\t\t{7, 13},\n\t\t\t{11, 89},\n\t\t}\n\t*/\n\tif n == 1 {\n\t\treturn 1\n\t}\n\tif n == 2 {\n\t\treturn 1\n\t}\n\treturn fibonacci(n-1) + fibonacci(n-2)\n}\n```\n\nHere's the test generated by `godoctest` (slightly redacted for readability):\n\n``` go\nfunc Test_fibonacci_gdt1(t *testing.T) {\n    tests := []struct{\n        f0 int\n        e0 int\n    }{\n        {1, 1},\n        {2, 1},\n        {3, 2},\n        {7, 13},\n        {11, 89},\n    }\n    for _, test := range tests {\n        r0 := fibonacci(test.f0)\n        assert.Equal(t, test.e0, r0)\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frtfb%2Fgodoctest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frtfb%2Fgodoctest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frtfb%2Fgodoctest/lists"}