mardi 8 août 2017

How to write tests for classes relying on the operating system

I have written a class that enumerates over the operating system's physical displays, retrieving their information and capabilities. I actually would like to test that this class works appropriately and embrace (unit) tests in general.

However, I have no idea how I would go about testing this class. Leaving the implementation details aside, it's basically defined as so:

class VideoMode {
public:
    int64 width;
    int64 height;
    std::vector<int64> frequencies;
}

class Display {
protected:
    std::vector<VideoMode> modes_;
    std::string display_name_;
    std::string adapter_name_;
    bool primary_;

public:
    Display(char* osDevName, char* osAdapterDevName);

    // typical getters
}

How would I go about testing something that is so deeply integrated and dependent on the OS, and the physically attached hardware. I understand that writing an unit test for a class like this is difficult, so what alternatives do I have?

Aucun commentaire:

Enregistrer un commentaire