Wednesday, July 13, 2016

Installing Google Test

Google test is a framework for unit testing in c++.
For more information watch this video

$ git clone https://github.com/google/googletest.git
$ cd googletest
$ cmake -DBUILD_SHARED_LIBS=ON .
$ make
$ sudo cp -a include/gtest /usr/include
$ sudo cp -a libgtest_main.so libgtest.so /usr/lib/
$ sudo ldconfig -v

And now compile any program that uses Google test with '-lgtest' flag.

Source: http://stackoverflow.com/questions/13513905/how-to-setup-googletest-as-a-shared-library-on-linux

Friday, June 24, 2016

Create a file with random numbers

Sometimes we need to create a file that contains several random numbers. Using bash programming we can do that very quickly. Example,

mycomputer ~% for i in {1..1000}; do echo $RANDOM; done >> nums.txt

This command executes a for loop 1000 times, prints the random variable $RANDOM and redirect the output to the file nums.txt

Print a random integer in the bash console

If you need a random positive integer, you can print the variable $RANDOM. For example:

mycomputer ~% echo $RANDOM
120865