PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 4int npk_03_flag( int argc, char * argv [] )
 5{
 6    CMD( "../npk test.npk -create --f --k 1:2:3:4" );
 7    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" );
 8    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" );
 9
10    int teakey[4] = {1,2,3,4};
11    NPK_PACKAGE pack = npk_package_open( "test.npk", teakey );
12
13    CHECK( pack != NULL );
14
15    std::string entityNames[6] = { "sample.txt", "zip.txt", "tea.txt", "zipntea.txt", "xxtea.txt", "zipnxxtea.txt" };
16
17    for( int i = 0; i < 6; ++i )
18    {
19        NPK_ENTITY entity = npk_package_get_entity( pack, entityNames[i].c_str() );
20        CHECK( entity != NULL );
21
22        NPK_SIZE size = npk_entity_get_size( entity );
23        void* buf = malloc( size );
24
25        CHECK( npk_entity_read( entity, buf ) );
26        CHECK_EQUAL_STR_WITH_FILE( (const char*)buf, "sample.txt" );
27
28        free( buf );
29    }
30
31    npk_package_close( pack );
32
33    return 0;
34}