view markdown_converter/tests/markdown_to_html_test.c @ 279:b3b547563ec7

Add Google connector service and agent wiki Implement the C/Seobeo Google Drive and Gmail connector with encrypted OAuth storage, Zenbu authentication, browser testing, AI tool discovery, chunked HTTP decoding, and Bazel coverage. Consolidate repository guidance into progressive wiki documentation and enforce arena-first allocation for new first-party C code. Co-authored-by: Copilot <[email protected]> Copilot-Session: 84c338fd-0939-4bb3-b7f3-1062eb213e5d
author MrJuneJune <me@mrjunejune.com>
date Mon, 17 Aug 2026 22:22:36 -0700
parents ce7f4400c2de
children
line wrap: on
line source

#include "markdown_converter/markdown_to_html.h"

#include <stdio.h>
#include <string.h>

static int failures = 0;

static void expect_equal(const char *name, const char *markdown, const char *expected)
{
  char *actual = markdown_to_html(markdown);
  if (!actual || strcmp(actual, expected) != 0) {
    fprintf(stderr, "%s\nexpected: %s\nactual:   %s\n", name, expected, actual ? actual : "(null)");
    failures++;
  }
  markdown_free(actual);
}

int main(void)
{
  expect_equal("normal link", "[link](https://example.com)",
               "<p><a href=\"https://example.com\">link</a></p>");
  expect_equal("escape paragraph", "a & <b>", "<p>a &amp; &lt;b&gt;</p>");
  expect_equal("escape raw script", "<script>alert('x')</script>",
               "<p>&lt;script&gt;alert(&#39;x&#39;)&lt;/script&gt;</p>");
  expect_equal("reject script link", "[open](javascript:alert)", "<p>open</p>");
  expect_equal("reject data image", "![preview](data:image/svg+xml,test)", "<p>preview</p>");
  expect_equal("escape link attribute", "[link](https://example.com/\"x)",
               "<p><a href=\"https://example.com/&quot;x\">link</a></p>");
  expect_equal("escape inline code", "`<script>`", "<p><code>&lt;script&gt;</code></p>");

  return failures == 0 ? 0 : 1;
}