summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYinzuo Jiang <jiangyinzuo@foxmail.com>2024-07-13 19:02:10 +0200
committerChristian Brabandt <cb@256bit.org>2024-07-13 19:02:10 +0200
commit360c51208eb36a527191cc5fe3f9c4f4cae1131a (patch)
tree2277e751ede4391699adec24e44390437e5bc2a0
parent69a28f6c0861523b1a9c565b3c882f439ae73ef4 (diff)
patch 9.1.0578: no tests for :Tohtmlv9.1.0578
Problem: no tests for :Tohtml Solution: Add two basic tests (Yinzuo Jiang) closes: #15240 Signed-off-by: Yinzuo Jiang <jiangyinzuo@foxmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
-rw-r--r--Filelist1
-rw-r--r--src/testdir/Make_all.mak2
-rw-r--r--src/testdir/samples/Test_tohtml_basic.c.html47
-rw-r--r--src/testdir/samples/Test_tohtml_basic_no_css.c.html40
-rw-r--r--src/testdir/test_tohtml.vim72
-rw-r--r--src/version.c2
6 files changed, 164 insertions, 0 deletions
diff --git a/Filelist b/Filelist
index 30c820822c..5e24dbb70b 100644
--- a/Filelist
+++ b/Filelist
@@ -214,6 +214,7 @@ SRC_ALL = \
src/testdir/pyxfile/*.py \
src/testdir/dumps/*.dump \
src/testdir/dumps/*.vim \
+ src/testdir/samples/*.html \
src/testdir/samples/*.txt \
src/testdir/samples/*.vim \
src/testdir/samples/test000 \
diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak
index 76d44299e9..71c3dccac8 100644
--- a/src/testdir/Make_all.mak
+++ b/src/testdir/Make_all.mak
@@ -315,6 +315,7 @@ NEW_TESTS = \
test_textobjects \
test_textprop \
test_timers \
+ test_tohtml \
test_true_false \
test_trycatch \
test_undo \
@@ -560,6 +561,7 @@ NEW_TESTS_RES = \
test_textobjects.res \
test_textprop.res \
test_timers.res \
+ test_tohtml.res \
test_true_false.res \
test_trycatch.res \
test_undo.res \
diff --git a/src/testdir/samples/Test_tohtml_basic.c.html b/src/testdir/samples/Test_tohtml_basic.c.html
new file mode 100644
index 0000000000..d9467b5086
--- /dev/null
+++ b/src/testdir/samples/Test_tohtml_basic.c.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="UTF-8">
+<title>/home/jiangyinzuo/vim/src/testdir/Test_tohtml_basic.c.html</title>
+<meta name="Generator" content="Vim/9.1">
+<meta name="plugin-version" content="vim9.0_v2">
+<meta name="syntax" content="none">
+<meta name="settings" content="use_css,no_foldcolumn,pre_wrap,prevent_copy=,use_input_for_pc=none">
+<meta name="colorscheme" content="none">
+<style>
+<!--
+pre { white-space: pre-wrap; font-family: monospace; color: #000000; background-color: #ffffff; }
+body { font-family: monospace; color: #000000; background-color: #ffffff; }
+* { font-size: 1em; }
+-->
+</style>
+</head>
+<body>
+<pre id='vimCodeElement'>
+#include &lt;stdio.h&gt;
+#include &lt;stdlib.h&gt;
+
+int isprime(int n)
+{
+ if (n &lt;= 1)
+ return 0;
+
+ for (int i = 2; i &lt;= n / 2; i++)
+ if (n % i == 0)
+ return 0;
+
+ return 1;
+}
+
+int main(int argc, char *argv[])
+{
+ int n = 7;
+
+ printf(&quot;%d is %s prime\n&quot;, n, isprime(n) ? &quot;a&quot; : &quot;not a&quot;);
+
+ return 0;
+}
+</pre>
+</body>
+</html>
+<!-- vim: set foldmethod=manual : -->
diff --git a/src/testdir/samples/Test_tohtml_basic_no_css.c.html b/src/testdir/samples/Test_tohtml_basic_no_css.c.html
new file mode 100644
index 0000000000..fcbcf5c1fc
--- /dev/null
+++ b/src/testdir/samples/Test_tohtml_basic_no_css.c.html
@@ -0,0 +1,40 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+<title>/home/jiangyinzuo/vim/src/testdir/Test_tohtml_basic_no_css.c.html</title>
+<meta name="Generator" content="Vim/9.1">
+<meta name="plugin-version" content="vim9.0_v2">
+<meta name="syntax" content="none">
+<meta name="settings" content="no_pre,no_foldcolumn,expand_tabs,prevent_copy=,use_input_for_pc=none">
+<meta name="colorscheme" content="none">
+</head>
+<body bgcolor="#ffffff" text="#000000">
+<font face="monospace">
+#include &lt;stdio.h&gt;<br>
+#include &lt;stdlib.h&gt;<br>
+<br>
+int isprime(int n)<br>
+{<br>
+&nbsp;&nbsp;if (n &lt;= 1)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;return 0;<br>
+<br>
+&nbsp;&nbsp;for (int i = 2; i &lt;= n / 2; i++)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;if (n % i == 0)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return 0;<br>
+<br>
+&nbsp;&nbsp;return 1;<br>
+}<br>
+<br>
+int main(int argc, char *argv[])<br>
+{<br>
+&nbsp;&nbsp;int n = 7;<br>
+<br>
+&nbsp;&nbsp;printf(&quot;%d is %s prime\n&quot;, n, isprime(n) ? &quot;a&quot; : &quot;not a&quot;);<br>
+<br>
+&nbsp;&nbsp;return 0;<br>
+}<br>
+</font>
+</body>
+</html>
+<!-- vim: set foldmethod=manual : -->
diff --git a/src/testdir/test_tohtml.vim b/src/testdir/test_tohtml.vim
new file mode 100644
index 0000000000..a1c8572732
--- /dev/null
+++ b/src/testdir/test_tohtml.vim
@@ -0,0 +1,72 @@
+" Tests for Vim :TOhtml
+
+source check.vim
+
+func s:setup_basic(src_name)
+ let lines =<< trim END
+ #include <stdio.h>
+ #include <stdlib.h>
+
+ int isprime(int n)
+ {
+ if (n <= 1)
+ return 0;
+
+ for (int i = 2; i <= n / 2; i++)
+ if (n % i == 0)
+ return 0;
+
+ return 1;
+ }
+
+ int main(int argc, char *argv[])
+ {
+ int n = 7;
+
+ printf("%d is %s prime\n", n, isprime(n) ? "a" : "not a");
+
+ return 0;
+ }
+ END
+ call writefile(lines, a:src_name)
+ exe 'edit ' . a:src_name
+ TOhtml
+ write
+endfunc
+
+func s:cleanup_basic(src_name)
+ call delete(a:src_name)
+ call delete(a:src_name . ".html")
+endfunc
+
+source $VIMRUNTIME/plugin/tohtml.vim
+
+func Test_tohtml_basic()
+ let src_name = "Test_tohtml_basic.c"
+ call s:setup_basic(src_name)
+ let expected = readfile("samples/" . src_name . ".html")
+ let actual = readfile(src_name . ".html")
+ call assert_equal(expected[0:3], actual[0:3])
+ " Ignore the title
+ call assert_equal(expected[5:11], actual[5:11])
+ " Ignore pre and body css
+ call assert_equal(expected[14:], actual[14:])
+ call s:cleanup_basic(src_name)
+endfunc
+
+func Test_tohtml_basic_no_css()
+ let g:html_use_css = 0
+ let src_name = "Test_tohtml_basic_no_css.c"
+ call s:setup_basic(src_name)
+ let expected = readfile("samples/" . src_name . ".html")
+ let actual = readfile(src_name . ".html")
+ call assert_equal(expected[0:3], actual[0:3])
+ " Ignore the title
+ call assert_equal(expected[5:10], actual[5:10])
+ " Ignore body's inline css
+ call assert_equal(expected[12:], actual[12:])
+ call s:cleanup_basic(src_name)
+ unlet g:html_use_css
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index a1b87b3eb4..c87d37891e 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 578,
+/**/
577,
/**/
576,