Пример #1
0
        public void PureVirtual()
        {
            string code = "virtual int XYZ() = 0;";

            TestContext context = CCCParserTests.SetupContext(code);

            context.NextFunction();
        }
Пример #2
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());
        }
Пример #3
0
        public void FunctionWithOperatorNameIsNotAnOperator()
        {
            string code = "bool isoperator(int ch) { return false; }";

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

            Assert.AreEqual("isoperator", context.NextFunction());
        }
Пример #4
0
        public void CppStyleForwardDeclared()
        {
            string code = "int X::Deliver() const;";

            TestContext context = CCCParserTests.SetupContext(code);

            context.NextFunction();
        }
Пример #5
0
        public void CStyleForwardDeclared()
        {
            string code = "int Deliver(int y, int x);";

            TestContext context = CCCParserTests.SetupContext(code);

            context.NextFunction();
        }
Пример #6
0
        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());
        }
Пример #7
0
        public void FunctionWithGeneric()
        {
            string code = "CreateVariable<T>(string name) {}";

            TestContext context = CCCParserTests.SetupContext(code);

            Assert.AreEqual("CreateVariable<T>(string name)", context.NextFunction());
        }
Пример #8
0
        public void MethodPreceededByTabIsRecognized()
        {
            string code = "int\tFoo() { ";

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

            Assert.AreEqual("Foo", context.NextFunction());
        }
Пример #9
0
        public void TestFunctionNotRecognizedAsClass()
        {
            string code = "void ClassFunc();";

            TestContext context = CCCParserTests.SetupContext(code);

            Assert.AreEqual(false, context.NextIsClass());
        }
Пример #10
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());
        }
Пример #11
0
        public void TestNextIsClass()
        {
            string code = "class CMyClass {"; //forward declaration

            TestContext context = CCCParserTests.SetupContext(code);

            Assert.AreEqual(true, context.NextIsClass());
        }
Пример #12
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());
        }
Пример #13
0
        public void TestVoidOperator()
        {
            string code = "operator()(void const*) const {}";

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

            Assert.AreEqual("operator()", context.NextFunction());
        }
Пример #14
0
        public void FunctionNameWithGenericsIsRecognizedAsFunction()
        {
            string code = "CreateVariable<T>(string name) {}";

            TestContext context = CCCParserTests.SetupContext(code);

            Assert.IsTrue(context.NextIsFunction());
        }
Пример #15
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());
        }
Пример #16
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());
        }
Пример #17
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());
        }
Пример #18
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());
        }
Пример #19
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());
        }
Пример #20
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());
        }
Пример #21
0
        public void TestCppStylePointerOperator()
        {
            string code = "CItemValue::operator->(){}";

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

            Assert.IsTrue(context.NextIsFunction());
            Assert.AreEqual("CItemValue::operator ->", context.NextFunction());
        }
Пример #22
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());
        }
Пример #23
0
        public void SpecializedTemplate()
        {
            string code = "template <>EXTRA";

            TestContext context = CCCParserTests.SetupContext(code);

            context.ccc.ConsumeTemplate();

            Assert.AreEqual("EXTRA", context.parser.PeekNextKeyword());
        }
Пример #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());
        }
Пример #25
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());
        }
Пример #26
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());
        }
Пример #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());
        }
Пример #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());
        }
Пример #29
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);
        }
Пример #30
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());
        }