public void PureVirtual() { string code = "virtual int XYZ() = 0;"; TestContext context = CCCParserTests.SetupContext(code); context.NextFunction(); }
public void TemplateStatementIsConsumed() { string code = "template <typename X, class Y>NEXT"; TestContext context = CCCParserTests.SetupContext(code); context.ccc.ConsumeTemplate(); Assert.AreEqual("NEXT", context.parser.PeekNextKeyword()); }
public void FunctionWithOperatorNameIsNotAnOperator() { string code = "bool isoperator(int ch) { return false; }"; TestContext context = CCCParserTests.SetupContext(code, true); Assert.AreEqual("isoperator", context.NextFunction()); }
public void CppStyleForwardDeclared() { string code = "int X::Deliver() const;"; TestContext context = CCCParserTests.SetupContext(code); context.NextFunction(); }
public void CStyleForwardDeclared() { string code = "int Deliver(int y, int x);"; TestContext context = CCCParserTests.SetupContext(code); context.NextFunction(); }
public void TestMethodNameWithGenericsAndParameterWithGenericsIsReturnedAsFunction() { string code = "TypeX<T>(TypeY<T> sourceArray){}"; TestContext context = CCCParserTests.SetupContext(code); Assert.IsTrue(context.NextIsFunction()); Assert.AreEqual("TypeX<T>(TypeY<T> sourceArray)", context.NextFunction()); }
public void FunctionWithGeneric() { string code = "CreateVariable<T>(string name) {}"; TestContext context = CCCParserTests.SetupContext(code); Assert.AreEqual("CreateVariable<T>(string name)", context.NextFunction()); }
public void MethodPreceededByTabIsRecognized() { string code = "int\tFoo() { "; TestContext context = CCCParserTests.SetupContext(code, true); Assert.AreEqual("Foo", context.NextFunction()); }
public void TestFunctionNotRecognizedAsClass() { string code = "void ClassFunc();"; TestContext context = CCCParserTests.SetupContext(code); Assert.AreEqual(false, context.NextIsClass()); }
public void FullNamespaceQualifiedCppFunctionIsFound() { string code = "void xxx::yyy::zzz::MyFoo::Bar(void) { }"; TestContext context = CCCParserTests.SetupContext(code); Assert.AreEqual("xxx::yyy::zzz::MyFoo::Bar(void)", context.NextFunction()); }
public void TestNextIsClass() { string code = "class CMyClass {"; //forward declaration TestContext context = CCCParserTests.SetupContext(code); Assert.AreEqual(true, context.NextIsClass()); }
public void TestOnlyReturnNameWhenAskedToSkipSignature() { string code = "void CMyClass::Function(int j, double d, const X& x){}"; TestContext context = CCCParserTests.SetupContext(code, true); Assert.AreEqual("CMyClass::Function", context.NextFunction()); }
public void TestVoidOperator() { string code = "operator()(void const*) const {}"; TestContext context = CCCParserTests.SetupContext(code, false); Assert.AreEqual("operator()", context.NextFunction()); }
public void FunctionNameWithGenericsIsRecognizedAsFunction() { string code = "CreateVariable<T>(string name) {}"; TestContext context = CCCParserTests.SetupContext(code); Assert.IsTrue(context.NextIsFunction()); }
public void ArgsWithParenthesis() { string code = "GetMimeData(__inout CStringA &str, __in_ecount(dwFieldLen) LPCSTR szField, __in DWORD dwFieldLen, __out LPBOOL pbFound, __in BOOL bIgnoreCase = FALSE) throw() {}"; TestContext context = CCCParserTests.SetupContext(code); Assert.IsTrue(context.NextIsFunction()); Assert.AreEqual("GetMimeData", context.NextFunction()); }
public void CppyUnaryOperator() { string code = "bool X::operator != (const X& r) {} "; TestContext context = CCCParserTests.SetupContext(code); Assert.AreEqual("X::operator !=(const X& r)", context.NextFunction()); Assert.AreEqual("{", context.parser.PeekNextKeyword()); }
public void TestTemplateFunctionMultiParams() { string code = "template <typename X, typename Z>\r\n" + "static int FuncB(X x) { return 1; } \r\n"; TestContext context = CCCParserTests.SetupContext(code); Assert.AreEqual("FuncB(X x)", context.NextFunction()); }
public void TestCSharpAttributesWithNamedParam() { string code = "[SuppressMessage(\"Rule\", Justification = \"Yeah\"]\r\n" + "protected static Func(A b,B b,C c) {}"; TestContext context = CCCParserTests.SetupContext(code); Assert.AreEqual("Func(A b,B b,C c)", context.NextFunction()); }
public void CppStyleStaticCPP() { string code = "int C::StaticFunction() { }"; TestContext context = CCCParserTests.SetupContext(code); Assert.AreEqual("C::StaticFunction()", context.NextFunction()); Assert.AreEqual("{", context.parser.PeekNextKeyword()); }
public void CEqualityOperator() { string code = "bool operator == (GUID& r1, GUID& r2) {}"; TestContext context = CCCParserTests.SetupContext(code); Assert.AreEqual("operator ==(GUID& r1,GUID& r2)", context.NextFunction()); // global context Assert.AreEqual("{", context.parser.PeekNextKeyword()); }
public void TestCppStylePointerOperator() { string code = "CItemValue::operator->(){}"; TestContext context = CCCParserTests.SetupContext(code, true); Assert.IsTrue(context.NextIsFunction()); Assert.AreEqual("CItemValue::operator ->", context.NextFunction()); }
public void TestCppStyleLessThanOperatorIsFoundAsFunction() { string code = "CSHA1::operator<< (const char *message_array){}"; TestContext context = CCCParserTests.SetupContext(code, true); Assert.IsTrue(context.NextIsFunction()); Assert.AreEqual("CSHA1::operator<<", context.NextFunction()); }
public void SpecializedTemplate() { string code = "template <>EXTRA"; TestContext context = CCCParserTests.SetupContext(code); context.ccc.ConsumeTemplate(); Assert.AreEqual("EXTRA", context.parser.PeekNextKeyword()); }
public void CppUsingStatements() { string code = "using xxx::YYY::cf::x; " + "void CMyClass::Foo() {} "; TestContext context = CCCParserTests.SetupContext(code); Assert.AreEqual("CMyClass::Foo()", context.NextFunction()); Assert.AreEqual("{", context.parser.PeekNextKeyword()); }
public void CppMultiFunctions() { string code = "void C::Foo() const {} " + "void B::Bar() const {} "; TestContext context = CCCParserTests.SetupContext(code); Assert.AreEqual("C::Foo()", context.NextFunction()); Assert.AreEqual("B::Bar()", context.NextFunction()); }
public void CSharpEqualityOperator() { string code = "public class CO { " + " public static bool operator ==(CO c1, CO c2) {} }"; TestContext context = CCCParserTests.SetupContext(code); Assert.AreEqual("CO::operator ==(CO c1,CO c2)", context.NextFunction()); // global context Assert.AreEqual("{", context.parser.PeekNextKeyword()); }
public void TestCShardFieldsDoesNotThrowParserOff() { string code = "public class X { " + " public int Age { get; private set; } " + " public Foo() {}"; TestContext context = CCCParserTests.SetupContext(code, false); Assert.AreEqual("X::Foo()", context.NextFunction()); }
public void TestClassWithGeneric() { string code = "" + "class SingletonProvider<T> where T : new()\r\n" + "{ void Foo() {} }"; TestContext context = CCCParserTests.SetupContext(code); Assert.IsTrue(context.NextIsClass()); Assert.AreEqual("SingletonProvider<T>::Foo()", context.NextFunction()); }
public void CppConstStyleFunction() { string code = "int Y::Foo() const {}"; TestContext context = CCCParserTests.SetupContext(code); string function = context.NextFunction(); Assert.AreEqual("{", context.parser.PeekNextKeyword()); Assert.AreEqual("Y::Foo()", function); }
public void TestTemplatedClassWithInheritance() { string code = "template <typename X, typename B>\r\n" + "class Bar<X, B> : public Base { \r\n " + " void Foo(void) { } \r\n " + "}"; TestContext context = CCCParserTests.SetupContext(code); Assert.AreEqual("Bar<X,B>::Foo(void)", context.NextFunction()); }