Whether to insert the code or not, I think it depends on what you write. Suppose you write about the importance of functional testing. Then you certainly don't need to insert code. If you are writing a white-box test, or testing software by code, it is completely normal to insert code. The premise is that you don't insert code to make up the number of words ~
For example, if your thesis is about the influence of code optimization on software performance, you can write a redundant code and compare it with the optimized code.