summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/it/it0015-cpp-executable/pom.xml63
-rw-r--r--src/it/it0015-cpp-executable/src/main/c++/Executable.cpp57
-rw-r--r--src/it/it0015-cpp-executable/src/main/c++/example.cxx28
-rw-r--r--src/it/it0015-cpp-executable/src/main/include/example.h39
4 files changed, 187 insertions, 0 deletions
diff --git a/src/it/it0015-cpp-executable/pom.xml b/src/it/it0015-cpp-executable/pom.xml
new file mode 100644
index 0000000..84b1f8c
--- /dev/null
+++ b/src/it/it0015-cpp-executable/pom.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.its.nar</groupId>
+ <artifactId>it-parent</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <relativePath>../it-parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>it0015-cpp-executable</artifactId>
+ <packaging>nar</packaging>
+
+ <name>Maven NAR C++ Executable Test</name>
+ <version>1.0-SNAPSHOT</version>
+ <description>
+ Simple c++ test executable
+ </description>
+ <url>http://maven.apache.org/</url>
+
+ <properties>
+ <skipTests>true</skipTests>
+ </properties>
+
+ <build>
+ <defaultGoal>integration-test</defaultGoal>
+ <plugins>
+ <plugin>
+ <artifactId>maven-nar-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <libraries>
+ <library>
+ <type>executable</type>
+ <run>true</run>
+ </library>
+ </libraries>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/src/it/it0015-cpp-executable/src/main/c++/Executable.cpp b/src/it/it0015-cpp-executable/src/main/c++/Executable.cpp
new file mode 100644
index 0000000..976ffb8
--- /dev/null
+++ b/src/it/it0015-cpp-executable/src/main/c++/Executable.cpp
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <stdio.h>
+#include <example.h>
+
+extern "C"
+int main(int argc, char *argv[]) {
+ Circle* c = new Circle(10);
+ Square* s = new Square(10);
+
+ if (Shape::nshapes != 2) return 1;
+
+ c->x = 20;
+ c->y = 30;
+
+ Shape* shape = s;
+ shape->x = -10;
+ shape->y = 5;
+
+ if (c->x != 20.0) return 2;
+ if (c->y != 30.0) return 3;
+ if (s->x != -10.0) return 4;
+ if (s->y != 5.0) return 5;
+
+ Shape* shapes[] = { c, s };
+
+ if (shapes[0]->area() - 314.1592653589793 > 0.0001) return 6;
+ if (shapes[0]->perimeter() - 62.83185307179586 > 0.0001) return 7;
+ if (shapes[1]->area() - 100.0 > 0.0001) return 8;
+ if (shapes[1]->perimeter() - 40.0 > 0.0001) return 9;
+
+ delete c;
+ delete s;
+
+ if (Shape::nshapes != 0) return 10;
+
+ return 0;
+}
+
+
diff --git a/src/it/it0015-cpp-executable/src/main/c++/example.cxx b/src/it/it0015-cpp-executable/src/main/c++/example.cxx
new file mode 100644
index 0000000..1e8e203
--- /dev/null
+++ b/src/it/it0015-cpp-executable/src/main/c++/example.cxx
@@ -0,0 +1,28 @@
+/* File : example.c */
+
+#include "example.h"
+#define M_PI 3.14159265358979323846
+
+/* Move the shape to a new location */
+void Shape::move(double dx, double dy) {
+ x += dx;
+ y += dy;
+}
+
+int Shape::nshapes = 0;
+
+double Circle::area(void) {
+ return M_PI*radius*radius;
+}
+
+double Circle::perimeter(void) {
+ return 2*M_PI*radius;
+}
+
+double Square::area(void) {
+ return width*width;
+}
+
+double Square::perimeter(void) {
+ return 4*width;
+}
diff --git a/src/it/it0015-cpp-executable/src/main/include/example.h b/src/it/it0015-cpp-executable/src/main/include/example.h
new file mode 100644
index 0000000..46d9013
--- /dev/null
+++ b/src/it/it0015-cpp-executable/src/main/include/example.h
@@ -0,0 +1,39 @@
+/* File : example.h */
+
+class Shape {
+public:
+ Shape() {
+ nshapes++;
+ }
+ virtual ~Shape() {
+ nshapes--;
+ };
+ double x, y;
+ void move(double dx, double dy);
+ virtual double area(void) = 0;
+ virtual double perimeter(void) = 0;
+ static int nshapes;
+};
+
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ Circle(double r) : radius(r) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+class Square : public Shape {
+private:
+ double width;
+public:
+ Square(double w) : width(w) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+
+
+
+