$86 GRAYBYTE WORDPRESS FILE MANAGER $85

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 172.67.217.254 | ADMIN IP 216.73.216.180
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : mail

/opt/cpanel/ea-ruby27/src/passenger-release-6.1.2/doc/

HOME
Current File : /opt/cpanel/ea-ruby27/src/passenger-release-6.1.2/doc//CxxMockingStrategy.md
# C++ mocking strategy

- We don't use any mocking library.
- We implement mocking by splitting mockable code to protected virtual methods. Inside test suites, we create a subclass in which we override the methods we want to mock.
- Best practices for the override:
   - Opt-in for mocking on a per-test basis.
   - When not opted-in, call the parent class's method instead of duplicating its code.

Example:

```c++
class Greeter {
protected:
    virtual const char *name() {
        return "john";
    }

public:
    void greet() {
        std::cout << "hello " << name() << std::endl;
    }
};

// In the test suite:
class TestGreeter: public Greeter {
protected:
    virtual const char *name() override {
        if (mockName != nullptr) {
            return mockName;
        } else {
            return Greeter::name();
        }
    }

public:
    const char *mockName; // Set to non-nullptr to mock the name

    TestGreeter()
        : mockName(nullptr)
        { }
};
```


Current_dir [ NOT WRITEABLE ] Document_root [ NOT WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
13 Feb 2026 9.30 AM
root / root
0755
DesignAspects
--
13 Feb 2026 9.30 AM
root / root
0755
images
--
13 Feb 2026 9.30 AM
root / root
0755
templates
--
13 Feb 2026 9.30 AM
root / root
0755
AiInstructions.md
6.629 KB
27 Jan 2026 11.50 PM
root / root
0644
CodingTipsAndPitfalls.md
2.927 KB
27 Jan 2026 11.50 PM
root / root
0644
CxxMockingStrategy.md
0.959 KB
27 Jan 2026 11.50 PM
root / root
0644
CxxTestingGuide.md
2.972 KB
27 Jan 2026 11.50 PM
root / root
0644
DebuggingAndStressTesting.md
4.954 KB
27 Jan 2026 11.50 PM
root / root
0644
DeveloperQuickstart.md
3.505 KB
27 Jan 2026 11.50 PM
root / root
0644
Packaging.md
12.526 KB
27 Jan 2026 11.50 PM
root / root
0644
TempFileHandling.md
0.778 KB
27 Jan 2026 11.50 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF