summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-08-31 13:41:47 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-08-31 13:42:07 (GMT)
commitf7fc864c3ae26afa1ec8670699782e3da037a1d9 (patch)
tree96c3f0e53f5e6e3558beb8d8ae15d5fd87a3c017 /Tests
parent914ee5d2e5280dcfc94d234fee0287f9a70447dd (diff)
parente706da5f7ebbdab98098825ff8f7bad89ce06277 (diff)
downloadCMake-f7fc864c3ae26afa1ec8670699782e3da037a1d9.zip
CMake-f7fc864c3ae26afa1ec8670699782e3da037a1d9.tar.gz
CMake-f7fc864c3ae26afa1ec8670699782e3da037a1d9.tar.bz2
Merge topic 'FindOpenSP-module'
e706da5f7e FindOpenSP: Add module to find the OpenSP library 4bcdf1b992 ci: add OpenSP to Debian and Fedora base images Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !7470
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLists.txt1
-rw-r--r--Tests/FindOpenSP/CMakeLists.txt10
-rw-r--r--Tests/FindOpenSP/Test/CMakeLists.txt16
-rw-r--r--Tests/FindOpenSP/Test/main.cxx55
-rw-r--r--Tests/FindOpenSP/Test/test.sgml7
5 files changed, 89 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index b7de021..b6fec4d 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1476,6 +1476,7 @@ if(BUILD_TESTING)
OpenCL
OpenGL
OpenMP
+ OpenSP
OpenSSL
MPI
PNG
diff --git a/Tests/FindOpenSP/CMakeLists.txt b/Tests/FindOpenSP/CMakeLists.txt
new file mode 100644
index 0000000..26826d3
--- /dev/null
+++ b/Tests/FindOpenSP/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindOpenSP.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindOpenSP/Test"
+ "${CMake_BINARY_DIR}/Tests/FindOpenSP/Test"
+ ${build_generator_args}
+ --build-project TestFindOpenSP
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindOpenSP/Test/CMakeLists.txt b/Tests/FindOpenSP/Test/CMakeLists.txt
new file mode 100644
index 0000000..d8992d9
--- /dev/null
+++ b/Tests/FindOpenSP/Test/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.4)
+project(TestFindOpenSP CXX)
+include(CTest)
+
+find_package(OpenSP REQUIRED)
+
+add_definitions(-DSP_MULTI_BYTE="${OpenSP_MULTI_BYTE}")
+
+add_executable(test_tgt main.cxx)
+target_link_libraries(test_tgt OpenSP::OpenSP)
+add_test(NAME test_tgt COMMAND test_tgt)
+
+add_executable(test_var main.cxx)
+target_include_directories(test_var PRIVATE ${OpenSP_INCLUDE_DIRS})
+target_link_libraries(test_var PRIVATE ${OpenSP_LIBRARIES})
+add_test(NAME test_var COMMAND test_var)
diff --git a/Tests/FindOpenSP/Test/main.cxx b/Tests/FindOpenSP/Test/main.cxx
new file mode 100644
index 0000000..ef8aa2c
--- /dev/null
+++ b/Tests/FindOpenSP/Test/main.cxx
@@ -0,0 +1,55 @@
+#include <cassert>
+#include <string>
+
+#include "ParserEventGeneratorKit.h"
+
+std::string CharStringtostring(const SGMLApplication::CharString source)
+{
+ // The CharString type might have multi-byte characters if SP_MULTI_BYTE was
+ // defined
+ std::string result;
+ result.resize(source.len);
+ for (size_t i = 0; i < source.len; i++) {
+ result[i] = static_cast<char>(source.ptr[i]);
+ }
+ return result;
+}
+
+class OutlineApplication : public SGMLApplication
+{
+public:
+ OutlineApplication()
+ : depth_(0)
+ {
+ }
+ void startElement(const StartElementEvent& event)
+ {
+ for (unsigned i = 0; i < depth_; i++)
+ parsedOutput += "\t";
+ parsedOutput += CharStringtostring(event.gi);
+ depth_++;
+ }
+ void endElement(const EndElementEvent&) { depth_--; }
+ std::string parsedOutput;
+
+private:
+ unsigned depth_;
+};
+
+int main()
+{
+ std::string expectedOutput = "TESTDOC\tTESTELEMENT";
+ char file_name[] = "test.sgml";
+ char* files[] = { file_name, 0 };
+
+ ParserEventGeneratorKit parserKit;
+ EventGenerator* egp = parserKit.makeEventGenerator(1, files);
+ OutlineApplication app;
+ unsigned nErrors = egp->run(app);
+
+ assert(nErrors == 0);
+ assert(app.parsedOutput.compare(expectedOutput) == 0);
+
+ delete egp;
+ return 0;
+}
diff --git a/Tests/FindOpenSP/Test/test.sgml b/Tests/FindOpenSP/Test/test.sgml
new file mode 100644
index 0000000..bbf0da6
--- /dev/null
+++ b/Tests/FindOpenSP/Test/test.sgml
@@ -0,0 +1,7 @@
+ <!DOCTYPE TESTDOC [
+<!ELEMENT TESTDOC - - (TESTELEMENT)+>
+<!ELEMENT TESTELEMENT - - (#PCDATA)>
+]>
+<TESTDOC>
+<TESTELEMENT>Hello</TESTELEMENT>
+</TESTDOC>