START_TEST (test_real_store_strings){ hash_t config[] = { { 0, DATA_HASHT( { HK(class), DATA_STRING("file") }, { HK(filename), DATA_STRING("data_real_store_strings.dat") }, hash_end )}, hash_end }; backend_t *backend = backend_new(config); off_t data_ptrs[6]; char *data_array[] = { "http://google.ru/", "http://yandex.ru/", "http://bing.com/", "http://rambler.ru/", "http://aport.ru/", "http://hell.com/" }; // write array to file int i; ssize_t ret; for(i=0; i < sizeof(data_array) / sizeof(char *); i++){ request_t r_write[] = { { HK(action), DATA_UINT32T(ACTION_CREATE) }, { HK(offset_out), DATA_PTR_OFFT(&data_ptrs[i]) },
#include "../vendor/catch.hpp" extern "C" { #include "mock_variables.h" #include "../src/backend.c" } TEST_CASE("backend_new/connect", "Should successfully return PA context") { s_instance = 1; callback_t *sc = (callback_t*)malloc(sizeof(callback_t)); context_t *e = (context_t*)malloc(sizeof(context_t)); e->loop = &s_instance; e->context = &s_context; context_t *r = backend_new(sc); REQUIRE(r->loop == e->loop); REQUIRE(r->context == e->context); free(r); free(e); free(sc); } TEST_CASE("backend_volume_set", "Should set volume for a single channel") { // "Single" really means "not all". // To do so, it needs to get current volumes // and that is what we really test here. // Callbacks are tested elsewhere. context_t *c = (context_t*)malloc(sizeof(context_t));
hash_t settings[] = { { 0, DATA_HASHT( { HK(class), DATA_STRING("file") }, { HK(filename), DATA_STRING("data_backend_cache_app.dat") }, hash_end )}, { 0, DATA_HASHT( { HK(class), DATA_STRING("cache-append") }, { HK(size), DATA_SIZET(100) }, hash_end )}, hash_end }; /* create backend */ backend = backend_new(settings); fail_unless(backend != NULL, "backend creation failed"); /* test read/writes */ ssize_t ret; size_t i; char buf[30] = {0}; for(i=0; i<=10; i++){ request_t request[] = { { HK(action), DATA_UINT32T(ACTION_CREATE) }, { HK(buffer), DATA_RAW(buf, 30) }, { HK(size), DATA_SIZET(30) }, hash_end };