summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGravatar Sébastien Gonzalve2023-04-21 12:40:18 +0200
committerGravatar Nikias Bassen2023-04-21 12:40:18 +0200
commit25ace1e8cb7f9a464c29dd2ce80cd68104d54f84 (patch)
treeb084e02e0021d78c62bae94ac2e2f214631a469d /test
parent12c45a21b4f223ca2a4ccba42ade2366f4dbde5c (diff)
downloadlibplist-25ace1e8cb7f9a464c29dd2ce80cd68104d54f84.tar.gz
libplist-25ace1e8cb7f9a464c29dd2ce80cd68104d54f84.tar.bz2
Add C++ interface test
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am10
-rwxr-xr-xtest/bigarray++.test15
-rwxr-xr-xtest/empty++.test15
-rwxr-xr-xtest/huge++.test15
-rwxr-xr-xtest/large++.test15
-rwxr-xr-xtest/medium++.test15
-rw-r--r--test/plist_test++.cpp103
-rwxr-xr-xtest/small++.test15
8 files changed, 203 insertions, 0 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 5326317..5d31f5a 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -8,6 +8,7 @@ AM_LDFLAGS =
noinst_PROGRAMS = \
plist_cmp \
plist_test \
+ plist_test++ \
integer_set_test \
plist_btest \
plist_jtest \
@@ -18,6 +19,9 @@ plist_cmp_LDADD = \
$(top_builddir)/src/libplist-2.0.la \
$(top_builddir)/libcnary/libcnary.la
+plist_test___SOURCES = plist_test++.cpp
+plist_test___LDADD = $(top_builddir)/src/libplist++-2.0.la
+
plist_test_SOURCES = plist_test.c
plist_test_LDADD = $(top_builddir)/src/libplist-2.0.la
@@ -40,6 +44,12 @@ TESTS = \
large.test \
huge.test \
bigarray.test \
+ empty++.test \
+ small++.test \
+ medium++.test \
+ large++.test \
+ huge++.test \
+ bigarray++.test \
dates.test \
timezone1.test \
timezone2.test \
diff --git a/test/bigarray++.test b/test/bigarray++.test
new file mode 100755
index 0000000..da65387
--- /dev/null
+++ b/test/bigarray++.test
@@ -0,0 +1,15 @@
+## -*- sh -*-
+
+DATASRC=$top_srcdir/test/data
+DATAOUT=$top_builddir/test/data
+TESTFILE=6.plist
+
+if ! test -d "$DATAOUT"; then
+ mkdir -p $DATAOUT
+fi
+
+echo "Converting"
+$top_builddir/test/plist_test++ $DATASRC/$TESTFILE $DATAOUT/$TESTFILE.out
+
+echo "Comparing"
+$top_builddir/test/plist_cmp $DATASRC/$TESTFILE $DATAOUT/$TESTFILE.out
diff --git a/test/empty++.test b/test/empty++.test
new file mode 100755
index 0000000..f29e95e
--- /dev/null
+++ b/test/empty++.test
@@ -0,0 +1,15 @@
+## -*- sh -*-
+
+DATASRC=$top_srcdir/test/data
+DATAOUT=$top_builddir/test/data
+TESTFILE=1.plist
+
+if ! test -d "$DATAOUT"; then
+ mkdir -p $DATAOUT
+fi
+
+echo "Converting"
+$top_builddir/test/plist_test++ $DATASRC/$TESTFILE $DATAOUT/$TESTFILE.out
+
+echo "Comparing"
+$top_builddir/test/plist_cmp $DATASRC/$TESTFILE $DATAOUT/$TESTFILE.out
diff --git a/test/huge++.test b/test/huge++.test
new file mode 100755
index 0000000..3b6425e
--- /dev/null
+++ b/test/huge++.test
@@ -0,0 +1,15 @@
+## -*- sh -*-
+
+DATASRC=$top_srcdir/test/data
+DATAOUT=$top_builddir/test/data
+TESTFILE=5.plist
+
+if ! test -d "$DATAOUT"; then
+ mkdir -p $DATAOUT
+fi
+
+echo "Converting"
+$top_builddir/test/plist_test++ $DATASRC/$TESTFILE $DATAOUT/$TESTFILE.out
+
+echo "Comparing"
+$top_builddir/test/plist_cmp $DATASRC/$TESTFILE $DATAOUT/$TESTFILE.out
diff --git a/test/large++.test b/test/large++.test
new file mode 100755
index 0000000..cdadd75
--- /dev/null
+++ b/test/large++.test
@@ -0,0 +1,15 @@
+## -*- sh -*-
+
+DATASRC=$top_srcdir/test/data
+DATAOUT=$top_builddir/test/data
+TESTFILE=4.plist
+
+if ! test -d "$DATAOUT"; then
+ mkdir -p $DATAOUT
+fi
+
+echo "Converting"
+$top_builddir/test/plist_test++ $DATASRC/$TESTFILE $DATAOUT/$TESTFILE.out
+
+echo "Comparing"
+$top_builddir/test/plist_cmp $DATASRC/$TESTFILE $DATAOUT/$TESTFILE.out
diff --git a/test/medium++.test b/test/medium++.test
new file mode 100755
index 0000000..3488dfd
--- /dev/null
+++ b/test/medium++.test
@@ -0,0 +1,15 @@
+## -*- sh -*-
+
+DATASRC=$top_srcdir/test/data
+DATAOUT=$top_builddir/test/data
+TESTFILE=3.plist
+
+if ! test -d "$DATAOUT"; then
+ mkdir -p $DATAOUT
+fi
+
+echo "Converting"
+$top_builddir/test/plist_test++ $DATASRC/$TESTFILE $DATAOUT/$TESTFILE.out
+
+echo "Comparing"
+$top_builddir/test/plist_cmp $DATASRC/$TESTFILE $DATAOUT/$TESTFILE.out
diff --git a/test/plist_test++.cpp b/test/plist_test++.cpp
new file mode 100644
index 0000000..33205c1
--- /dev/null
+++ b/test/plist_test++.cpp
@@ -0,0 +1,103 @@
+/*
+ * source libplist++ regression test
+ *
+ * Copyright (c) 2021 Sebastien Gonzalve All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#include "plist/plist++.h"
+#include <fstream>
+#include <sstream>
+#include <iostream>
+
+int main(int argc, char *argv[])
+{
+ if (argc != 3)
+ {
+ printf("Wrong input\n");
+ return 1;
+ }
+
+ const char* file_in = argv[1];
+ const char* file_out = argv[2];
+
+ //read input file
+ std::ifstream iplist;
+ iplist.open(file_in);
+
+ if (!iplist)
+ {
+ printf("File does not exists\n");
+ return 2;
+ }
+
+ std::cout << "File " << file_in << " is open\n";
+
+ std::string plist_xml;
+ {
+ std::stringstream buffer;
+ buffer << iplist.rdbuf();
+ plist_xml = buffer.str();
+ }
+
+ iplist.close();
+
+ //convert one format to another
+ PList::Structure* root_node1 = PList::Structure::FromXml(plist_xml);
+ if (!root_node1)
+ {
+ std::cout << "PList XML parsing failed\n";
+ return 3;
+ }
+
+ std::cout << "PList XML parsing succeeded\n";
+ std::vector<char> plist_bin = root_node1->ToBin();
+ // FIXME There is no way to test for success of ToBin for now.
+
+ std::cout << "PList BIN writing succeeded\n";
+ PList::Structure* root_node2 = PList::Structure::FromBin(plist_bin);
+ if (!root_node2)
+ {
+ std::cout << "PList BIN parsing failed\n";
+ return 5;
+ }
+
+ std::cout << "PList BIN parsing succeeded\n";
+ std::string plist_xml2 = root_node2->ToXml();
+ if (plist_xml2.empty())
+ {
+ std::cout << "PList XML writing failed\n";
+ return 8;
+ }
+
+ std::cout << "PList XML writing succeeded\n";
+ {
+ std::ofstream oplist;
+ oplist.open(file_out);
+ oplist << plist_xml2;
+ }
+
+ if (plist_xml.size() != plist_xml2.size())
+ {
+ std::cout << "Size of input and output is different\n"
+ << "Input size : " << plist_xml.size()
+ << "\nOutput size : " << plist_xml2.size() << '\n';
+ }
+
+ return 0;
+}
+
diff --git a/test/small++.test b/test/small++.test
new file mode 100755
index 0000000..28c7676
--- /dev/null
+++ b/test/small++.test
@@ -0,0 +1,15 @@
+## -*- sh -*-
+
+DATASRC=$top_srcdir/test/data
+DATAOUT=$top_builddir/test/data
+TESTFILE=2.plist
+
+if ! test -d "$DATAOUT"; then
+ mkdir -p $DATAOUT
+fi
+
+echo "Converting"
+$top_builddir/test/plist_test++ $DATASRC/$TESTFILE $DATAOUT/$TESTFILE.out
+
+echo "Comparing"
+$top_builddir/test/plist_cmp $DATASRC/$TESTFILE $DATAOUT/$TESTFILE.out