commit a346839c20ee59260a95cc5664925a28d9618e55
parent d1ddde91044de95e07bc9dd0750e79b68befccf4
Author: Mario Rosell R. Martinez <mario@mariorosell.es>
Date: Sat, 28 Mar 2026 22:02:42 +0100
anntp_overview, tests: Add missing semicolon on definitions and anntp_overview tests
Diffstat:
| M | anntp.h | | | 2 | +- |
| M | tests/test.c | | | 64 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 files changed, 65 insertions(+), 1 deletion(-)
diff --git a/anntp.h b/anntp.h
@@ -196,7 +196,7 @@ ANNTP_API int anntp_group(AnntpConnection* conn, const char* group,
ANNTP_API ssize_t anntp_article(AnntpConnection*, size_t num, AnntpArticle* out_art);
ANNTP_API void anntp_article_free(AnntpArticle* art);
ANNTP_API int anntp_article_cb(AnntpConnection* cv, size_t n, AnntpLineCb cb, void* extra);
-ANNTP_API void anntp_overview_free(AnntpOverview* ov)
+ANNTP_API void anntp_overview_free(AnntpOverview* ov);
ANNTP_API ssize_t anntp_overview(AnntpConnection* cv, size_t start, size_t end, AnntpOverview* ov);
ANNTP_API int anntp_overview_cb(AnntpConnection*, size_t start, size_t end, AnntpLineCb, void*);
ANNTP_API ssize_t anntp_write_all(AnntpConnection* conn, const uchar_t* buf, size_t bufsize);
diff --git a/tests/test.c b/tests/test.c
@@ -205,6 +205,68 @@ test_article_cb(void)
anntp_freeconn(c);
}
+void
+test_overview(void)
+{
+ AnntpConnection* c = anntp_mkconn("news.eternal-september.org", "119", false);
+ require(c != NULL, "connection for OVERVIEW test");
+
+ char line[256];
+ anntp_readline(c, line, sizeof(line));
+
+ AnntpGroup g;
+ int err = anntp_group(c, "eternal-september.talk", &g);
+ require(err == ANE_OK, "group for overview");
+
+ AnntpOverview ov;
+ memset(&ov, 0, sizeof(ov));
+
+ /* small range to avoid huge downloads */
+ ssize_t n = anntp_overview(c, g.first, g.first + 10, &ov);
+
+ require(n > 0, "anntp_overview fetch");
+ require(ov.count > 0, "overview has entries");
+ require(ov.lines != NULL, "overview lines allocated");
+
+ /* make sure the server also works */
+ require(ov.lines[0] != NULL, "first overview line exists");
+
+ anntp_overview_free(&ov);
+ anntp_freeconn(c);
+}
+
+static int
+overview_count_cb(const char* line, void* extra)
+{
+ size_t* n = (size_t*)extra;
+ if (line && line[0] != '\0')
+ (*n)++;
+ return 0;
+}
+
+void
+test_overview_cb(void)
+{
+ AnntpConnection* c = anntp_mkconn("news.eternal-september.org", "119", false);
+ require(c != NULL, "connection for OVERVIEW_CB test");
+
+ char line[256];
+ anntp_readline(c, line, sizeof(line));
+
+ AnntpGroup g;
+ int err = anntp_group(c, "eternal-september.talk", &g);
+ require(err == ANE_OK, "group for overview_cb");
+
+ size_t count = 0;
+
+ err = anntp_overview_cb(c, g.first, g.first + 10, overview_count_cb, &count);
+
+ require(err == ANE_OK, "anntp_overview_cb execution");
+ require(count > 0, "overview_cb received lines");
+
+ anntp_freeconn(c);
+}
+
/*********************************************************************************************************************/
int
@@ -221,6 +283,8 @@ main(void)
test_list();
test_article();
test_article_cb();
+ test_overview();
+ test_overview_cb();
printf("> INFO: %u out of %u tests failed (%u succeeded).\n",
nfailed, ntests, ntests - nfailed);