summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt2
-rw-r--r--tests/cgalpngtest.cc26
-rw-r--r--tests/cgaltest.cc26
-rw-r--r--tests/csgtermtest.cc27
-rw-r--r--tests/csgtexttest.cc26
-rw-r--r--tests/dumptest.cc26
-rw-r--r--tests/opencsgtest.cc32
7 files changed, 45 insertions, 120 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index c274435..af64772 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -79,6 +79,8 @@ include_directories(../src)
add_definitions(-DOPENSCAD_VERSION=test)
set(COMMON_SOURCES
+ ../src/handle_dep.cc
+ ../src/qhash.cc
../src/export.cc
../src/value.cc
../src/expr.cc
diff --git a/tests/cgalpngtest.cc b/tests/cgalpngtest.cc
index a93d564..89f1bc9 100644
--- a/tests/cgalpngtest.cc
+++ b/tests/cgalpngtest.cc
@@ -40,6 +40,7 @@
#include "CGAL_renderer.h"
#include "cgal.h"
#include "OffscreenView.h"
+#include "handle_dep.h"
#include <QApplication>
#include <QFile>
@@ -49,29 +50,15 @@
#include <getopt.h>
#include <iostream>
#include <assert.h>
+#include <sstream>
-QString commandline_commands;
-const char *make_command = NULL;
-QSet<QString> dependencies;
+std::string commandline_commands;
QString currentdir;
QString examplesdir;
QString librarydir;
using std::string;
-void handle_dep(QString filename)
-{
- if (filename.startsWith("/"))
- dependencies.insert(filename);
- else
- dependencies.insert(QDir::currentPath() + QString("/") + filename);
- if (!QFile(filename).exists() && make_command) {
- char buffer[4096];
- snprintf(buffer, 4096, "%s '%s'", make_command, filename.replace("'", "'\\''").toUtf8().data());
- system(buffer); // FIXME: Handle error
- }
-}
-
// FIXME: enforce some maximum cache size (old version had 100K vertices as limit)
QHash<std::string, CGAL_Nef_polyhedron> cache;
@@ -153,15 +140,16 @@ int main(int argc, char **argv)
fprintf(stderr, "Can't open input file `%s'!\n", filename);
exit(1);
} else {
- QString text;
+ std::stringstream text;
char buffer[513];
int ret;
while ((ret = fread(buffer, 1, 512, fp)) > 0) {
buffer[ret] = 0;
- text += buffer;
+ text << buffer;
}
fclose(fp);
- root_module = parse((text+commandline_commands).toAscii().data(), fileInfo.absolutePath().toLocal8Bit(), false);
+ text << commandline_commands;
+ root_module = parse(text.str().c_str(), fileInfo.absolutePath().toLocal8Bit(), false);
if (!root_module) {
exit(1);
}
diff --git a/tests/cgaltest.cc b/tests/cgaltest.cc
index 9d4ef5d..44e87f9 100644
--- a/tests/cgaltest.cc
+++ b/tests/cgaltest.cc
@@ -25,6 +25,7 @@
#include "myqhash.h"
#include "openscad.h"
+#include "handle_dep.h"
#include "node.h"
#include "module.h"
#include "context.h"
@@ -44,29 +45,15 @@
#include <getopt.h>
#include <iostream>
#include <assert.h>
+#include <sstream>
-QString commandline_commands;
-const char *make_command = NULL;
-QSet<QString> dependencies;
+std::string commandline_commands;
QString currentdir;
QString examplesdir;
QString librarydir;
using std::string;
-void handle_dep(QString filename)
-{
- if (filename.startsWith("/"))
- dependencies.insert(filename);
- else
- dependencies.insert(QDir::currentPath() + QString("/") + filename);
- if (!QFile(filename).exists() && make_command) {
- char buffer[4096];
- snprintf(buffer, 4096, "%s '%s'", make_command, filename.replace("'", "'\\''").toUtf8().data());
- system(buffer); // FIXME: Handle error
- }
-}
-
// FIXME: enforce some maximum cache size (old version had 100K vertices as limit)
QHash<std::string, CGAL_Nef_polyhedron> cache;
@@ -143,15 +130,16 @@ int main(int argc, char **argv)
fprintf(stderr, "Can't open input file `%s'!\n", filename);
exit(1);
} else {
- QString text;
+ std::stringstream text;
char buffer[513];
int ret;
while ((ret = fread(buffer, 1, 512, fp)) > 0) {
buffer[ret] = 0;
- text += buffer;
+ text << buffer;
}
fclose(fp);
- root_module = parse((text+commandline_commands).toAscii().data(), fileInfo.absolutePath().toLocal8Bit(), false);
+ text << commandline_commands;
+ root_module = parse(text.str().c_str(), fileInfo.absolutePath().toLocal8Bit(), false);
if (!root_module) {
exit(1);
}
diff --git a/tests/csgtermtest.cc b/tests/csgtermtest.cc
index 42d22a0..26b809a 100644
--- a/tests/csgtermtest.cc
+++ b/tests/csgtermtest.cc
@@ -23,9 +23,11 @@
*
*/
+#include "myqhash.h"
#include "CSGTermEvaluator.h"
#include "CSGTextCache.h"
#include "openscad.h"
+#include "handle_dep.h"
#include "node.h"
#include "module.h"
#include "context.h"
@@ -42,29 +44,15 @@
#include <getopt.h>
#include <assert.h>
#include <iostream>
+#include <sstream>
using std::cout;
-QString commandline_commands;
-const char *make_command = NULL;
-QSet<QString> dependencies;
+std::string commandline_commands;
QString currentdir;
QString examplesdir;
QString librarydir;
-void handle_dep(QString filename)
-{
- if (filename.startsWith("/"))
- dependencies.insert(filename);
- else
- dependencies.insert(QDir::currentPath() + QString("/") + filename);
- if (!QFile(filename).exists() && make_command) {
- char buffer[4096];
- snprintf(buffer, 4096, "%s '%s'", make_command, filename.replace("'", "'\\''").toUtf8().data());
- system(buffer); // FIXME: Handle error
- }
-}
-
int main(int argc, char **argv)
{
if (argc != 2) {
@@ -131,15 +119,16 @@ int main(int argc, char **argv)
fprintf(stderr, "Can't open input file `%s'!\n", filename);
exit(1);
} else {
- QString text;
+ std::stringstream text;
char buffer[513];
int ret;
while ((ret = fread(buffer, 1, 512, fp)) > 0) {
buffer[ret] = 0;
- text += buffer;
+ text << buffer;
}
fclose(fp);
- root_module = parse((text+commandline_commands).toAscii().data(), fileInfo.absolutePath().toLocal8Bit(), false);
+ text << commandline_commands;
+ root_module = parse(text.str().c_str(), fileInfo.absolutePath().toLocal8Bit(), false);
if (!root_module) {
exit(1);
}
diff --git a/tests/csgtexttest.cc b/tests/csgtexttest.cc
index c259e2d..3c4451d 100644
--- a/tests/csgtexttest.cc
+++ b/tests/csgtexttest.cc
@@ -26,6 +26,7 @@
#include "CSGTextRenderer.h"
#include "CSGTextCache.h"
#include "openscad.h"
+#include "handle_dep.h"
#include "node.h"
#include "module.h"
#include "context.h"
@@ -41,27 +42,13 @@
#include <getopt.h>
#include <assert.h>
#include <iostream>
+#include <sstream>
-QString commandline_commands;
-const char *make_command = NULL;
-QSet<QString> dependencies;
+std::string commandline_commands;
QString currentdir;
QString examplesdir;
QString librarydir;
-void handle_dep(QString filename)
-{
- if (filename.startsWith("/"))
- dependencies.insert(filename);
- else
- dependencies.insert(QDir::currentPath() + QString("/") + filename);
- if (!QFile(filename).exists() && make_command) {
- char buffer[4096];
- snprintf(buffer, 4096, "%s '%s'", make_command, filename.replace("'", "'\\''").toUtf8().data());
- system(buffer); // FIXME: Handle error
- }
-}
-
void csgTree(CSGTextCache &cache, const AbstractNode &root)
{
CSGTextRenderer renderer(cache);
@@ -135,15 +122,16 @@ int main(int argc, char **argv)
fprintf(stderr, "Can't open input file `%s'!\n", filename);
exit(1);
} else {
- QString text;
+ std::stringstream text;
char buffer[513];
int ret;
while ((ret = fread(buffer, 1, 512, fp)) > 0) {
buffer[ret] = 0;
- text += buffer;
+ text << buffer;
}
fclose(fp);
- root_module = parse((text+commandline_commands).toAscii().data(), fileInfo.absolutePath().toLocal8Bit(), false);
+ text << commandline_commands;
+ root_module = parse(text.str().c_str(), fileInfo.absolutePath().toLocal8Bit(), false);
if (!root_module) {
exit(1);
}
diff --git a/tests/dumptest.cc b/tests/dumptest.cc
index 3f6068a..9af7154 100644
--- a/tests/dumptest.cc
+++ b/tests/dumptest.cc
@@ -25,6 +25,7 @@
*/
#include "openscad.h"
+#include "handle_dep.h"
#include "node.h"
#include "module.h"
#include "context.h"
@@ -41,29 +42,15 @@
#include <getopt.h>
#include <assert.h>
#include <iostream>
+#include <sstream>
using std::string;
-QString commandline_commands;
-const char *make_command = NULL;
-QSet<QString> dependencies;
+std::string commandline_commands;
QString currentdir;
QString examplesdir;
QString librarydir;
-void handle_dep(QString filename)
-{
- if (filename.startsWith("/"))
- dependencies.insert(filename);
- else
- dependencies.insert(QDir::currentPath() + QString("/") + filename);
- if (!QFile(filename).exists() && make_command) {
- char buffer[4096];
- snprintf(buffer, 4096, "%s '%s'", make_command, filename.replace("'", "'\\''").toUtf8().data());
- system(buffer); // FIXME: Handle error
- }
-}
-
int main(int argc, char **argv)
{
if (argc != 2) {
@@ -130,15 +117,16 @@ int main(int argc, char **argv)
fprintf(stderr, "Can't open input file `%s'!\n", filename);
exit(1);
} else {
- QString text;
+ std::stringstream text;
char buffer[513];
int ret;
while ((ret = fread(buffer, 1, 512, fp)) > 0) {
buffer[ret] = 0;
- text += buffer;
+ text << buffer;
}
fclose(fp);
- root_module = parse((text+commandline_commands).toAscii().data(), fileInfo.absolutePath().toLocal8Bit(), false);
+ text << commandline_commands;
+ root_module = parse(text.str().c_str(), fileInfo.absolutePath().toLocal8Bit(), false);
if (!root_module) {
exit(1);
}
diff --git a/tests/opencsgtest.cc b/tests/opencsgtest.cc
index cbf07e8..b946b4f 100644
--- a/tests/opencsgtest.cc
+++ b/tests/opencsgtest.cc
@@ -1,5 +1,6 @@
#include <GL/glew.h>
#include "openscad.h"
+#include "handle_dep.h"
#include "builtin.h"
#include "context.h"
#include "node.h"
@@ -21,36 +22,16 @@
#include <QDir>
#include <QSet>
#include <QTimer>
+#include <sstream>
using std::cerr;
using std::cout;
-QString commandline_commands;
+std::string commandline_commands;
QString librarydir;
-QSet<QString> dependencies;
-const char *make_command = NULL;
//#define DEBUG
-void handle_dep(QString filename)
-{
- if (filename.startsWith("/"))
- dependencies.insert(filename);
- else
- dependencies.insert(QDir::currentPath() + QString("/") + filename);
- if (!QFile(filename).exists() && make_command) {
- char buffer[4096];
- snprintf(buffer, 4096, "%s '%s'", make_command, filename.replace("'", "'\\''").toUtf8().data());
- system(buffer); // FIXME: Handle error
- }
-}
-
-// static void renderfunc(void *vp)
-// {
-// glClearColor(1.0, 0.0, 0.0, 0.0);
-// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
-// }
-
struct CsgInfo
{
CSGTerm *root_norm_term; // Normalized CSG products
@@ -127,15 +108,16 @@ int main(int argc, char *argv[])
fprintf(stderr, "Can't open input file `%s'!\n", filename);
exit(1);
} else {
- QString text;
+ std::stringstream text;
char buffer[513];
int ret;
while ((ret = fread(buffer, 1, 512, fp)) > 0) {
buffer[ret] = 0;
- text += buffer;
+ text << buffer;
}
fclose(fp);
- root_module = parse((text+commandline_commands).toAscii().data(), fileInfo.absolutePath().toLocal8Bit(), false);
+ text << commandline_commands;
+ root_module = parse(text.str().c_str(), fileInfo.absolutePath().toLocal8Bit(), false);
if (!root_module) {
exit(1);
}
contact: Jan Huwald // Impressum