Patterns for unit testing a C++ method that makes a standard library call
I'm writing a C++ class to wrap sockets (I know that there are good libraries for this--I'm rolling my own for practise):

    class Socket {
    public:
      int init(void); // calls socket(2)
      // other stuff we don't care about for the sake of this code sample
    };

This class is in turn used by several others, which I know I can unit test with [googlemock](http://code.google.com/p/googlemock/) by subclassing and mocking.

But I would like to develop this class [test first](http://en.wikipedia.org/wiki/Test-driven_development), and am a bit stuck currently. I can't use googlemock on the C standard library (i.e. `socket.h`, in this case), since a C++ class it is not. I *could* create a thin C++ wrapper class around the C standard library functions I need, e.g.

    class LibcWrapper {
    public:
       static int socket(int domain, int type, int protocol);
       static int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
       static int listen(int sockfd, int backlog);
       static int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
       static ssize_t write(int fd, const void *buf, size_t count);
       static int close(int fd);
    };

Now I can mock that and unit test my `Socket` class (which might now need to be renamed `Network` or some such). `LibcWrapper` could come in handy for other classes as well, and would not itself need to be unit tested since it just provides a bunch of class methods.

This is starting to sound good to me. Have I answered my own question, or do there exist standard patterns for test driving this sort of development in C++?
Patterns for unit testing a C++ method that makes a standard library call
===

I'm writing a C++ class to wrap sockets (I know that there are good libraries for this--I'm rolling my own for practise):

    class Socket {
    public:
      int init(void); // calls socket(2)
      // other stuff we don't care about for the sake of this code sample
    };

This class is in turn used by several others, which I know I can unit test with [googlemock](http://code.google.com/p/googlemock/) by subclassing and mocking.

But I would like to develop this class [test first](http://en.wikipedia.org/wiki/Test-driven_development), and am a bit stuck currently. I can't use googlemock on the C standard library (i.e. `socket.h`, in this case), since a C++ class it is not. I *could* create a thin C++ wrapper class around the C standard library functions I need, e.g.

    class LibcWrapper {
    public:
       static int socket(int domain, int type, int protocol);
       static int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
       static int listen(int sockfd, int backlog);
       static int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
       static ssize_t write(int fd, const void *buf, size_t count);
       static int close(int fd);
    };

Now I can mock that and unit test my `Socket` class (which might now need to be renamed `Network` or some such). `LibcWrapper` could come in handy for other classes as well, and would not itself need to be unit tested since it just provides a bunch of class methods.

This is starting to sound good to me. Have I answered my own question, or do there exist standard patterns for test driving this sort of development in C++?