Example #1
0
        public void FunctionWithOperatorNameIsNotAnOperator()
        {
            string code = "bool isoperator(int ch) { return false; }";

            TestContext context = CCCParserTests.SetupContext(code, true);

            Assert.AreEqual("isoperator", context.NextFunction());
        }
Example #2
0
        public void MethodPreceededByTabIsRecognized()
        {
            string code = "int\tFoo() { ";

            TestContext context = CCCParserTests.SetupContext(code, true);

            Assert.AreEqual("Foo", context.NextFunction());
        }
Example #3
0
        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());
        }
Example #4
0
        public void TestVoidOperator()
        {
            string code = "operator()(void const*) const {}";

            TestContext context = CCCParserTests.SetupContext(code, false);

            Assert.AreEqual("operator()", context.NextFunction());
        }
Example #5
0
        public void FunctionNameWithGenericsIsRecognizedAsFunction()
        {
            string code = "CreateVariable<T>(string name) {}";

            TestContext context = CCCParserTests.SetupContext(code);

            Assert.IsTrue(context.NextIsFunction());
        }
Example #6
0
        public void FunctionWithGeneric()
        {
            string code = "CreateVariable<T>(string name) {}";

            TestContext context = CCCParserTests.SetupContext(code);

            Assert.AreEqual("CreateVariable<T>(string name)", context.NextFunction());
        }
Example #7
0
        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());
        }
Example #8
0
        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());
        }
Example #9
0
        public void TestFunctionNotRecognizedAsClass()
        {
            string code = "void ClassFunc();";

            TestContext context = CCCParserTests.SetupContext(code);

            Assert.AreEqual(false, context.NextIsClass());
        }
Example #10
0
        public void TestNextIsClass()
        {
            string code = "class CMyClass {"; //forward declaration

            TestContext context = CCCParserTests.SetupContext(code);

            Assert.AreEqual(true, context.NextIsClass());
        }
Example #11
0
        public void PureVirtual()
        {
            string code = "virtual int XYZ() = 0;";

            TestContext context = CCCParserTests.SetupContext(code);

            context.NextFunction();
        }
Example #12
0
        public void CppStyleForwardDeclared()
        {
            string code = "int X::Deliver() const;";

            TestContext context = CCCParserTests.SetupContext(code);

            context.NextFunction();
        }
Example #13
0
        public void CStyleForwardDeclared()
        {
            string code = "int Deliver(int y, int x);";

            TestContext context = CCCParserTests.SetupContext(code);

            context.NextFunction();
        }
Example #14
0
        public void CppStyleStaticCPP()
        {
            string code = "int C::StaticFunction() { }";

            TestContext context = CCCParserTests.SetupContext(code);

            Assert.AreEqual("C::StaticFunction()", context.NextFunction());
            Assert.AreEqual("{", context.parser.PeekNextKeyword());
        }
Example #15
0
        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());
        }
Example #16
0
        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());
        }
Example #17
0
        public void TestCppStylePointerOperator()
        {
            string code = "CItemValue::operator->(){}";

            TestContext context = CCCParserTests.SetupContext(code, true);

            Assert.IsTrue(context.NextIsFunction());
            Assert.AreEqual("CItemValue::operator ->", context.NextFunction());
        }
Example #18
0
        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());
        }
Example #19
0
        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());
        }
Example #20
0
        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());
        }
Example #21
0
        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());
        }
Example #22
0
        public void SpecializedTemplate()
        {
            string code = "template <>EXTRA";

            TestContext context = CCCParserTests.SetupContext(code);

            context.ccc.ConsumeTemplate();

            Assert.AreEqual("EXTRA", context.parser.PeekNextKeyword());
        }
Example #23
0
        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());
        }
Example #24
0
        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());
        }
Example #25
0
        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());
        }
Example #26
0
        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);
        }
Example #27
0
        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());
        }
Example #28
0
        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());
        }
Example #29
0
        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());
        }
Example #30
0
        public void TemplatebasedReturn()
        {
            string code = "private List<string> GetList(int j) {}";

            TestContext context = CCCParserTests.SetupContext(code);

            string function = context.NextFunction();

            Assert.AreEqual("{", context.parser.PeekNextKeyword());
            Assert.AreEqual("GetList(int j)", function);
        }