The general concept of these automatic tests is always the same: you know that, given a certain input, a function should yield a certain result. Compare the actual result with the one you expect. If they are the same, the test is passed, otherwise you either have a bug in your code or in your test.
That said, let's try to apply it to your specific case. You are passing buffer
by reference, so that you can modify it (otherwise it should be a const reference!). So you have to write tests that call your function and then check what happened to buffer
, instead of checking the returned value. Conceptually it's the same: you provide some input and compare the output with the expected one. It's just that in this case the output isn't a returned value, but rather the same object used as input.
In case this is not possible, for example because the arguments are passed by const reference or by value, you must understand how your function interacts with the rest of the world. If it doesn't return, throw, modify one of the input arguments, etc, then it is not a good candidate for these tests. These could mean 2 things: that it is a function you don't care about testing (at least in this way), or that you must refactor your code.
An example of the former would be something that interacts with hardware. Suppose you are writing code for some embedded system with a LED, and you have a function to turn the LED on or off. This is not a case that lends itself to automatic tests. Just skip it, you don't need to cover 100% of your code with automatic tests (see this great answer).
On the other hand, maybe your function interacts with the rest of the world thanks to global variables, which your program makes heavy use of (terrible idea). Well in this case you could still write some tests (just check what happens to the global variables after you have called the function), but what you should do is refactoring your code so that your function receives as argument all the variables that it needs, and after you've done it for all the functions, you can change the global variables to non-global, and you end up with functions that return a value and/or modify the arguments passed as reference or pointer, for which writing tests is easy.
To make it short: if you have a function that you don't know how to test, then probably either writing tests for it isn't worth it, or it is an indicator that your code might require some changes.