/npk/cli/tests/npk_01_add.cpp

http://npk.googlecode.com/ · C++ · 28 lines · 19 code · 9 blank · 0 comment · 2 complexity · 03666549dfc7352a302fd290d494a30a MD5 · raw file

  1. #include "testutil.h"
  2. #include <npk.h>
  3. int npk_01_add( int argc, char * argv [] )
  4. {
  5. CMD( "../npk test.npk -create --f --k 1:2:3:4" );
  6. CMD( "../npk test.npk -add sample.txt --k 1:2:3:4" );
  7. int teakey[4] = {1,2,3,4};
  8. NPK_PACKAGE pack = npk_package_open( "test.npk", teakey );
  9. CHECK( pack != NULL );
  10. NPK_ENTITY entity = npk_package_get_entity( pack, "sample.txt" );
  11. CHECK( entity != NULL );
  12. NPK_SIZE size = npk_entity_get_size( entity );
  13. void* buf = malloc( size );
  14. CHECK( npk_entity_read( entity, buf ) );
  15. CHECK_EQUAL_STR_WITH_FILE( (const char*)buf, "sample.txt" );
  16. free( buf );
  17. npk_package_close( pack );
  18. return 0;
  19. }