diff options
Diffstat (limited to 'src/it/it0015-cpp-executable/src/main/c++/Executable.cpp')
-rw-r--r-- | src/it/it0015-cpp-executable/src/main/c++/Executable.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
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; +} + + |