/npk/cli/tests/npk_03_flag.cpp

http://npk.googlecode.com/ · C++ · 34 lines · 24 code · 10 blank · 0 comment · 3 complexity · 02afe32721770c2a9fc3c1adfdfc0dc2 MD5 · raw file

  1. #include "testutil.h"
  2. #include <npk.h>
  3. int npk_03_flag( 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 sample.txt@zip.txt sample.txt@tea.txt sample.txt@zipntea.txt sample.txt@xxtea.txt sample.txt@zipnxxtea.txt --k 1:2:3:4" );
  7. CMD( "../npk test.npk -flag zip.txt@C tea.txt@E zipntea.txt@C@E xxtea.txt@X zipnxxtea.txt@C@X --k 1:2:3:4" );
  8. int teakey[4] = {1,2,3,4};
  9. NPK_PACKAGE pack = npk_package_open( "test.npk", teakey );
  10. CHECK( pack != NULL );
  11. std::string entityNames[6] = { "sample.txt", "zip.txt", "tea.txt", "zipntea.txt", "xxtea.txt", "zipnxxtea.txt" };
  12. for( int i = 0; i < 6; ++i )
  13. {
  14. NPK_ENTITY entity = npk_package_get_entity( pack, entityNames[i].c_str() );
  15. CHECK( entity != NULL );
  16. NPK_SIZE size = npk_entity_get_size( entity );
  17. void* buf = malloc( size );
  18. CHECK( npk_entity_read( entity, buf ) );
  19. CHECK_EQUAL_STR_WITH_FILE( (const char*)buf, "sample.txt" );
  20. free( buf );
  21. }
  22. npk_package_close( pack );
  23. return 0;
  24. }