diff --git a/LanguageRecogniser/Cpp/CppClassDiagramVisitor.cs b/LanguageRecogniser/Cpp/CppClassDiagramVisitor.cs index ba6ae40fa7b54b4a3a514656b2b7a0206949d067..4142461a70d4c6fb7dc8d75e6501daf26259a13e 100644 --- a/LanguageRecogniser/Cpp/CppClassDiagramVisitor.cs +++ b/LanguageRecogniser/Cpp/CppClassDiagramVisitor.cs @@ -144,8 +144,8 @@ public class CppClassDiagramVisitor : CPP14ParserBaseVisitor<object> string compositionPattern = @"^(?:std::)?(?:vector<)?(\w+)>?$"; // Check if the property type matches aggregation or composition - Match aggregationMatch = Regex.Match(atribute.Type, aggregationPattern, RegexOptions.NonBacktracking); - Match compositionMatch = Regex.Match(atribute.Type, compositionPattern, RegexOptions.NonBacktracking); + Match aggregationMatch = Regex.Match(atribute.Type, aggregationPattern, RegexOptions.Compiled); + Match compositionMatch = Regex.Match(atribute.Type, compositionPattern, RegexOptions.Compiled); int groupMatch = 1; if (aggregationMatch.Success && !string.IsNullOrEmpty(aggregationMatch.Groups[groupMatch].Value)) { diff --git a/UnitTest/Input/main.cpp b/UnitTest/Input/main.cpp index 0bbf9904455864ca5d5c4984eb6d66689d43625d..c85c1ad6ad828f2d422c71091186a5322fc02b01 100644 --- a/UnitTest/Input/main.cpp +++ b/UnitTest/Input/main.cpp @@ -11,13 +11,48 @@ namespace MyNamespace { std::cout << "Name: " << name << ", Age: " << age << std::endl; } }; + + class Student : public Person + { + private: + std::string login; + + void changeLogin(std::string newLogin) { + login = newLogin; + return; + } + }; + + class Teacher : public Person + { + public: + //vector of students + std::vector<Student> students; + + }; } int main() { - MyNamespace::Person person1; + MyNamespace::Student person1; person1.name = "John"; person1.age = 25; person1.displayInfo(); + if(person1.age > 18) { + std::cout << "Student is an adult" << std::endl; + int i = 0; + while(i < 10) { + std::cout << "i = " << i << std::endl; + i++; + } + } else { + std::cout << "Student is not an adult" << std::endl; + if(person1.age < 10) { + std::cout << "Student is a child" << std::endl; + } else { + std::cout << "Student is not a child" << std::endl; + } + } + return 0; } \ No newline at end of file diff --git a/UnitTest/WebApiTests.cs b/UnitTest/WebApiTests.cs index 2ec6ad8fe3f63b94e00a7c2b07d39147aaa04a48..8394d02b9ead18e703f7b9eb9e488745bb30073c 100644 --- a/UnitTest/WebApiTests.cs +++ b/UnitTest/WebApiTests.cs @@ -1,9 +1,7 @@ using System.Text; using Database; -using Microsoft.AspNetCore.Http.HttpResults; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; -using NUnit.Framework.Constraints; using WebAPI.Controllers; using WebAPI.DTO; using WebAPI.DTO.External; @@ -257,7 +255,7 @@ public class WebApiTests [TestCase(true)] [TestCase(false)] - public void UploadCodeAndTransform(bool getValidToken) + public void UploadCodeListTransformRemoveList(bool getValidToken) { string token = string.Empty; if (getValidToken) @@ -293,6 +291,9 @@ public class WebApiTests ListOne(true, 1, true); ConvertToActivityDiagram(true, 1, true); ConvertToClassDiagram(true, 1, true); + RemoveCode(true, 1, true); + ListAll(true, 0); + ListOne(true, 1, false); } else { @@ -445,7 +446,57 @@ public class WebApiTests } #endregion - + + #region Remove Code Tests + + [TestCase(true, -1, false)] + [TestCase(false, -1, false)] + public void RemoveCode(bool getValidToken, int id, bool codeExists) + { + string token = string.Empty; + if (getValidToken) + { + token = GetToken(TestUserAuthenticationProcedure()); + } + else + { + token = "WrongToken"; + } + var path = Path.Join(Directory.GetCurrentDirectory(), "users.json"); + ApiController apiController = new ApiController(null, null, path); + var model = new RemoveCodeModel() + { + Id = id, + Token = token + }; + var result = apiController.RemoveCode(model); + if (getValidToken) + { + if (codeExists) + { + Assert.IsTrue(result is OkObjectResult); + var okResult = result as OkObjectResult; + Assert.IsTrue(okResult.Value is string); + Assert.IsTrue(okResult.Value as string == "Code removed"); + } + else + { + Assert.IsTrue(result is NotFoundObjectResult); + var okResult = result as NotFoundObjectResult; + Assert.IsTrue(okResult.Value is string); + Assert.IsTrue(okResult.Value as string == "Code does not exist"); + } + + } + else + { + Assert.IsTrue(result is BadRequestObjectResult); + var okResult = result as BadRequestObjectResult; + Assert.IsTrue(okResult.Value is string); + Assert.IsTrue(okResult.Value as string == "Invalid token"); + } + } + #endregion private string GetToken(string authResult) { //parse guid from authResult