Skip to content

Instantly share code, notes, and snippets.

@ancientstraits
Created May 12, 2022 17:30
Show Gist options
  • Save ancientstraits/b1f44e922642e11cc92f90ae7521977c to your computer and use it in GitHub Desktop.
Save ancientstraits/b1f44e922642e11cc92f90ae7521977c to your computer and use it in GitHub Desktop.
A mocking framework
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
void mock(char* s) {
srand(time(NULL));
for (int i = 0; s[i]; i++) {
if (rand() % 2 == 0)
s[i] = toupper(s[i]);
else
s[i] = tolower(s[i]);
}
}
int main() {
char str[] = "this is the mock string";
mock(str);
printf("%s\n", str);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment