patch 9.1.0797: testing of options can be further improved

Problem:  testing of options can be further improved
Solution: split the generated option test into test_options_all.vim,
          add more test cases, save and restore values, fix use-after-free

closes: #15894

Signed-off-by: Milly <milly.ca@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/testdir/test_options_all.vim b/src/testdir/test_options_all.vim
new file mode 100644
index 0000000..a2330ec
--- /dev/null
+++ b/src/testdir/test_options_all.vim
@@ -0,0 +1,13 @@
+" Test for options
+
+" opt_test.vim is generated from src/optiondefs.h and runtime/doc/options.txt
+" using gen_opt_test.vim
+if filereadable('opt_test.vim')
+  source opt_test.vim
+else
+  func Test_set_values()
+    throw 'Skipped: opt_test.vim does not exist'
+  endfunc
+endif
+
+" vim: shiftwidth=2 sts=2 expandtab