Better test names

I have some simple tests written, however, the names are not good…I think, any suggestions on better names? I’m not really sure how these tests should be named. I’m looking for a format or pattern I can follow. [TestClass] public class DoorTests { [TestMethod] public void DoorIsNotVirtualIfNameStartsWithLetterOtherThanV() { var door = new Door {Name = … Read more

Maths test program

I have written this simple program that is a basically a maths test. I would like to know is there any areas I can improve on and if I have any bad habits that would be useful to break now. I realise I could have written this in the main class, but I was trying … Read more

Windows socket class

I need some advice to see if my simple Windows socket class is good enough to be used in a simple chat application. #include <iostream> #include <string> #include <Windows.h> class Socket { private: WSADATA wsaData; SOCKET hSocket; sockaddr_in service; std::string addr; USHORT port; int exitCode; bool initializeWSA(); bool initializeSocket(); bool bind(); bool listen(); bool connect(); … Read more

Printing the contents of a string array using pointers

I’m currently studying C and I’m trying to just print the contents of a string array. I’m using pNames to point to the first char pointer and iterating from there. A more proper approach would use this pointer, get a char* each time and use printf(“%s”, pNames[i]) to print a whole string. However, I thought … Read more

Reversing a number

I was working through a programming challenge I found on Reddit and it seemed easy enough: Find all numbers less than \$10^n\$ where the number and its reverse (the reverse of \$123\$ is \$321\$) are both divisible by \$7\$ and then sum them all together. def challenge_229(power): numbers = [] for x in range(0, 10**power, … Read more

Versatile string validation

I passed a technical test the other day, one part included a cheap string validation and I am wondering this can be further improved to be more versatile to requirement changes. The requirements were something like that Create a Validate method, which accepts a string and returns true if it’s valid and false if it’s … Read more