diff --git a/unit-test-activity/Intersect.cpp b/unit-test-activity/Intersect.cpp new file mode 100644 index 0000000..70aa8eb --- /dev/null +++ b/unit-test-activity/Intersect.cpp @@ -0,0 +1,408 @@ +// Intersect.cpp - Functions for calculating intersection points of 2D geometry +// Adapted by Chris Bass on 20/10/2021 - originally from: +// https://gist.github.com/sirisian/78196964265c385d81e1599391ebb249 +// http://paulbourke.net/geometry/circlesphere/ +// http://paulbourke.net/geometry/circlesphere/tvoght.c + +#include "Intersect.h" + + +// This is an intersection object for storing the intersection points after a calculation +namespace intersect +{ + // Circle2D to Circle2D + // circlePosition1 - center point of circle1 + // radius1 - radius of circle1 + // circlePosition2 - center point of circle2 + // radius2 - radius of circle2 + // returns - intersection points if there is any intersections + std::vector circle_circle(Vector2D circlePosition1, float radius1, + Vector2D circlePosition2, float radius2) + { + std::vector result; + float a, dx, dy, d, h, rx, ry; + float x2, y2; + + // dx and dy are the vertical and horizontal distances between the circle centers. + dx = circlePosition2.x - circlePosition1.x; + dy = circlePosition2.y - circlePosition1.y; + + // Determine the straight-line distance between the centers. + //d = sqrt((dy*dy) + (dx*dx)); + d = hypot(dx, dy); + + // Check for solvability. + if (d > (radius1 + radius2)) + { + // no solution. circles do not intersect. + return result; + } + if (d < fabs(radius1 - radius2)) + { + // no solution. one circle is contained in the other + return result; + } + + // 'point 2' is the point where the line through the circle + // intersection points crosses the line between the circle centers + // Determine the distance from point 0 to point 2. + a = ((radius1 * radius1) - (radius2 * radius2) + (d * d)) / (2.0f * d); + + // Determine the coordinates of point 2. + x2 = circlePosition1.x + (dx * a / d); + y2 = circlePosition1.y + (dy * a / d); + + // Determine the distance from point 2 to either of the intersection points. + h = sqrt((radius1 * radius1) - (a * a)); + + // Now determine the offsets of the intersection points from point 2. + rx = -dy * (h / d); + ry = dx * (h / d); + + // Determine the absolute intersection points. + result.push_back(Vector2D(x2 + rx, y2 + ry)); + result.push_back(Vector2D(x2 - rx, y2 - ry)); + + return result; + } + + namespace { + // Used only within this namespace - + // using an anonymous namespace means it cannot be seen outside this compilation unit. + int private_line_circle(Vector2D vertex1, Vector2D vertex2, + Vector2D circlePosition, float radius, + Vector2D& solution1, Vector2D& solution2) + { + // Vector from point 1 to point 2 + Vector2D vertex1to2 = vertex2 - vertex1; + // Vector from point 1 to the circle's center + Vector2D circleToVertex1 = circlePosition - vertex1; + + float dot = vertex1to2.dot(circleToVertex1); + Vector2D proj1 = vertex1to2 * (dot / vertex1to2.length_squared()); + + Vector2D midpt = vertex1 + proj1; + Vector2D circleToMidpt = midpt - circlePosition; + float distSqToCenter = circleToMidpt.length_squared(); + if (distSqToCenter > radius * radius) return 0; + if (distSqToCenter == radius * radius) + { + solution1 = midpt; + return 1; + } + float distToIntersection; + if (distSqToCenter == 0) + { + distToIntersection = radius; + } + else + { + distToIntersection = sqrt(radius * radius - distSqToCenter); + } + vertex1to2 = vertex1to2.normalize(); + vertex1to2 *= distToIntersection; + + solution1 = midpt + vertex1to2; + solution2 = midpt - vertex1to2; + return 2; + } + } + + // Line to Circle2D + // vertex1 - Line travels through this point towards infinity + // vertex2 - Line travels through this point towards infinity + // circlePosition - center point of circle + // radius - radius of circle + // returns - intersection points if there is any intersections + std::vector line_circle(Vector2D vertex1, Vector2D vertex2, + Vector2D circlePosition, float radius) + { + std::vector result; + Vector2D solution1, solution2; + switch (private_line_circle(vertex1, vertex2, circlePosition, radius, solution1, solution2)) + { + case 2: + result.push_back(solution2); + case 1: + result.push_back(solution1); + break; + } + return result; + } + + // LineSegment to Circle2D + // vertex1 - Start point of LineSegment + // vertex2 - End point of LineSegment + // circlePosition - center point of circle + // radius - radius of circle + // returns - intersection points if there is any intersections + std::vector linesegment_circle(Vector2D vertex1, Vector2D vertex2, + Vector2D circlePosition, float radius) + { + std::vector result; + Vector2D solution1, solution2; + Vector2D vertex1to2 = vertex2 - vertex1; + Vector2D vertex1ToSolution1, vertex2ToSolution1, vertex1ToSolution2, vertex2ToSolution2; + switch (private_line_circle(vertex1, vertex2, circlePosition, radius, solution1, solution2)) + { + case 2: + vertex1ToSolution2 = solution2 - vertex1; + vertex2ToSolution2 = solution2 - vertex2; + if (vertex1ToSolution2.dot(vertex1to2) > 0 && + vertex2ToSolution2.dot(vertex1to2) < 0) + { + result.push_back(solution2); + } + case 1: + vertex1ToSolution1 = solution1 - vertex1; + vertex2ToSolution1 = solution1 - vertex2; + if (vertex1ToSolution1.dot(vertex1to2) > 0 && + vertex2ToSolution1.dot(vertex1to2) < 0) + { + result.push_back(solution1); + } + break; + } + return result; + } + + // Ray to Circle2D + // vertex1 - Start point of ray + // vertex2 - Ray travels through this point towards infinity + // circlePosition - center point of circle + // radius - radius of circle + // returns - intersection points if there is any intersections + std::vector ray_circle(Vector2D vertex1, Vector2D vertex2, + Vector2D circlePosition, float radius) + { + std::vector result; + Vector2D solution1, solution2; + Vector2D vertex1to2 = vertex2 - vertex1; + Vector2D vertex1ToSolution1, vertex1ToSolution2; + switch (private_line_circle(vertex1, vertex2, circlePosition, radius, solution1, solution2)) + { + case 2: + vertex1ToSolution2 = solution2 - vertex1; + if (vertex1ToSolution2.dot(vertex1to2) > 0) + { + result.push_back(solution2); + } + case 1: + vertex1ToSolution1 = solution1 - vertex1; + if (vertex1ToSolution1.dot(vertex1to2) > 0) + { + result.push_back(solution1); + } + break; + } + return result; + } + + namespace { + // Used only within this namespace - + // using an anonymous namespace means it cannot be seen outside this compilation unit. + bool private_line_line(Vector2D vertex1, Vector2D vertex2, + Vector2D vertex3, Vector2D vertex4, float& r, float& s) + { + float d; + Vector2D vertex1to2 = vertex2 - vertex1; + Vector2D vertex3to4 = vertex4 - vertex3; + + if (vertex1to2.y / vertex1to2.x != vertex3to4.y / vertex3to4.x) // if lines are not parallel + { + d = vertex1to2.x * vertex3to4.y - vertex1to2.y * vertex3to4.x; + if (d != 0) + { + Vector2D vertex3to1 = vertex1 - vertex3; + r = (vertex3to1.y * vertex3to4.x - vertex3to1.x * vertex3to4.y) / d; + s = (vertex3to1.y * vertex1to2.x - vertex3to1.x * vertex1to2.y) / d; + return true; + } + } + return false; + } + } + + // Line to Line + // vertex1 - Line1 travels through this point towards infinity + // vertex2 - Line1 travels through this point towards infinity + // vertex3 - Line2 travels through this point towards infinity + // vertex4 - Line2 travels through this point towards infinity + // returns - intersection points if there is any intersections + std::vector line_line(Vector2D vertex1, Vector2D vertex2, + Vector2D vertex3, Vector2D vertex4) + { + std::vector result; + float r, s; + if (private_line_line(vertex1, vertex2, vertex3, vertex4, r, s)) + { + result.push_back(vertex1 + (vertex2 - vertex1) * r); + } + return result; + } + + // LineSegment to LineSegment + // vertex1 - Start point of LineSegment1 + // vertex2 - End point of LineSegment1 + // vertex3 - Start point of LineSegment2 + // vertex4 - End point of LineSegment2 + // returns - intersection points if there is any intersections + std::vector linesegment_linesegment(Vector2D vertex1, Vector2D vertex2, + Vector2D vertex3, Vector2D vertex4) + { + std::vector result; + float r, s; + if (private_line_line(vertex1, vertex2, vertex3, vertex4, r, s)) + { + if (r >= 0 && r <= 1) + { + if (s >= 0 && s <= 1) + { + result.push_back(vertex1 + (vertex2 - vertex1) * r); + } + } + } + return result; + } + + // LineSegment to Line + // vertex1 - Start point of LineSegment1 + // vertex2 - End point of LineSegment1 + // vertex3 - Line2 travels through this point towards infinity + // vertex4 - Line2 travels through this point towards infinity + // returns - intersection points if there is any intersections + std::vector linesegment_line(Vector2D vertex1, Vector2D vertex2, + Vector2D vertex3, Vector2D vertex4) + { + std::vector result; + float r, s; + if (private_line_line(vertex1, vertex2, vertex3, vertex4, r, s)) + { + if (r >= 0 && r <= 1) + { + result.push_back(vertex1 + (vertex2 - vertex1) * r); + } + } + return result; + } + + // Ray to LineSegment + // vertex1 - Start point of Ray + // vertex2 - Ray travels through this point towards infinity + // vertex3 - Start point of LineSegment2 + // vertex4 - End point of LineSegment2 + // returns - intersection points if there is any intersections + std::vector ray_linesegment(Vector2D vertex1, Vector2D vertex2, + Vector2D vertex3, Vector2D vertex4) + { + std::vector result; + float r, s; + if (private_line_line(vertex1, vertex2, vertex3, vertex4, r, s)) + { + if (r >= 0) + { + if (s >= 0 && s <= 1) + { + result.push_back(vertex1 + (vertex2 - vertex1) * r); + } + } + } + return result; + } + + // Ray to Line + // vertex1 - Start point of Ray + // vertex2 - Ray travels through this point towards infinity + // vertex3 - Line2 travels through this point towards infinity + // vertex4 - Line2 travels through this point towards infinity + // returns - intersection points if there is any intersections + std::vector ray_line(Vector2D vertex1, Vector2D vertex2, + Vector2D vertex3, Vector2D vertex4) + { + std::vector result; + float r, s; + if (private_line_line(vertex1, vertex2, vertex3, vertex4, r, s)) + { + if (r >= 0) + { + result.push_back(vertex1 + (vertex2 - vertex1) * r); + } + } + return result; + } + + // Ray to Ray + // vertex1 - Start point of Ray1 + // vertex2 - Ray1 travels through this point towards infinity + // vertex3 - Start point of Ray2 + // vertex4 - Ray2 travels through this point towards infinity + // returns - intersection points if there is any intersections + std::vector ray_ray(Vector2D vertex1, Vector2D vertex2, + Vector2D vertex3, Vector2D vertex4) + { + std::vector result; + float r, s; + if (private_line_line(vertex1, vertex2, vertex3, vertex4, r, s)) + { + if (r >= 0) + { + if (s >= 0) + { + result.push_back(vertex1 + (vertex2 - vertex1) * r); + } + } + } + return result; + } + + // point to circle tangent, finds the tangent points of a line drawn + // through the point and to the circle tangent. + // point1 - start point of the tangent line + // circlePosition - center point of circle + // radius - radius of circle + // returns - tangent points if there are any tangent points + std::vector point_circle_tangent(Vector2D point1, + Vector2D circlePosition, float radius) { + std::vector result; + + if (radius == 0) { return result; } + + float nx = (point1.x - circlePosition.x) / radius; + float ny = (point1.y - circlePosition.y) / radius; + float xy = nx * nx + ny * ny; + + if (xy == 1.0f) { + // point lies on the circumference + result.push_back(point1); + return result; + } + + if (xy < 1.0f) { + // point lies inside circle, no tangents + return result; + } + + // common case, two tangents + Vector2D tangentPoint0; + Vector2D tangentPoint1; + float d = ny * sqrt(xy - 1.0f); + float tx0 = (nx - d) / xy; + float tx1 = (nx + d) / xy; + if (ny != 0) { + // common case + tangentPoint0.y = circlePosition.y + radius * (1 - tx0 * nx) / ny; + tangentPoint1.y = circlePosition.y + radius * (1 - tx1 * nx) / ny; + } + else { + d = radius * sqrt(1 - tx0 * tx0); + tangentPoint0.y = circlePosition.y + d; + tangentPoint1.y = circlePosition.y - d; + } + tangentPoint0.x = circlePosition.x + radius * tx0; + tangentPoint1.x = circlePosition.x + radius * tx1; + result.push_back(tangentPoint0); + result.push_back(tangentPoint1); + return result; + } + +} diff --git a/unit-test-activity/Intersect.h b/unit-test-activity/Intersect.h new file mode 100644 index 0000000..df473af --- /dev/null +++ b/unit-test-activity/Intersect.h @@ -0,0 +1,116 @@ +// Intersect.h - Functions for calculating intersection points of 2D geometry +// Adapted by Chris Bass on 20/10/2021 - originally from: +// https://gist.github.com/sirisian/78196964265c385d81e1599391ebb249 +// http://paulbourke.net/geometry/circlesphere/ +// http://paulbourke.net/geometry/circlesphere/tvoght.c + +#pragma once + +#include +#include + +#include "Vector2D.h" // .hpp + + +// Intersection functions returns the intersection points after a calculation +namespace intersect +{ + // Circle2D to Circle2D + // circlePosition1 - center point of circle1 + // radius1 - radius of circle1 + // circlePosition2 - center point of circle2 + // radius2 - radius of circle2 + // returns - intersection points if there are any intersections + std::vector circle_circle(Vector2D circlePosition1, float radius1, + Vector2D circlePosition2, float radius2); + + // Line to Circle2D + // vertex1 - Line travels through this point towards infinity + // vertex2 - Line travels through this point towards infinity + // circlePosition - center point of circle + // radius - radius of circle + // returns - intersection points if there are any intersections + std::vector line_circle(Vector2D vertex1, Vector2D vertex2, + Vector2D circlePosition, float radius); + + // LineSegment to Circle2D + // vertex1 - Start point of LineSegment + // vertex2 - End point of LineSegment + // circlePosition - center point of circle + // radius - radius of circle + // returns - intersection points if there are any intersections + std::vector linesegment_circle(Vector2D vertex1, Vector2D vertex2, + Vector2D circlePosition, float radius); + + // Ray to Circle2D + // vertex1 - Start point of ray + // vertex2 - Ray travels through this point towards infinity + // circlePosition - center point of circle + // radius - radius of circle + // returns - intersection points if there are any intersections + std::vector ray_circle(Vector2D vertex1, Vector2D vertex2, + Vector2D circlePosition, float radius); + + // Line to Line + // vertex1 - Line1 travels through this point towards infinity + // vertex2 - Line1 travels through this point towards infinity + // vertex3 - Line2 travels through this point towards infinity + // vertex4 - Line2 travels through this point towards infinity + // returns - intersection points if there are any intersections + std::vector line_line(Vector2D vertex1, Vector2D vertex2, + Vector2D vertex3, Vector2D vertex4); + + // LineSegment to LineSegment + // vertex1 - Start point of LineSegment1 + // vertex2 - End point of LineSegment1 + // vertex3 - Start point of LineSegment2 + // vertex4 - End point of LineSegment2 + // returns - intersection points if there are any intersections + std::vector linesegment_linesegment(Vector2D vertex1, Vector2D vertex2, + Vector2D vertex3, Vector2D vertex4); + + // LineSegment to Line + // vertex1 - Start point of LineSegment1 + // vertex2 - End point of LineSegment1 + // vertex3 - Line2 travels through this point towards infinity + // vertex4 - Line2 travels through this point towards infinity + // returns - intersection points if there are any intersections + std::vector linesegment_line(Vector2D vertex1, Vector2D vertex2, + Vector2D vertex3, Vector2D vertex4); + + // Ray to LineSegment + // vertex1 - Start point of Ray + // vertex2 - Ray travels through this point towards infinity + // vertex3 - Start point of LineSegment2 + // vertex4 - End point of LineSegment2 + // returns - intersection points if there are any intersections + std::vector ray_linesegment(Vector2D vertex1, Vector2D vertex2, + Vector2D vertex3, Vector2D vertex4); + + // Ray to Line + // vertex1 - Start point of Ray + // vertex2 - Ray travels through this point towards infinity + // vertex3 - Line2 travels through this point towards infinity + // vertex4 - Line2 travels through this point towards infinity + // returns - intersection points if there are any intersections + std::vector ray_line(Vector2D vertex1, Vector2D vertex2, + Vector2D vertex3, Vector2D vertex4); + + // Ray to Ray + // vertex1 - Start point of Ray1 + // vertex2 - Ray1 travels through this point towards infinity + // vertex3 - Start point of Ray2 + // vertex4 - Ray2 travels through this point towards infinity + // returns - intersection points if there are any intersections + std::vector ray_ray(Vector2D vertex1, Vector2D vertex2, + Vector2D vertex3, Vector2D vertex4); + + // point to circle tangent, finds the tangent points of a line drawn + // through the point and to the circle tangent. + // point1 - start point of the tangent line + // circlePosition - center point of circle + // radius - radius of circle + // returns - tangent points if there are any tangent points + std::vector point_circle_tangent(Vector2D point1, + Vector2D circlePosition, float radius); +} diff --git a/unit-test-activity/Rectangle2D.h b/unit-test-activity/Rectangle2D.h new file mode 100644 index 0000000..387c834 --- /dev/null +++ b/unit-test-activity/Rectangle2D.h @@ -0,0 +1,60 @@ + +#pragma once +#include "Vector2D.h" +#include "Intersect.h" + +class Rectangle2D +{ +public: + Vector2D topLeft; + Vector2D bottomRight; + + // constructor - create a Rectangle as defined by 2x 2d points + Rectangle2D(Vector2D topLeft, Vector2D bottomRight) : + topLeft(topLeft), bottomRight(bottomRight) { } + + Rectangle2D(float topLeftX, float topLeftY, float bottomRightX, float bottomRightY) : + topLeft(topLeftX, topLeftY), bottomRight(bottomRightX, bottomRightY) { } + + Vector2D get_top_right() { + return Vector2D(bottomRight.x, topLeft.y); + } + + Vector2D get_bottom_left() { + return Vector2D(topLeft.x, bottomRight.y); + } + + // makes the rectangle smaller on all sizes by a fixed amount + Rectangle2D& shrink(float amount) { + Vector2D editTopLeft = topLeft + amount; + Vector2D editBottomRight = bottomRight - amount; + if (editTopLeft.x < editBottomRight.x || editTopLeft.y < editBottomRight.y) { + // okay - top left is still top left, keep the changes + topLeft = editTopLeft; + bottomRight = editBottomRight; + } + // else dont shrink below size 0, cancel operaton, do nothing + return *this; + } + + // returns the intersection point(s) between this rectangle and a ray + // ray1 - is the start point of the ray + // ray2 - ray travels through this point towards infinity + // returns - a vector of intersection point(s) between this ray and this rectangle + std::vector ray_intersect(Vector2D ray1, Vector2D ray2) { + Vector2D topRight(bottomRight.x, topLeft.y); + Vector2D bottomLeft(topLeft.x, bottomRight.y); + + std::vector top = intersect::ray_linesegment(ray1, ray2, topLeft, topRight); + std::vector bottom = intersect::ray_linesegment(ray1, ray2, bottomLeft, bottomRight); + std::vector left = intersect::ray_linesegment(ray1, ray2, topLeft, bottomLeft); + std::vector right = intersect::ray_linesegment(ray1, ray2, topRight, bottomRight); + std::vector result; + result.insert(result.end(), top.begin(), top.end()); + result.insert(result.end(), bottom.begin(), bottom.end()); + result.insert(result.end(), left.begin(), left.end()); + result.insert(result.end(), right.begin(), right.end()); + return result; + } +}; + diff --git a/unit-test-activity/Vector2D.h b/unit-test-activity/Vector2D.h new file mode 100644 index 0000000..d5f5843 --- /dev/null +++ b/unit-test-activity/Vector2D.h @@ -0,0 +1,108 @@ +// Vector2D.h - Vector2D class for storing a 2D vector (geometry) with some useful vector maths +// Adapted by Chris Bass on 20/10/2021 - originally from: +// https://codereview.stackexchange.com/questions/11934/c-vector2-class-review + +#pragma once + +#include +#include + +// class used to represent a 2D vector, or sometimes used for a 2D point as well. +class Vector2D +{ +public: + float x, y; + + // constructor - default values are 0.0f, 0.0f + Vector2D(float xVal = 0.0f, float yVal = 0.0f) : x(xVal), y(yVal) { } + + // returns - length of the vector squared. + float length_squared() const { return x * x + y * y; } + + // returns - length of the vector. + float length() const { return sqrt(length_squared()); } + + // v2 - the vector to dot product against. + // returns - length of the vector squared. + float dot(const Vector2D& v2) { return ((x * v2.x) + (y * v2.y)); } + + // normalises and returns - a normalised vector i.e. a vector of unit length + const Vector2D& normalize() { + float len = length(); + if (len < FLT_EPSILON) { + x = y = 0; + return *this; + } + else { + float invLen = 1.0 / len; + x *= invLen; + y *= invLen; + return *this; + } + } + + //assingment operators + Vector2D& operator = (const Vector2D& v) { x = v.x; y = v.y; return *this; } + Vector2D& operator = (const float& s) { x = s; y = s; return *this; } + Vector2D& operator - (void) { x = -x; y = -y; return *this; } + + //equality operators + bool operator == (const Vector2D& v) const { return (x == v.x) && (y == v.y); } + bool operator != (const Vector2D& v) const { return !(*this == v); } + + //vector2 to this operators + Vector2D& operator += (const Vector2D& v) { x += v.x; y += v.y; return *this; } + Vector2D& operator -= (const Vector2D& v) { x -= v.x; y -= v.y; return *this; } + Vector2D& operator *= (const Vector2D& v) { x *= v.x; y *= v.y; return *this; } + Vector2D& operator /= (const Vector2D& v) { x /= v.x; y /= v.y; return *this; } + + //vector2 to vector2 operators + const Vector2D operator + (const Vector2D& v) const { Vector2D r(*this); return r += v; } + const Vector2D operator - (const Vector2D& v) const { Vector2D r(*this); return r -= v; } + const Vector2D operator * (const Vector2D& v) const { Vector2D r(*this); return r *= v; } + const Vector2D operator / (const Vector2D& v) const { Vector2D r(*this); return r /= v; } + + //scaler to this operators + Vector2D& operator += (float s) { x += s; y += s; return *this; } + Vector2D& operator -= (float s) { x -= s; y -= s; return *this; } + Vector2D& operator *= (float s) { x *= s; y *= s; return *this; } + Vector2D& operator /= (float s) { x /= s; y /= s; return *this; } + + //scaler to vector2 operators + const Vector2D operator + (float s) const { Vector2D r(*this); return r += s; } + const Vector2D operator - (float s) const { Vector2D r(*this); return r -= s; } + const Vector2D operator * (float s) const { Vector2D r(*this); return r *= s; } + const Vector2D operator / (float s) const { Vector2D r(*this); return r /= s; } + + //static methods + // returns - distance between point1 and point2 squared + static float distance_squared(const Vector2D& v1, const Vector2D& v2) + { + return ((v1.x - v2.x) * (v1.x - v2.x)) + ((v1.y - v2.y) * (v1.y - v2.y)); + } + + // returns - distance between point1 and point2 + static float distance(const Vector2D& v1, const Vector2D& v2) + { + return sqrt(distance_squared(v1, v2)); + } + + // returns - dot product of v1 and v2 + static float dot(const Vector2D& v1, const Vector2D& v2) + { + return ((v1.x * v2.x) + (v1.y * v2.y)); + } + + // given a line defined by startPoint and endPoint return a new point a distance away from the end point + static Vector2D projectPoint(Vector2D startPoint, Vector2D endPoint, float projectDistance) { + Vector2D line = endPoint - startPoint; + Vector2D projectedPoint = endPoint + line.normalize() * projectDistance; + return projectedPoint; + } + + // the other one that might be useful is projecting a point until crossing another line, i.e. raycast until hitting a wall then stop and create a point. this will be part of the intersection code i think. + + //friend operators + friend std::ostream& operator << (std::ostream& os, const Vector2D& v) { return os << "{" << v.x << ", " << v.y << "}"; } + +}; //end vector2 diff --git a/unit-test-activity/main.cpp b/unit-test-activity/main.cpp new file mode 100644 index 0000000..62c9231 --- /dev/null +++ b/unit-test-activity/main.cpp @@ -0,0 +1,15 @@ + +#include +#include "Intersect.h" +#include "Rectangle2D.h" + +int main() +{ + std::cout << "Hello Unit Testing!" << std::endl; + + std::cout << "This project contains a few Classes, Methods, and Functions " << + "which require a unit test suite written for them." << std::endl; + + return 0; +} + diff --git a/unit-test-activity/unit-test-activity.sln b/unit-test-activity/unit-test-activity.sln new file mode 100644 index 0000000..9a4a5e3 --- /dev/null +++ b/unit-test-activity/unit-test-activity.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31205.134 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unit-test-activity", "unit-test-activity.vcxproj", "{6D1C6CF1-5633-49DF-A641-3BC2D056079C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6D1C6CF1-5633-49DF-A641-3BC2D056079C}.Debug|x64.ActiveCfg = Debug|x64 + {6D1C6CF1-5633-49DF-A641-3BC2D056079C}.Debug|x64.Build.0 = Debug|x64 + {6D1C6CF1-5633-49DF-A641-3BC2D056079C}.Debug|x86.ActiveCfg = Debug|Win32 + {6D1C6CF1-5633-49DF-A641-3BC2D056079C}.Debug|x86.Build.0 = Debug|Win32 + {6D1C6CF1-5633-49DF-A641-3BC2D056079C}.Release|x64.ActiveCfg = Release|x64 + {6D1C6CF1-5633-49DF-A641-3BC2D056079C}.Release|x64.Build.0 = Release|x64 + {6D1C6CF1-5633-49DF-A641-3BC2D056079C}.Release|x86.ActiveCfg = Release|Win32 + {6D1C6CF1-5633-49DF-A641-3BC2D056079C}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {416A12F3-C2FA-477C-903B-47D7095379E0} + EndGlobalSection +EndGlobal diff --git a/unit-test-activity/unit-test-activity.vcxproj b/unit-test-activity/unit-test-activity.vcxproj new file mode 100644 index 0000000..7b9ac10 --- /dev/null +++ b/unit-test-activity/unit-test-activity.vcxproj @@ -0,0 +1,153 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {6d1c6cf1-5633-49df-a641-3bc2d056079c} + unittestactivity + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/unit-test-activity/unit-test-activity.vcxproj.filters b/unit-test-activity/unit-test-activity.vcxproj.filters new file mode 100644 index 0000000..cf373a2 --- /dev/null +++ b/unit-test-activity/unit-test-activity.vcxproj.filters @@ -0,0 +1,36 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file