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

/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
 4int npk_01_add( 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 --k 1:2:3:4" );
 8
 9    int teakey[4] = {1,2,3,4};
10    NPK_PACKAGE pack = npk_package_open( "test.npk", teakey );
11
12    CHECK( pack != NULL );
13
14    NPK_ENTITY entity = npk_package_get_entity( pack, "sample.txt" );
15    CHECK( entity != NULL );
16
17    NPK_SIZE size = npk_entity_get_size( entity );
18    void* buf = malloc( size );
19
20    CHECK( npk_entity_read( entity, buf ) );
21    CHECK_EQUAL_STR_WITH_FILE( (const char*)buf, "sample.txt" );
22
23    free( buf );
24
25    npk_package_close( pack );
26
27    return 0;
28}