Skip to content

Instantly share code, notes, and snippets.

@morxa
Last active August 22, 2016 18:21
Show Gist options
  • Save morxa/2db366b6f5797c0190383ce6d7c0f22a to your computer and use it in GitHub Desktop.
Save morxa/2db366b6f5797c0190383ce6d7c0f22a to your computer and use it in GitHub Desktop.
test generator
#!/bin/bash
# Copyright 2016 Till Hofmann <till.hofmann@posteo.de>
# This work is free. You can redistribute it and/or modify it under the
# terms of the Do What The Fuck You Want To Public License, Version 2,
# as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
random_word () {
ALL_NON_RANDOM_WORDS=/usr/share/dict/words
non_random_words=`cat $ALL_NON_RANDOM_WORDS | wc -l`
random_number=$(expr $non_random_words \* $RANDOM / 32767)
sed `echo $random_number`"q;d" $ALL_NON_RANDOM_WORDS
}
for i in $(seq 1 $1); do
w1=`random_word`
for j in $(seq 1 $2); do
w2=`random_word`
w3=`random_word`
echo "TEST(${w1^}Test,${w2^}${w3^}) {" | tr -d '-' >> test.cc
r=$RANDOM
echo " ASSERT_EQ($r,$r);" >> test.cc
echo "}" >> test.cc
echo >> test.cc
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment