diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2015-09-07 21:28:59 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2015-09-07 21:28:59 +0200 |
commit | 26cdc783c935a2a9b41af0083dcafe401589d41e (patch) | |
tree | 9fb5de793445c46829d36e6e78235cc22edb17d0 /tests | |
parent | 69a0fdd630b13d8864d7dfe494205139d5ecb079 (diff) | |
download | cssh-26cdc783c935a2a9b41af0083dcafe401589d41e.tar.gz cssh-26cdc783c935a2a9b41af0083dcafe401589d41e.tar.bz2 |
a first playing around with ANSI on bash
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 6 | ||||
-rw-r--r-- | tests/progressbartest.c | 32 |
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..f3becb6 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,6 @@ +include_directories(../src) + +add_executable(progressbartest progressbartest.c ../src/progressbar.c ../src/port.c) + +target_link_libraries(progressbartest ncurses) + diff --git a/tests/progressbartest.c b/tests/progressbartest.c new file mode 100644 index 0000000..8e6e0bf --- /dev/null +++ b/tests/progressbartest.c @@ -0,0 +1,32 @@ +#include "progressbar.h" +#include "port.h" + +#include <stdlib.h> +#include <stdio.h> + +int main( void ) +{ + cssh_progressbar_t p1; + cssh_progressbar_t p2; + cssh_progressbar_pool_t pool; + + create_progressbar_pool( &pool, 2 ); + create_progressbar( &p1, 0, 100, 100, "[Running on host %s]:", "host1" ); + create_progressbar( &p2, 0, 100, 100, "[Running on host %s]:", "host2" ); + append_progressbar_to_pool( &pool, &p1 ); + append_progressbar_to_pool( &pool, &p2 ); + for( unsigned int i = 0; i < 100; i++ ) { + set_value_of_progressbar( &p1, i ); + set_value_of_progressbar( &p2, 100 - i ); + cssh_msleep( 100 ); + printf( "\33[3F\n" ); + } + + free_progressbar( &p1 ); + free_progressbar( &p2 ); + remove_progressbar_from_pool( &pool, &p2 ); + remove_progressbar_from_pool( &pool, &p1 ); + free_progressbar_pool( &pool ); + + exit( EXIT_SUCCESS ); +} |