Exemplo n.º 1
0
        public void FunctionWithOperatorNameIsNotAnOperator()
        {
            string code = "bool isoperator(int ch) { return false; }";

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

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

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

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

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

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

            TestContext context = CCCParserTests.SetupContext(code);

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

            TestContext context = CCCParserTests.SetupContext(code);

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

            TestContext context = CCCParserTests.SetupContext(code);

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

            TestContext context = CCCParserTests.SetupContext(code);

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

            TestContext context = CCCParserTests.SetupContext(code);

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

            TestContext context = CCCParserTests.SetupContext(code);

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

            TestContext context = CCCParserTests.SetupContext(code);

            context.NextFunction();
        }
Exemplo n.º 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());
        }
Exemplo n.º 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());
        }
Exemplo n.º 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());
        }
Exemplo n.º 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());
        }
Exemplo n.º 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());
        }
Exemplo n.º 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());
        }
Exemplo n.º 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());
        }
Exemplo n.º 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());
        }
Exemplo n.º 22
0
        public void SpecializedTemplate()
        {
            string code = "template <>EXTRA";

            TestContext context = CCCParserTests.SetupContext(code);

            context.ccc.ConsumeTemplate();

            Assert.AreEqual("EXTRA", context.parser.PeekNextKeyword());
        }
Exemplo n.º 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());
        }
Exemplo n.º 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());
        }
Exemplo n.º 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());
        }
Exemplo n.º 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);
        }
Exemplo n.º 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());
        }
Exemplo n.º 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());
        }
Exemplo n.º 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());
        }
Exemplo n.º 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);
        }